Skip to content

Commit

Permalink
Exit cleanly on WM_CLOSE
Browse files Browse the repository at this point in the history
  • Loading branch information
cpq committed Aug 16, 2012
1 parent cf53f3d commit b68b0e3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,11 @@ static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam,
PostMessage(hWnd, WM_NULL, 0, 0);
DestroyMenu(hMenu);
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;
}
Expand Down Expand Up @@ -473,10 +478,12 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show) {
TrayIcon.uCallbackMessage = WM_USER;
Shell_NotifyIcon(NIM_ADD, &TrayIcon);

while (GetMessage(&msg, hWnd, 0, 0)) {
while (GetMessage(&msg, hWnd, 0, 0) > 0) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}

return msg.wParam;
}
#else
int main(int argc, char *argv[]) {
Expand Down

0 comments on commit b68b0e3

Please sign in to comment.