Started code for handling WM_QUERYENDSESSION and its console equivalent.
This commit is contained in:
parent
03cf0845ef
commit
bd4716c949
|
@ -243,6 +243,19 @@ static LRESULT CALLBACK containerWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP
|
||||||
logLastError("error getting client rect for resize in containerWndProc()");
|
logLastError("error getting client rect for resize in containerWndProc()");
|
||||||
resize(cc, &r);
|
resize(cc, &r);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
// and this is run only on the initial parent
|
||||||
|
// this ensures that all end session handling is done in one place and only once
|
||||||
|
case WM_QUERYENDSESSION:
|
||||||
|
case msgConsoleEndSession:
|
||||||
|
if (cc != NULL)
|
||||||
|
break;
|
||||||
|
// TODO block handler
|
||||||
|
if (shouldQuit()) {
|
||||||
|
uiQuit();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
||||||
|
|
|
@ -52,6 +52,19 @@ static const char *loadLastError(const char *message)
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL WINAPI consoleCtrlHandler(DWORD dwCtrlType)
|
||||||
|
{
|
||||||
|
switch (dwCtrlType) {
|
||||||
|
case CTRL_LOGOFF_EVENT:
|
||||||
|
case CTRL_SHUTDOWN_EVENT:
|
||||||
|
// the handler is run in a separate thread
|
||||||
|
SendMessageW(initialParent, msgConsoleEndSession, 0, 0);
|
||||||
|
// we handled it here
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
uiInitOptions options;
|
uiInitOptions options;
|
||||||
|
|
||||||
const char *uiInit(uiInitOptions *o)
|
const char *uiInit(uiInitOptions *o)
|
||||||
|
@ -98,6 +111,9 @@ const char *uiInit(uiInitOptions *o)
|
||||||
if (ce != NULL)
|
if (ce != NULL)
|
||||||
return loadLastError(ce);
|
return loadLastError(ce);
|
||||||
|
|
||||||
|
if (SetConsoleCtrlHandler(consoleCtrlHandler, TRUE) == 0)
|
||||||
|
return loadLastError("setting up console end session handler");
|
||||||
|
|
||||||
hollowBrush = (HBRUSH) GetStockObject(HOLLOW_BRUSH);
|
hollowBrush = (HBRUSH) GetStockObject(HOLLOW_BRUSH);
|
||||||
if (hollowBrush == NULL)
|
if (hollowBrush == NULL)
|
||||||
return loadLastError("getting hollow brush");
|
return loadLastError("getting hollow brush");
|
||||||
|
@ -109,6 +125,8 @@ void uiUninit(void)
|
||||||
{
|
{
|
||||||
uninitMenus();
|
uninitMenus();
|
||||||
// TODO delete hollow brush
|
// TODO delete hollow brush
|
||||||
|
if (SetConsoleCtrlHandler(consoleCtrlHandler, FALSE) == 0)
|
||||||
|
logLastError("unregistering console end session handler");
|
||||||
uninitContainer();
|
uninitContainer();
|
||||||
if (DeleteObject(hMessageFont) == 0)
|
if (DeleteObject(hMessageFont) == 0)
|
||||||
logLastError("error deleting control font in uiUninit()");
|
logLastError("error deleting control font in uiUninit()");
|
||||||
|
|
|
@ -36,6 +36,7 @@ enum {
|
||||||
msgNOTIFY,
|
msgNOTIFY,
|
||||||
msgUpdateChild, // fake because Windows seems to SWP_NOSIZE MoveWindow()s and SetWindowPos()s that don't change the window size (even if SWP_NOSIZE isn't specified)
|
msgUpdateChild, // fake because Windows seems to SWP_NOSIZE MoveWindow()s and SetWindowPos()s that don't change the window size (even if SWP_NOSIZE isn't specified)
|
||||||
msgHasTabStops,
|
msgHasTabStops,
|
||||||
|
msgConsoleEndSession,
|
||||||
};
|
};
|
||||||
|
|
||||||
// debug.c
|
// debug.c
|
||||||
|
|
Loading…
Reference in New Issue