15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Modeless dialog box only inerface application

Ken Litwak @actionware.com -- klitwak@actionware.com
Tuesday, March 18, 1997

Environment:  VC 1.52, Windows 3.1

   I've scoured the books I have, the MS KB and "Net resources I can
find to find an example of a modeless dialgo box as the only UI for an
application.  I'm trying to adapt the Cancel dialog from MSJ to do this
but it fails in CDialog::Create.  I presume this is because it doesn't
have a parent window handle, though if I try to do a quick watch on the
template name, that seems to be a problem too.  ANyway, can anyone point
me to a sample for how to do this in VC 1.52?  Or perhaps you could
provide a code snippet of how to do it?  Thanks.


Ken Litwak
klitwak@actionware.com



Mike Blaszczak -- mikeblas@nwlink.com
Friday, March 21, 1997

[Mini-digest: 4 responses]

At 17:07 3/18/97 -0800, Ken Litwak wrote:
>Environment:  VC 1.52, Windows 3.1
>
>   I've scoured the books I have, the MS KB and "Net resources I can
>find to find an example of a modeless dialgo box as the only UI for an
>application.  I'm trying to adapt the Cancel dialog from MSJ to do this
>but it fails in CDialog::Create.  I presume this is because it doesn't
>have a parent window handle, though if I try to do a quick watch on the
>template name, that seems to be a problem too.  ANyway, can anyone point
>me to a sample for how to do this in VC 1.52?  Or perhaps you could
>provide a code snippet of how to do it?  Thanks.

I'm not really sure I understand your question.

A modal dialog box is a dialog box that disables all of its ancestor
windows while it is active.  So, if the main frame window puts up a modal
dialog box, the main frame window is disabled until the dialog box goes away.
The dialog remains active, of course, until the user closes it.

A modeless dialog box is a dialog box that _doesn't_ disable its ancestor
windows while it is active. If a main frame window puts up a modeless
dialog, the dialog is active and usable but the main frame window is
active and usable, too.

But if you take away the main frame window and leave the dialog box as the
only interface the application has, it turns out that there's really nothing
happening.  That is, you can't expect the dialog to disable its parent
windows because it has none.  Since the scope of modality is limited to
the application (normally), there's no point in considering modality if
the dialog is the only user interface the application provides.

For such an application, there's no need to call Create(), then, on the
dialog box in question.  Just call DoModal().


.B ekiM
http://www.nwlink.com/~mikeblas/
These words are my own. I do not speak on behalf of Microsoft.
       One is too many and a million is not enough.
-----From: Paul Gerhart 

Ken Litwak wrote:
> 
> Environment:  VC 1.52, Windows 3.1
> 
>    I've scoured the books I have, the MS KB and "Net resources I can
> find to find an example of a modeless dialgo box as the only UI for an
> application. 


I would think this would be easy to do. Have you ever seen some source
for an app that has a splash screen before the mainframe becomes
visible? The Brain/Lovette book has an example for a 1.52 or 2
environment where the splash screen is derived from CDialog.

That is, initially launch the mainfram with SW_HIDE style and spawn a
modeless dialog; unlike the classic splash screen case, you always keep
the mainframe hidden and the splash screen visible.

HTH

-- 
#########################
# Paul Gerhart          #
# pgerhart@voicenet.com #
#########################
-----From: Ben Burnett 

Ok, I dont know if i.m telling you what you have already tried but here
goes:

Using the appwizard make a new projects and remove the view and doc
stuff if you dont need it, now in the (project name).cpp change it so
that instead of displaing a new view+doc when it starts, it dispalys a
dialog box modal/or non-modal. Like so:

in -> BOOL CMyApp::InitInstance()

remove: ( this junk )

	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(
		IDR_NONAMETYPE,
		RUNTIME_CLASS(CMyDoc),
		RUNTIME_CLASS(CMyFrame), // custom MDI child frame
		RUNTIME_CLASS(CMyView));
	AddDocTemplate(pDocTemplate);

	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;
	m_pMainWnd = pMainFrame;

add:

	CMyDialog dlg;
	dlg.DoModal(); // or create ( which ever you wish to use )

hope this help a little.
-----From: Jim Lawson Williams 

At 17:07 18-03-97 -0800, you wrote:
>Environment:  VC 1.52, Windows 3.1
>
>   I've scoured the books I have, the MS KB and "Net resources I can
>find to find an example of a modeless dialgo box as the only UI for an
>application.  I'm trying to adapt the Cancel dialog from MSJ to do this
>but it fails in CDialog::Create.  I presume this is because it doesn't
>have a parent window handle, though if I try to do a quick watch on the
>template name, that seems to be a problem too.  ANyway, can anyone point
>me to a sample for how to do this in VC 1.52?  Or perhaps you could
>provide a code snippet of how to do it?  Thanks.
>
>
>Ken Litwak
>klitwak@actionware.com
>
G'day!
The "modeless" is irrelevant.  My ancient Kruglinski (1993, ISBN 
1-55615-511-5) provides an example as EX22B.

Regards,
Jim LW


>From the BBC's "Barchester Chronicles":

    "I know that ultimately we are not supposed to understand.
    But I also know that we must try."

       -- the Reverend Septimus Harding, 
          crypt-analyst, art-critic, tax-consultant, C++ programmer



DFPav@aol.com
Monday, March 24, 1997

Ken:
Why does it have to be modeless?  If it is the only interface, why can't it
be modal?
Then all you do is call your CMyDialog::DoModal() from
CMyWinApp::InitInstance.
Dan



Mihir Dalal -- m_dalal@ECE.concordia.CA
Wednesday, March 26, 1997



On Mon, 24 Mar 1997 DFPav@aol.com wrote:

> Ken:
> Why does it have to be modeless?  If it is the only interface, why can't it
> be modal?
> Then all you do is call your CMyDialog::DoModal() from
> CMyWinApp::InitInstance.
> Dan

I think, I know what has prompted the original poster of this thread, to 
think of having a modeless dialog interface. 

The answer is very simple and obvious. 

The very thought of a modal dialog box brings into any windows user's 
mind, that it will prevent him from working behind the box, unless he 
kills it. 

This is true, for all modal dialogs, that popup from a windows 
application that has a parent main frame. What the original poster has 
overlooked is that when the dialog is the only interface without a parent 
main frame for his application, as Mike said, it is silly to think of its 
modality. 

A modal dialog does not prevent you from working on another application 
which is open on the windows desktop, simultaneously. It only prevents 
access to its parent main frame. 

This fact has been overlooked by the original poster, & in the hope to 
find an answer for a dialog which will not block the desktop area, he/she 
has thought of using a modeless dialog as an interface, but he/she only 
needs to be told that whatever he/she is trying to do with his modeless 
dialog interface, is in any case gonna work with a modal dialog interace 
too.  

Mihir. 
 _________________________________________________________________________
     Mihir Dalal , M.Engg. (Electrical) Student
              Department of Electrical and Computer Engineering
                   Concordia University, Montreal, Canada
                http://www.ECE.Concordia.CA/~m_dalal/addr.html





Become an MFC-L member | Вернуться в корень Архива |