diff options
author | chai <chaifix@163.com> | 2020-07-28 00:30:33 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-07-28 00:30:33 +0800 |
commit | 5dfdb6b58b2dc7bbd3348004c1fcd17e23fea48b (patch) | |
tree | a03f1a01382595ed50cc4780a728b22013f6d5a0 /src/extern | |
parent | 690f20cdbe8dad3fce7a547934a5a8322303342d (diff) |
Diffstat (limited to 'src/extern')
-rw-r--r-- | src/extern/wog.c | 47 | ||||
-rw-r--r-- | src/extern/wog.h | 2 |
2 files changed, 34 insertions, 15 deletions
diff --git a/src/extern/wog.c b/src/extern/wog.c index 4892f99..194f893 100644 --- a/src/extern/wog.c +++ b/src/extern/wog.c @@ -37,9 +37,12 @@ #define min(a, b) (a < b ? a : b) #define clamp(x, minv, maxv) (max(minv, min(x, maxv))) +static HINSTANCE g_hinstance = NULL; + typedef struct wog_Window { HWND hwnd; // Window handler + HINSTANCE hInstance; HDC hdc; // Device Context HDC mdc; // Memory Device Contexts #if WOG_API == WOG_GDI @@ -55,7 +58,6 @@ typedef struct wog_GLContext }wog_GLContext; #endif - // A mouse capture count is used void wog_setMouseCapture(wog_Window* wnd) { @@ -299,10 +301,11 @@ static int registerWindowClass() windowClass.cbSize = sizeof(WNDCLASSEX); // Size Of The windowClass Structure windowClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraws The Window For Any Movement / Resizing windowClass.lpfnWndProc = (WNDPROC)(WindowProc); // WindowProc Handles Messages - windowClass.hInstance = GetModuleHandle(0); // Set The Instance + windowClass.hInstance = g_hinstance; // Set The Instance windowClass.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE); // Class Background Brush Color windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); // Load The Arrow Pointer windowClass.lpszClassName = WINDOW_CLASS; // Sets The Applications Classname + windowClass.hIcon = (HICON)LoadIcon(g_hinstance, "icon.ico"); if (RegisterClassEx(&windowClass) == 0) // Did Registering The Class Fail? { @@ -357,6 +360,11 @@ wog_Window* wog_createWindow(const char* title, int width, int height, int x, in { int client_w = width, client_h = height; + if (g_hinstance == NULL) + { + g_hinstance = GetModuleHandle(NULL); + } + if (! registerWindowClass()) { printf("Register window class failed.\n"); @@ -395,6 +403,8 @@ wog_Window* wog_createWindow(const char* title, int width, int height, int x, in wnd ); + wnd->hInstance = g_hinstance; + if (wnd->hwnd == 0) return 0; @@ -625,22 +635,24 @@ int console_main(int argc, char* argv[]) */ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) { - char* temp = GetCommandLine(); - int len = strlen(temp) + 1; - char* cmd = stack_alloc(char, len); - strcpy(cmd, temp); - cmd[len - 1] = '\0'; + g_hinstance = hInst; - int argc = 0; - char** argv = 0; - argc = ParseCommandLine(cmd, 0); - ParseCommandLine(cmd, 0); - argv = stack_alloc(char*, argc + 1); - ParseCommandLine(cmd, argv); + char* temp = GetCommandLine(); + int len = strlen(temp) + 1; + char* cmd = stack_alloc(char, len); + strcpy(cmd, temp); + cmd[len - 1] = '\0'; - int status = console_main(argc, argv); + int argc = 0; + char** argv = 0; + argc = ParseCommandLine(cmd, 0); + ParseCommandLine(cmd, 0); + argv = stack_alloc(char*, argc + 1); + ParseCommandLine(cmd, argv); - return status; + int status = console_main(argc, argv); + + return status; } @@ -714,3 +726,8 @@ void wog_setcursorImage(wog_Window* wnd, Wog_Cursor icon) { SetCursor(icon); } + +HINSTANCE wog_get_instance() +{ + return g_hinstance; +} diff --git a/src/extern/wog.h b/src/extern/wog.h index c5e5c06..89c98fb 100644 --- a/src/extern/wog.h +++ b/src/extern/wog.h @@ -214,4 +214,6 @@ void wog_setcursorImage(wog_Window* wnd, Wog_Cursor icon); void wog_setMouseCapture(wog_Window* wnd); void wog_releaseMouseCapture(wog_Window* wnd); +HINSTANCE wog_get_instance(); + #endif
\ No newline at end of file |