Hiding main dialog
Jim Husband -- jimhus@airmail.net Friday, August 09, 1996 Environment: VC++ 4.2, Windows 95 I am trying to get a dialog-based AppWizard generated program to initially hide the main dialog (a task-bar icon is added, and the dialog can be made visible thru clicking the taskbar). Using the approach below, I get a "flicker" of the dialog at program startup. From that point on, everything works fine. I would like to eliminate the initial "flicker." The dialog serves as the message loop for processing the NotifyIcon messages - so I do want the dialog created at program startup, just not displayed. Any suggestions? (BTW, I have also turned off the "visible" checkbox within the resource editor - to no avail.) Thanks in advance. Jim Husband jimhus@airmail.net ~~~~~~~~~ Snippit Starts ~~~~~~~~~~ void CCleanIEDlg::OnPaint() { if (m_IsDlgVisible) ShowWindow(SW_NORMAL); else ShowWindow(SW_HIDE); CDialog::OnPaint(); } Note: m_IsDlgVisible is initialized to FALSE in the contructor. ~~~~~~~~~ Snippit Ends ~~~~~~~~~~
petter.hesselberg -- petter.hesselberg@ac.com Monday, August 12, 1996 [Mini-digest: 3 responses] You may solve your problem by NOT calling CDialog::OnPaint in the "hidden" case. Architecturally speaking, however, calling ShowWindow from within a Paint handler does not strike me as a terribly good idea. Other possibilities include placing the dlg off-screen (disabled). If I were you, I'd trace through all the MFC code related to dlg-box startup; this is sure to be illuminating. Regards, Petter -----From: Brian_Dormer@ftdetrck-ccmail.army.mil What about using SetRedraw(); to disable/enable display updating for the dialog? ______________________________ Reply Separator _________________________________ Subject: Hiding main dialog Author: mfc-l@netcom.com at Internet-Mail Date: 8/12/96 4:15 AM Environment: VC++ 4.2, Windows 95 I am trying to get a dialog-based AppWizard generated program to initially hide the main dialog (a task-bar icon is added, and the dialog can be made visible thru clicking the taskbar). Using the approach below, I get a "flicker" of the dialog at program startup. From that point on, everything works fine. I would like to eliminate the initial "flicker." The dialog serves as the message loop for processing the NotifyIcon messages - so I do want the dialog created at program startup, just not displayed. Any suggestions? (BTW, I have also turned off the "visible" checkbox within the resource editor - to no avail.) Thanks in advance. Jim Husband jimhus@airmail.net ~~~~~~~~ Snippit Starts ~~~~~~~~~~ void CCleanIEDlg::OnPaint() { if (m_IsDlgVisible) ShowWindow(SW_NORMAL); else ShowWindow(SW_HIDE); CDialog::OnPaint(); } Note: m_IsDlgVisible is initialized to FALSE in the contructor. ~~~~~~~~ Snippit Ends ~~~~~~~~~~ -----From: PP mail systemHi Jim! Try substituting "return" for "ShowWindow(SW HIDE)". Regards, Jim LW
Portalski Nick -- N.Portalski@datasci.co.uk Wednesday, August 14, 1996 [Mini-digest: 4 responses] Try putting the following in OnCreate(------) { // Usual OnCreate stuff .... int screen_width = ::GetSystemMetrics(SM_CXSCREEN); CRect my_rect; GetWindowRec(&my_rect); SetWindowPos(&wndTop, screen_width + my_rect.Width() + 10, 0, 0, 0, SWP_NOSIZE); return 0; } This will create the dialog off screen, so you won't get that initial flicker when it's created. When you need it simply move it back on screen. (If you don't want to leave it off screen then simpy hide it after it's been created) -- Nick >Environment: VC++ 4.2, Windows 95 > I am trying to get a dialog-based AppWizard generated program to initially >hide the main dialog (a task-bar icon is added, and the dialog can be made >visible thru clicking the taskbar). Using the approach below, I get a >"flicker" of the dialog at program startup. From that point on, everything >works fine. I would like to eliminate the initial "flicker." -----From: Jim Husband[Moderator's note: This is a summary of answers to the question, including what Jim ended up doing.] Environment: VC++ 4.2, Windows 95 Although I'm not absolutely satisfied - I have a functioning work-around. Before I forget everything - thought I would summarize the various responses (and thank everyone for the help). Almost every suggestion made good sense on why it should resolve the flicker - but only one did. Hopefully this synopsis is worth something. Initial message: I am trying to get a dialog-based AppWizard generated program to initially hide the main dialog (a task-bar icon is added, and the dialog can be made visible thru clicking the taskbar). Using the approach below, I get a "flicker" of the dialog at program startup. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Response: Why do you do it in OnPaint(), may be try the same in OnInitDialog()? Regards. Arie Goberman Jerusalem Outcome: No difference whether it was done in OnPaint or InitDialog - flicker remains. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Response: Did you set the dialog to be not visible in the resource editor? David Elliott -- dce@netcom.com - Moderator MFC-L Outcome: I hadn't - but this also did not remove the flicker. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Response: Try substituting "return" for "ShowWindow(SW HIDE)". Regards, Jim LW Outcome: Nice try - no affect (flicker remains). ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Response: You may solve your problem by NOT calling CDialog::OnPaint in the "hidden" case. Architecturally speaking, however, calling ShowWindow from within a Paint handler does not strike me as a terribly good idea. Other possibilities include placing the dlg off-screen (disabled). If I were you, I'd trace through all the MFC code related to dlg-box startup; this is sure to be illuminating. Regards, Petter Outcome: Several good points - however NOT calling OnPaint() did not get rid of the flicker (I still don't know why it flickers - but it *really* shouldn't if OnPaint() isn't being called... right?) Tracing thru MFC (or any Windows code) is somewhat difficult (useless?) when trying to determine why / when a paint is happening (since the debug environment forces additional repaints on each "step" thru the code. Placing the dialog off screen in OnInitDialog() is what I finally ended up using - but this just feels sloppy (although it looks great). It may well end up being a style setting (3D look, or Centered, ...) somehow forces an initial paint of the dialog. I may go back and try to resolve it - but it's dead for awhile. Thanks again for the help. Jim Husband -----From: "Dmitry Davidovich" Doesn't a simpler way to open main dialog minimized ? ----- +++++++++++++++++++++++++++++++++++++++++ Dmitry Davidovich CS Tel Aviv University dmitry@enigma.co.il ddmitry@libra.math.tau.ac.il +++++++++++++++++++++++++++++++++++++++++ -----From: pjn@indigo.ie (pjn) I to had the exact problem. I could not resolve it after having spent 2 days playing with it. The solution I finally arrived at was the use a standard CMainFrame derived class as the main application window, using m_nCmdShow = SW_HIDE and let it respond to the NotifyIcon messages. ''' @ @ +========================ooO-(_)-Ooo=================================+ | PJ Naughter | | Software Developer email: pjn@indigo.ie | | Softech Telecom Tel: +353-1-2958384 | | Fax: +353-1-2956290 | | | | | | Addr: 7 Woodford, Brewery Road, Blackrock, | | Co. Dublin, Republic of Ireland | +====================================================================+
| Вернуться в корень Архива |