We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

My child dialog won't tab inside??

Robert Morton
on
Medium Priority
790 Views
Last Modified: 2013-12-03
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
Comment
Watch Question

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



Author

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

Author

Commented:

Commented:
dominic01's answer is correct, but he gives the wrong reason.

Windows handles the tabbing and keyboard navigation for your application behind the scenes during the handling of IsDialogMessage().  If you message loop isn't calling IsDialogMessage() for _all_ of the dialogs that are up, keyboard focus navigation is not going to work for all of them.

While you may know that all the messages you're pumping are dialog-related, you need to let windows know, too. The only way to do that is to call IsDialogMessage() so that Windows has a shot at properly handling the messages needed to do keyboard focus navigation.

.B ekiM

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
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.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.