Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define WIN32_LEAN_AND_MEAN
- #include <Windows.h>
- #include "../NotifyIcon.h"
- static NOTIFYICON_TOKEN ni, ni2;
- static void CALLBACK MyHandleNiEvent(
- NOTIFYICON_EVENTINFO ei)
- {
- if (ei.event == NOTIFYICON_EVENT_CLICK)
- {
- if (ei.token == ni) {
- int ret = MessageBox(GetForegroundWindow(),
- TEXT("Do you want to quit?"),
- TEXT("Quit?"), MB_ICONQUESTION | MB_YESNO);
- if (ret == IDYES) { PostQuitMessage(0); }
- }
- else if (ei.token == ni2) {
- MessageBox(GetForegroundWindow(),
- TEXT("This is how the Shell_NotifyIcon API should be."),
- TEXT("Encapsulated the headache"), MB_ICONINFORMATION);
- }
- }
- }
- int APIENTRY WinMain(HINSTANCE z, HINSTANCE zz, LPSTR zzz, int nCmdShow)
- {
- MSG msg = {0};
- ni = NotifyIcon_Create();
- ni2 = NotifyIcon_Create();
- NotifyIcon_SetIcon(ni, LoadIcon(NULL, IDI_APPLICATION));
- NotifyIcon_SetTip(ni, TEXT("Application"));
- NotifyIcon_SetIcon(ni2, LoadIcon(NULL, IDI_INFORMATION));
- NotifyIcon_SetTip(ni2, TEXT("Information"));
- NotifyIcon_SetEventCallback(ni, MyHandleNiEvent, NULL);
- NotifyIcon_SetEventCallback(ni2, MyHandleNiEvent, NULL);
- while (GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- NotifyIcon_Delete(ni);
- NotifyIcon_Delete(ni2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement