mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-01-31 13:40:35 +00:00
Fix: DllMain creation/destroy of the window handle, by Andy Fillebrown
This commit is contained in:
parent
b86c115898
commit
bc9bc38229
1 changed files with 30 additions and 5 deletions
|
@ -24,15 +24,31 @@
|
|||
|
||||
static HINSTANCE fluid_hinstance = NULL;
|
||||
static HWND fluid_wnd = NULL;
|
||||
static int fluid_refCount = 0;
|
||||
|
||||
int fluid_win32_create_window(void);
|
||||
void fluid_win32_destroy_window(void);
|
||||
HWND fluid_win32_get_window(void);
|
||||
|
||||
#ifndef FLUIDSYNTH_NOT_A_DLL
|
||||
BOOL WINAPI DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
FLUID_LOG(FLUID_DBG, "DllMain");
|
||||
fluid_set_hinstance((void*) hModule);
|
||||
fluid_win32_create_window();
|
||||
switch (ul_reason_for_call) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
fluid_refCount++;
|
||||
if (1 == fluid_refCount) {
|
||||
fluid_set_hinstance((void*) hModule);
|
||||
fluid_win32_create_window();
|
||||
}
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
fluid_refCount--;
|
||||
if (fluid_refCount == 0) {
|
||||
fluid_win32_destroy_window();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
@ -91,8 +107,8 @@ int fluid_win32_create_window(void)
|
|||
return -100;
|
||||
}
|
||||
fluid_wnd = CreateWindow((LPSTR) "FluidSynth", (LPSTR) "FluidSynth", WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, 400, 300, (HWND) NULL, (HMENU) NULL,
|
||||
fluid_hinstance, (LPSTR) NULL);
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, 400, 300, (HWND) NULL, (HMENU) NULL,
|
||||
fluid_hinstance, (LPSTR) NULL);
|
||||
if (fluid_wnd == NULL) {
|
||||
FLUID_LOG(FLUID_ERR, "Can't create window");
|
||||
return -101;
|
||||
|
@ -100,9 +116,18 @@ int fluid_win32_create_window(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void fluid_win32_destroy_window(void)
|
||||
{
|
||||
HWND hwnd = fluid_win32_get_window();
|
||||
if (hwnd) {
|
||||
DestroyWindow(hwnd);
|
||||
fluid_wnd = 0;
|
||||
}
|
||||
}
|
||||
|
||||
HWND fluid_win32_get_window(void)
|
||||
{
|
||||
return fluid_wnd;
|
||||
return fluid_wnd;
|
||||
}
|
||||
|
||||
#endif // #ifdef WIN32
|
||||
|
|
Loading…
Reference in a new issue