Link to home
Start Free TrialLog in
Avatar of Robert Morton
Robert Morton

asked on

My child dialog won't tab inside??

I've created a modal dialog box which contains a tab control and in the tab control display area, I'm displaying a child modeless dialog box (depending apon which tab is selected). When I try to tab from field to field in the modeless dialog box, I simply end up tabbing back to controls on the parent
dialog box. I want to be able to tab from field to field in the child dialog box.

I tried adding the DS_CONTROL style to the child modeless dialog boxes but now when I click on a field in the child, my system hangs and requires cold reboot. If you can help me, I would really appreciate it.

Here's the styles I'm using for the parent dialog box which contains the tab control:
STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_CAPTION |
    WS_SYSMENU
EXSTYLE WS_EX_CONTEXTHELP

Here's the styles I'm using (trying to) for the children
STYLE WS_CHILD | DS_CONTROL

All the edit fields in my child dialog boxes have the WS_TABSTOP set and the first edit field in each child has the WS_GROUP also. However, with the DS_CONTROL style the system hangs (as mentioned above).

BTW- When I create the modeless children using CreateDialog, I specify the parent hwnd as the tab control hwnd if that makes any diff. Also, I'm creating all the children at once and then making them visible later when their tab is selected.

Thanks for any help you can offer!
-Rob Morton
Avatar of dominic01
dominic01

The problem with modeless dialog box is the messages are not passed from the parent to the dialog box.

What you have to do is to test if the message is for a dialog box anf if yes then send it. This can be done by inserting something like this in your message loop:


    while ( GetMessage(&msg, NULL, 0, 0) ) {

      /* Translates virtual key codes */
      
//****** Here is what you are looking for *******************
if(msg.hwnd && IsDialogMessage(msg.hwnd, &msg))  continue;
//***********************************************************
      TranslateMessage(&msg);
      
      /* Dispatches message to window */
      DispatchMessage(&msg);
    }

Let me know if it worked.

DOM



Avatar of Robert Morton

ASKER

Since my modal dialog box is the parent of all my modeless dialog boxes, ALL messages are coming to its DialogProc and not WndProc. Therefore there's no reason to try to determine whether each message is dialog related since they ALL will be. Since I'm not trying to change the behavior of tabbing from control to control on my modeless dialog boxes or even the parent modal one, I'm not trapping for this message and I'm returning FALSE in my modal parent and modeless children DialogProcs. Therefore, whether the message comes to the parent or the child, Windows still receives a FALSE return value in hopes that Windows will tab correctly.
ASKER CERTIFIED SOLUTION
Avatar of mikeblas
mikeblas

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for taking the time to answer my question. I would have deleted it but ex-xchange lacks that feature. My assignment of the tab control hwnd to be the parent for the child modeless dialog boxes was causing the prob. After reassigning all the child modeless dialog boxes to the hwnd of the modal dialog box, my tabbing problem dissapeared.