Changeset 21603 for trunk/testapp/gui/systray/StealthDialog.cpp
- Timestamp:
- Mar 23, 2011, 11:45:41 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/testapp/gui/systray/StealthDialog.cpp
r21593 r21603 23 23 LPTSTR lpCmdLine, 24 24 int nCmdShow); 25 25 26 26 //Win32 resource table (produced by wrc) 27 27 extern DWORD Resource_PEResTab; 28 28 29 29 int main(int argc, char **argv) 30 30 { … … 64 64 { 65 65 if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)|| 66 !IsDialogMessage(msg.hwnd,&msg) ) 66 !IsDialogMessage(msg.hwnd,&msg) ) 67 67 { 68 68 TranslateMessage(&msg); … … 73 73 } 74 74 75 // Initialize the window and tray icon 76 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) 77 { 78 // prepare for XP style controls 79 InitCommonControls(); 80 81 // store instance handle and create dialog 82 hInst = hInstance; 83 HWND hWnd = CreateDialog( hInstance, MAKEINTRESOURCE(IDD_DLG_DIALOG), 84 NULL, (DLGPROC)DlgProc ); 85 if (!hWnd) return FALSE; 86 75 // Add tray icon 76 VOID AddTrayIcon(HWND hWnd) 77 { 87 78 // Fill the NOTIFYICONDATA structure and call Shell_NotifyIcon 88 79 … … 126 117 127 118 // load the icon 128 niData.hIcon = (HICON)LoadImage(hInst ance,MAKEINTRESOURCE(IDI_STEALTHDLG),119 niData.hIcon = (HICON)LoadImage(hInst,MAKEINTRESOURCE(IDI_STEALTHDLG), 129 120 IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON), 130 121 LR_DEFAULTCOLOR); … … 144 135 if(niData.hIcon && DestroyIcon(niData.hIcon)) 145 136 niData.hIcon = NULL; 137 } 138 139 // Initialize the window 140 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) 141 { 142 // prepare for XP style controls 143 InitCommonControls(); 144 145 // store instance handle and create dialog 146 hInst = hInstance; 147 HWND hWnd = CreateDialog( hInstance, MAKEINTRESOURCE(IDD_DLG_DIALOG), 148 NULL, (DLGPROC)DlgProc ); 149 if (!hWnd) return FALSE; 150 151 AddTrayIcon(hWnd); 146 152 147 153 // call ShowWindow here to make the dialog initially visible … … 161 167 MAKEINTRESOURCE(IDI_STEALTHDLG), 162 168 IMAGE_ICON, 0,0, LR_SHARED|LR_DEFAULTSIZE); 163 printf("### hIcon %x\n", hIcon);164 169 SendMessage(hWnd,WM_SETICON,ICON_BIG,(LPARAM)hIcon); 165 170 SendMessage(hWnd,WM_SETICON,ICON_SMALL,(LPARAM)hIcon); … … 221 226 INT_PTR CALLBACK DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 222 227 { 228 static UINT wmTaskbarCreated; 229 223 230 int wmId, wmEvent; 224 231 225 switch (message) 232 switch (message) 226 233 { 227 234 case SWM_TRAYMSG: … … 247 254 case WM_COMMAND: 248 255 wmId = LOWORD(wParam); 249 wmEvent = HIWORD(wParam); 256 wmEvent = HIWORD(wParam); 250 257 251 258 switch (wmId) … … 267 274 return 1; 268 275 case WM_INITDIALOG: 276 wmTaskbarCreated = RegisterWindowMessage(TEXT("TaskbarCreated")); 269 277 return OnInitDialog(hWnd); 270 278 case WM_CLOSE: … … 276 284 PostQuitMessage(0); 277 285 break; 286 default: 287 if (message == wmTaskbarCreated) 288 AddTrayIcon(hWnd); 289 break; 278 290 } 279 291 return 0; … … 289 301 290 302 case WM_COMMAND: 291 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 303 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 292 304 { 293 305 EndDialog(hDlg, LOWORD(wParam));
Note:
See TracChangeset
for help on using the changeset viewer.