Ignore:
Timestamp:
Mar 23, 2011, 11:45:41 PM (14 years ago)
Author:
dmik
Message:

testapp/systray: Added "TaskbarCreated" support.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/testapp/gui/systray/StealthDialog.cpp

    r21593 r21603  
    2323                     LPTSTR    lpCmdLine,
    2424                     int       nCmdShow);
    25                      
     25
    2626//Win32 resource table (produced by wrc)
    2727extern DWORD Resource_PEResTab;
    28                      
     28
    2929int main(int argc, char **argv)
    3030{
     
    6464        {
    6565                if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)||
    66                         !IsDialogMessage(msg.hwnd,&msg) ) 
     66                        !IsDialogMessage(msg.hwnd,&msg) )
    6767                {
    6868                        TranslateMessage(&msg);
     
    7373}
    7474
    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
     76VOID AddTrayIcon(HWND hWnd)
     77{
    8778        // Fill the NOTIFYICONDATA structure and call Shell_NotifyIcon
    8879
     
    126117
    127118        // load the icon
    128         niData.hIcon = (HICON)LoadImage(hInstance,MAKEINTRESOURCE(IDI_STEALTHDLG),
     119        niData.hIcon = (HICON)LoadImage(hInst,MAKEINTRESOURCE(IDI_STEALTHDLG),
    129120                IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),
    130121                LR_DEFAULTCOLOR);
     
    144135        if(niData.hIcon && DestroyIcon(niData.hIcon))
    145136                niData.hIcon = NULL;
     137}
     138
     139//      Initialize the window
     140BOOL 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);
    146152
    147153        // call ShowWindow here to make the dialog initially visible
     
    161167                MAKEINTRESOURCE(IDI_STEALTHDLG),
    162168                IMAGE_ICON, 0,0, LR_SHARED|LR_DEFAULTSIZE);
    163 printf("### hIcon %x\n", hIcon);
    164169        SendMessage(hWnd,WM_SETICON,ICON_BIG,(LPARAM)hIcon);
    165170        SendMessage(hWnd,WM_SETICON,ICON_SMALL,(LPARAM)hIcon);
     
    221226INT_PTR CALLBACK DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    222227{
     228    static UINT wmTaskbarCreated;
     229
    223230        int wmId, wmEvent;
    224231
    225         switch (message) 
     232        switch (message)
    226233        {
    227234        case SWM_TRAYMSG:
     
    247254        case WM_COMMAND:
    248255                wmId    = LOWORD(wParam);
    249                 wmEvent = HIWORD(wParam); 
     256                wmEvent = HIWORD(wParam);
    250257
    251258                switch (wmId)
     
    267274                return 1;
    268275        case WM_INITDIALOG:
     276            wmTaskbarCreated = RegisterWindowMessage(TEXT("TaskbarCreated"));
    269277                return OnInitDialog(hWnd);
    270278        case WM_CLOSE:
     
    276284                PostQuitMessage(0);
    277285                break;
     286        default:
     287                if (message == wmTaskbarCreated)
     288                        AddTrayIcon(hWnd);
     289                break;
    278290        }
    279291        return 0;
     
    289301
    290302        case WM_COMMAND:
    291                 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 
     303                if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
    292304                {
    293305                        EndDialog(hDlg, LOWORD(wParam));
Note: See TracChangeset for help on using the changeset viewer.