Modeless Dialog Boxes
Spencer Jones -- Spencer@azure.com Thursday, September 05, 1996 Environment: VC++ 4.1 and Windows NT 3.51 Is it possible to open a modeless dialog box and then minimize the DOC / VIEW framework and leave the modeless (or possible many modeless) dialog box open. I want the framework to be visible as an icon, I.E. I do not want to make it invisible and leave the modeless dialog box to display processing I actually want the main framework to appear as an icon and the user still able to work on the modeless dialog boxes. -- Spencer Jones ( http://www.azure.com/~spencer/) Chief Software Developer Azure Limited
Roger Onslow -- Roger_Onslow@compsys.com.au Friday, September 06, 1996 [Mini-digest: 5 responses] Spencer, >Is it possible to open a modeless dialog box and then minimize the DOC / >VIEW framework and leave the modeless (or possible many modeless) dialog >box open. I want the framework to be visible as an icon, I.E. I do not >want to make it invisible and leave the modeless dialog box to display >processing I actually want the main framework to appear as an icon and >the user still able to work on the modeless dialog boxes. Not sure, but you could try making the parent of the Desktop window the parent of the modeless dialog(s) when you create it/them. I thinkg, then, that when you minimize your app, it wond affect the dialogs (because they are not children of your app's main window). Roger Onslow -----From: Fabio FerracchiatiHave you tried to use the ShowWindow method with the SW_MINIMIZE = attribute? Bye. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^= ^^^^^^^^^ ^ Fabio Ferracchiati Windows Developer = ^ ^ Infobyte S.p.A (Italy) = ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^= ^^^^^^^^^ -----From: David Ohlssen David Ohlssen responds: I have had a lot of success doing just that. You need the whole doc/view framework if you plan to do print preview etc. It also makes your app much more solid and capable. Simply create the dlg and then hide the main window. You must do this after the ProcessShellCommand line. You get a taskbar entry or icon depending on the OS version. I normally use a prop sheet as the main app window for a certain type of app. Then it is easy to see different aspects of the app by tabbing to property pages. You have to be careful about where your data is stored and how you close the app. The best way to close is with a button which closes the main frame window. How? ((CMyApp *)AfxGetApp())->m_pMainWnd->DestroyWindow(); The above will work from anywhere and does a really thorough job of closing down all windows including your modeless dialogs etc. It will stop timers and end the app gracefully. Quite a polite attitude for something with such a ruthless name. You also need to override OnCancel and let it call the same destroy. To use print preview, simply call OnPrintPreview in the (hidden) view class by means of a pointer to view which you can put in the App class and init to "this" from the view. *Any criticisms/queries welcome* -----From: David.Lowndes@bj.co.uk Spencer, You can do this very easily by making your modeless dialog have the desktop as its parent. The following snippet should illustrate how to do it: void CTestApp::OnAboutModeless() { /* Create a modeless version of the about box */ static CAboutDlg * pDlg; if ( pDlg == NULL ) { pDlg = new CAboutDlg; /* Create the dialog */ pDlg->Create( IDD_ABOUTBOX, CWnd::FromHandle( GetDesktopWindow() ) ); } else { /* Destroy the dialog */ pDlg->DestroyWindow(); delete pDlg; pDlg = NULL; } } Dave Lowndes -----From: PP mail system G'day! Please find following some bits I've drug out of a working application & grafted onto a temp workspace called Fred. I leave the cleaning up to you, cos it's ugly as it stands. I just made it work with minimum effort. Doubtless there are cleaner approaches -- you may wish to try grafting it on to the App rather than the Mainframe. Regards, Jim LW P.S. If it looks funny that's because this eMail system is limited to 72 col.s, so I've done the line-wrap by hand. BOOL CMainFrame::OnCreateClient (LPCREATESTRUCT lpcs, CCreateContext* pContext) { // TODO: Add your specialized code here // and/or call the base class m_pFredModeless = new CFredModeless(this); ASSERT_VALID(m_pFredModeless); CWnd* pFredModelessWnd = (CWnd*) m_pFredModeless; if (pFredModelessWnd->GetSafeHwnd() == NULL) { delete m_pFredModeless; AfxMessageBox("Failed to create modeless Dialog"); return FALSE; } m_pFredModeless->Display(); return CMDIFrameWnd::OnCreateClient(lpcs, pContext); } void CMainFrame::OnDestroy() { CMDIFrameWnd::OnDestroy(); // TODO: Add your message handler code here delete m_pFredModeless; //^^^^causes warning below!!! Do you care??? } CFredModeless::CFredModeless(CWnd* pParent /*=NULL*/) : CDialog(CFredModeless::IDD, pParent) { //{{AFX_DATA_INIT(CFredModeless) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT Create(); } BOOL CFredModeless::Create() { return CDialog::Create(CFredModeless::IDD); } void CFredModeless::OnCancel() { // TODO: Add extra cleanup here CDialog::OnCancel();//this will hide it, not destroy it } void CFredModeless::OnOK() { // TODO: Add extra validation here //CDialog::OnOK();<=== Do this & it hides! } void CFredModeless::Display() { //How you get here after the 1st display is your business! ShowWindow(SW_SHOW); } >From the DEBUG window: Warning: calling DestroyWindow in CDialog::~CDialog -- OnDestroy or PostNcDestroy in derived class will not be called.
Joseph M. Koral -- jkoral@tiac.net Friday, September 06, 1996 ------ =_NextPart_000_01BB9BF1.E24DE540 Content-Type: text/plain; charset="us-ascii"
pjn -- pjn@indigo.ie Saturday, September 07, 1996 On Thu, 5 Sep 1996 14:56:28 +0100, you wrote: >Environment: VC++ 4.1 and Windows NT 3.51 > >Is it possible to open a modeless dialog box and then minimize the DOC / >VIEW framework and leave the modeless (or possible many modeless) dialog >box open. I want the framework to be visible as an icon, I.E. I do not >want to make it invisible and leave the modeless dialog box to display >processing I actually want the main framework to appear as an icon and >the user still able to work on the modeless dialog boxes. > > You need to make sure that the parent of the modeless dialog is not the mainframe off your window. That way it will not minimize when the main window is iconized to the taskbar. ''' @ @ +========================ooO-(_)-Ooo=================================+ | PJ Naughter | | | | Software Developer Email: pjn@indigo.ie | | Softech Telecom Tel: +353-1-2958384 | | Fax: +353-1-2956290 | | Author of DTime - A Collection URL: http://indigo.ie/~pjn | | of Date & Time classes for MFC | | | | Addr: 7 Woodford, Brewery Road, Stillorgan, | | Blackrock, Co. Dublin, Republic of Ireland | +====================================================================+
Lawrence_Chan@pcmailgw.ml.com Monday, September 09, 1996 I am wondering this will make your applicaton contain two icons when you do ALT-TAB? ______________________________ Reply Separator _________________________________ You need to make sure that the parent of the modeless dialog is not the mainframe off your window. That way it will not minimize when the main window is iconized to the taskbar. ''' @ @ +========================ooO-(_)-Ooo=================================+ | PJ Naughter | | | | Software Developer Email: pjn@indigo.ie | | Softech Telecom Tel: +353-1-2958384 | | Fax: +353-1-2956290 | | Author of DTime - A Collection URL: http://indigo.ie/~pjn | | of Date & Time classes for MFC | | | | Addr: 7 Woodford, Brewery Road, Stillorgan, | | Blackrock, Co. Dublin, Republic of Ireland | +====================================================================+
| Вернуться в корень Архива |