[windows] Support disabling window icon

This commit is contained in:
Lea Anthony
2021-06-14 12:00:47 +10:00
parent b0c522a59a
commit 58e6ce10ad
4 changed files with 25 additions and 4 deletions

View File

@@ -62,6 +62,7 @@ struct Application *NewApplication(const char *title, int width, int height, int
result->hideWindowOnClose = hideWindowOnClose;
result->webviewIsTranparent = false;
result->windowBackgroundIsTranslucent = false;
result->disableWindowIcon = false;
// Min/Max Width/Height
result->minWidth = 0;
@@ -373,9 +374,10 @@ void Run(struct Application* app, int argc, char **argv) {
wc.hInstance = GetModuleHandle(NULL);
wc.lpszClassName = CLASS_NAME;
// TODO: Make configurable
wc.hIcon = LoadIcon(wc.hInstance, MAKEINTRESOURCE(100));
wc.hIconSm = LoadIcon(wc.hInstance, MAKEINTRESOURCE(100));
if( app->disableWindowIcon == false ) {
wc.hIcon = LoadIcon(wc.hInstance, MAKEINTRESOURCE(100));
wc.hIconSm = LoadIcon(wc.hInstance, MAKEINTRESOURCE(100));
}
// Configure translucency
DWORD dwExStyle = 0;
@@ -417,6 +419,13 @@ void Run(struct Application* app, int argc, char **argv) {
return;
}
// Credit: https://stackoverflow.com/a/35482689
if( app->disableWindowIcon ) {
int extendedStyle = GetWindowLong(app->window, GWL_EXSTYLE);
SetWindowLong(app->window, GWL_EXSTYLE, extendedStyle | WS_EX_DLGMODALFRAME);
SetWindowPos(nullptr, nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
}
if ( app->windowBackgroundIsTranslucent ) {
// Enable the translucent background effect
@@ -442,7 +451,6 @@ void Run(struct Application* app, int argc, char **argv) {
// private center() as we are on main thread
center(app);
// SetLayeredWindowAttributes(app->window,RGB(255,255,255),0,LWA_COLORKEY);
ShowWindow(app->window, startVisibility);
UpdateWindow(app->window);
SetFocus(app->window);
@@ -559,6 +567,10 @@ void Show(struct Application* app) {
);
}
void DisableWindowIcon(struct Application* app) {
app->disableWindowIcon = true;
}
void center(struct Application* app) {
HMONITOR currentMonitor = MonitorFromWindow(app->window, MONITOR_DEFAULTTONEAREST);

View File

@@ -9,6 +9,8 @@ import "C"
#include "ffenestri.h"
extern void DisableWindowIcon(struct Application* app);
*/
import "C"
@@ -28,6 +30,10 @@ func (a *Application) processPlatformSettings() error {
C.WindowBackgroundIsTranslucent(a.app)
}
if config.DisableWindowIcon {
C.DisableWindowIcon(a.app)
}
//// Process menu
////applicationMenu := options.GetApplicationMenu(a.config)
//applicationMenu := a.menuManager.GetApplicationMenuJSON()

View File

@@ -45,6 +45,7 @@ struct Application{
bool webviewIsTranparent;
bool windowBackgroundIsTranslucent;
COREWEBVIEW2_COLOR backgroundColour;
bool disableWindowIcon;
// placeholders
char* bindings;
@@ -69,6 +70,7 @@ void completed(struct Application* app);
// Callback
extern "C" {
void DisableWindowIcon(struct Application* app);
void messageFromWindowCallback(const char *);
}