tab key, Win32, input focus and modeless dialog

tab key, Win32, input focus and modeless dialog

Post by Saurab » Sat, 03 Jul 2004 19:00:18

Hello All,

I have this combination where I set a win32 app window as a parent of my
dotnet form. As this form is a modeless form shown in the win32 app, the tab
key did not work. I made it work by adding a windows hook and checking for
the dialog message. Now the tab key vaguely works.

The form has a tabcontrol which has some tab pages having controls on it.
There are a couple of buttons like 'ok' and 'cancel' which are outside this
tab control. As far as the form is concerned, it has 3 children, one tab
control and 2 buttons saying ok and cancel. Now when I press the tab key I
can move the input focus between these 3 controls but the input focus does
not go inside the tab page. If I click on one of the controls within the
page to give the input focus to it, I can now use the tab key to navigate
between these controls but as soon as the focus comes to the tabpage header,
I cannot navigate back inside. Also if I press shift + tab from any control
within the page, the focus is transferred to one of the buttons.

Can anybody throw some light on this. Any help in this regard will be highly



1. Modeless Dialog Boxes - Knowing when it terminates, Terminate without using delete Dlg and Getting input Focus

2. Child Modeless Dialogs Always Hide Parent Modeless Dialog

My app is dialog based. The main dialog is essentially a web browser. It has
menu items that open other modeless dialogs. (One shows the page source, one
shows the current search path set.) The problem that I am having is that the
child dialogs (source and paths view) always hide the parent. They do not
hide each other. (i.e. the active one always comes to the top of the display

The main dialog is run modeless (using Create), and has its parent window
pointer set to NULL.

I can activate the main dialog, but it remains hidden behind the others if
they are on the screen. What I want is to be able to activate any of the
three windows and have it displayed in front of the others.

I have tried the following:
1) Setting m_pMainWnd to NULL in the app's InitInstance method. This just
causes the app to close immediately after it starts.

2) Runing the main dialog using DoModal, rather than Create. This changed
nothing. (The modeless child dialogs were created and could be activated.
Somehow, I thought this wouldn't work if their parent was a modal dialog. It
seems to violate the "modal-ness" of the parent. That's why I made the main
dialog be modeless to begin with.)

3) Having the child dialogs pass a NULL pParent pointer to the CDialog
constructor. This changed nothing.

I have also edited the resource file using the text editor and made sure
that the dialogs are created with the same styles. This changed nothing.

How can this be done? I have considered making an invisible modeless dialog
that is the main window for the app, then running all of mine as children of
that one, but it seems like a rather roundabout approach. Is there something
simple that I have missed?


3. Tabbing in modeless dialog that is a child of a modal dialog

4. WebBrowser lost Key input focus after close Find dialog

5. Dialog, tab key and focus rect problem

6. Key focus stays on toolbar when input focus is shifted

7. MDI app: Can't get window focus of modeless child dialog window

8. Cannot Set Focus to Modeless Dialog w/ DesktopParent

9. focus on modeless dialog

10. Trap CTRL+TAB when tab dialog control does not have focus

11. a top-most modeless dialog that i create grabs focus, how to avoid?

12. modeless dialog focus problem

13. [wxMac] Cant set the focus on wxComboBox child of a modeless dialog