you need to start your MFC modal dialog program with a hidden dialog, and the only way I found for this problem was to call ShowWindow(m_hWnd, SW_HIDE) in one of WM_NCPAINT or WM_PAINT message handlers. There is another way for this problem, but needs a little more modification of your program. The normal way would be to uncheck WS_VISIBLE style in resource editor, and start you dialog using CreateDialog , then make a message loop there by calling AfxPumpMessage in a loop like this: CMyDlg mydlg; mydlg.Create(IDD_MYDIALOG);// that IDD_MYDIALOG is // the dialog resource id, // you can find it in your // dialog class definition // (TrayIco.h as you said) // in a line like this: // enum { IDD = IDD_MYDIALOG }; // if you wanted to show dialog window // ShowWindow(m_hWnd, SW_SHOW); while(AfxPumpMessage()); // loop till the QUIT // message comes.