Commit b68b0e3e authored by Sergey Lyubka's avatar Sergey Lyubka

Exit cleanly on WM_CLOSE

parent cf53f3da
...@@ -440,6 +440,11 @@ static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, ...@@ -440,6 +440,11 @@ static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam,
PostMessage(hWnd, WM_NULL, 0, 0); PostMessage(hWnd, WM_NULL, 0, 0);
DestroyMenu(hMenu); DestroyMenu(hMenu);
break; break;
case WM_CLOSE:
mg_stop(ctx);
Shell_NotifyIcon(NIM_DELETE, &TrayIcon);
PostQuitMessage(0);
return 0; // We've just sent our own quit message, with proper hwnd.
} }
break; break;
} }
...@@ -473,10 +478,12 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show) { ...@@ -473,10 +478,12 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show) {
TrayIcon.uCallbackMessage = WM_USER; TrayIcon.uCallbackMessage = WM_USER;
Shell_NotifyIcon(NIM_ADD, &TrayIcon); Shell_NotifyIcon(NIM_ADD, &TrayIcon);
while (GetMessage(&msg, hWnd, 0, 0)) { while (GetMessage(&msg, hWnd, 0, 0) > 0) {
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);
} }
return msg.wParam;
} }
#else #else
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment