Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

IsDialogMessage - Tab Key not working

753 views
Skip to first unread message

Peter Carlson

unread,
Mar 27, 2003, 2:17:41 AM3/27/03
to
We have a dlg based app that has 5 or so "launch" buttons. Each button
launches a popup window which is just another dialog (modeless). Clicking
in that dialog and then hitting tab produces a beep. Doesn't move the
cursor from edit field to edit field. The dialog is set "control
parent=true".

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


David Lowndes

unread,
Mar 27, 2003, 3:52:01 AM3/27/03
to
>_hDlg is the main dialog. Do we need to do a IsDialogMessage for each
>dialog as well?

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

Quixote

unread,
Mar 27, 2003, 8:04:41 AM3/27/03
to

"Peter Carlson" <pe...@howudodat.com> wrote in message
news:#g07#DD9CH...@TK2MSFTNGP12.phx.gbl...

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)

Peter Carlson

unread,
Mar 27, 2003, 10:44:05 AM3/27/03
to
Ok, I've read through those and it seems to make sense, however the
situation now got worse :(. Windows 2-5 actually contain tab controls,
which contain modeless dialog boxes, one for each tab. Potentially you
could have 10+ modeless dialogs on the screen (many invisible becuase of the
tabnot being active). Does this mean that each child dialog of the child
dialog of the parent will need to be processed through IsDialogMessage()? I
must be missing something here.

Peter Carlson

unread,
Mar 27, 2003, 12:18:19 PM3/27/03
to
And to make matters worse :)
I made appropriate code changes to have one of the end of the line child
dialogs set a hdlgVisible global variable that is processed through
IsDialogMessage(). If I click in an edit field the cursor doesn't move
there automatically. if I click on a check box, it checks, and then I can
tab through the dialog(or clicking on the drop down arrow of a combobox also
works). But clicking in an edit field does nothing. The same thing
actually holds true whether it's the end of the line dialog or the middle
dialog (just added a couple of test boxes onto it).

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...

David Lowndes

unread,
Mar 27, 2003, 2:53:13 PM3/27/03
to
>Ok, I've read through those and it seems to make sense, however the
>situation now got worse :(. Windows 2-5 actually contain tab controls,
>which contain modeless dialog boxes, one for each tab. Potentially you
>could have 10+ modeless dialogs on the screen (many invisible becuase of the
>tabnot being active). Does this mean that each child dialog of the child
>dialog of the parent will need to be processed through IsDialogMessage()?

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.

Quixote

unread,
Mar 29, 2003, 7:02:25 PM3/29/03
to

"Peter Carlson" <pe...@howudodat.com> wrote in message
news:O0B5eTI9...@TK2MSFTNGP12.phx.gbl...

> And to make matters worse :)
> I made appropriate code changes to have one of the end of the line child
> dialogs set a hdlgVisible global variable that is processed through
> IsDialogMessage(). If I click in an edit field the cursor doesn't move
> there automatically. if I click on a check box, it checks, and then I can
> tab through the dialog(or clicking on the drop down arrow of a combobox
also
> works). But clicking in an edit field does nothing. The same thing
> actually holds true whether it's the end of the line dialog or the middle
> dialog (just added a couple of test boxes onto it).
>
> 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
>


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).

Shawn Stevens

unread,
Apr 1, 2003, 11:43:46 PM4/1/03
to
Peter,

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...

0 new messages