Article View: borland.public.cppbuilder.nativeapi
Article #11048Re: How to make a window modal
From: Martin Golm
Date: Mon, 01 Mar 2004 13:01
Date: Mon, 01 Mar 2004 13:01
40 lines
2165 bytes
2165 bytes
"Remy Lebeau (TeamB)" wrote:
> Assuming ShowModal() is the one that actually receives the WM_QUIT message,
> yes. However, if your tWindow were running in the context of another
> message queue, including the main message queue, the WM_QUIT would have the
> potential of either aborting the program altogether, or being lost
> altogether.
Interesting. Though WM_QUIT was never lost during my testing, if there's
the potential...
Would the following code be better than a GetMessage() loop, then:
void tDialog :: ShowModal()
{
EnableWindow(parent->GetHandle(), FALSE);
ShowWindow(hWnd, SW_SHOWNORMAL);
MSG msg;
do
{
if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
} while (!mAborted);
ShowWindow(hWnd, SW_HIDE);
EnableWindow(parent->GetHandle(), TRUE);
}
LRESULT tDialog :: WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam)
{
if (iMessage == WM_DESTROY)
{
mAborted = true;
return 0;
}
return tWindow::WndProc(iMessage, wParam, lParam);
}
Thanks,
Martin
Technical Details
Message-ID:
<40433434.6993BD49@gmx.de>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4036276C.5E202C7F@gmx.de> <40366739@newsgroups.borland.com> <403746C4.E97F73E6@gmx.de> <40382b87$1@newsgroups.borland.com> <403A22A2.8277EB3C@gmx.de> <403a48d5@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,214f35d58464ad5 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-03-01 05:09:49 PST Message-ID: <40433434.6993BD49@gmx.de> Date: Mon, 01 Mar 2004 14:01:40 +0100 From: Martin Golm <golm@gmx.de> X-Mailer: Mozilla 4.72 [en] (Win95; I) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: How to make a window modal References: <4036276C.5E202C7F@gmx.de> <40366739@newsgroups.borland.com> <403746C4.E97F73E6@gmx.de> <40382b87$1@newsgroups.borland.com> <403A22A2.8277EB3C@gmx.de> <403a48d5@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 62.153.11.171 X-Trace: newsgroups.borland.com 1078146129 62.153.11.171 (1 Mar 2004 05:02:09 -0800) Lines: 41 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail