We use this message loop:
while ( GetMessage (&msg, NULL, 0, 0 ) )
{
if (!IsDialogMessage (_hDlg, &msg))
{
TranslateMessage ( &msg );
DispatchMessage ( &msg );
}
}
_hDlg is the main dialog. Do we need to do a IsDialogMessage for each
dialog as well?
Any ideas would be appreciated.
Peter
---
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.463 / Virus Database: 262 - Release Date: 3/18/2003
Peter,
Rather than do it for each dialog, you need to do it for the currently
active dialog.
Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Further to David's comment, you might like to look at MSDN Knowledge base
article Q71450:
HOWTO: Use One IsDialogMessage() Call for Many Modeless Dialogs
--
Quixote
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)
MainApp (dialog based), 5 buttons. Each button launches a modeless dlg.
The modeless dlg contains a series of buttons (like a toolbar) and a tab
control. The tab control hosts several modeless dialogs.
I'm feeling pretty stupid here :( - I've only been doing this for almost 17
years now and I cant even make a basic dialog app work. hmm...
Peter
"Peter Carlson" <pe...@howudodat.com> wrote in message
news:#qfi9eH9...@TK2MSFTNGP11.phx.gbl...
Peter,
While I'm not entirely sure in your situation, I would conclude that
each modeless dialog (when active) ought to be used as the window
handle in the call to IsDialogMessage.
Under MFC this is largely handled by the default behaviour of CDialog
where the PreTranslateMessage handler (eventually) calls
IsDialogMessage.
I have never done a case with as many layers as you report but, assuming
that you are using the Resource Editor in VC++, there are Properties you can
set to make dialogs work better. Under VC++.Net, these are Control Parent (a
Property of a parent dialog for keyboard navigation among child windows) and
Control (a Property of a child dialog to make it work better) (I forget if
they have the same names under VC++ 6.0).
I have been doing this stuff for a while myself, and when I ran into this
problem, it was pretty frustrating. I came up with a solution that works in
my situation. Basically, in the main message loop for the thread I check
each message to see if it is a key message. If so, I try to find the parent
dialog. I find it by using a function _GetAncestor I created (notice the
underscore). This function calls GetAncestor on NT and up and uses
GetParent on ME and lower. I hope this helps. -Shawn
while(::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
BOOL bRet = ::GetMessage(&msg, NULL, 0, 0);
if(bRet == -1 || !bRet)
{
m_bQuit = TRUE;
continue;
}
HWND hWnd = msg.hwnd;
switch(msg.message)
{
//Find the parent dialog if there is one so IsDialogMessage will
work
case WM_CHAR:
case WM_SYSCHAR:
case WM_KEYUP:
case WM_KEYDOWN:
case WM_SYSKEYUP:
case WM_SYSKEYDOWN:
{
HWND hWndParent = _GetAncestor(hWnd, GA_PARENT);
if(hWndParent && hWndParent != HWND_DESKTOP)
hWnd = hWndParent;
}
break;
}
if(!IsDialogMessage(hWnd, &msg))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
}
"Peter Carlson" <pe...@howudodat.com> wrote in message
news:O0B5eTI9...@TK2MSFTNGP12.phx.gbl...