Tabbing not working
Hey guys, I've been having some tabbing issues for a while. I create a dialog resource in MSVC, add a bunch of textboxes, etc. and then use it in my program as the main window. For some reason, hitting tab won't switch between the buttons/edits - although it works fine when I go to Layout->Test, which suggests to me that I'm doing something wrong in code. Can anyone give me an idea as to what's wrong? (i.e. do I need to process a certain message to make it work or something?)
If you are using a modeless dialog, are you calling IsDialogMessage() in your message loop?
MSDN Using Dialogs page gives this sample:
while ( (bRet = GetMessage(&msg, NULL, 0, 0)) != 0 )
if (bRet == -1 )
// handle the error and possibly exit
else if (!IsWindow(hwndDialog) || !IsDialogMessage(hwndDialog, &msg))
Hmm, never heard of it. I'll check it out, thanks!
Ok, I've finally gotten around to looking at the docs. I believe that you're right; my problem probably is the missing IsDialogMessage(), although I haven't had the chance to test it yet (the code's at school). Strange though, I don't recall ever using it before, and I'm almost positive that tabbing used to work on other dialog boxes. Why would Windows need a separate IsDialogMessage() call to do the message-converting anyways? I mean, it might as well be an automatic feature, or the OS could just send the right messages in the first place instead of sending the wrong one and making you convert it... :mad:
>>tabbing used to work on other dialog boxes<<
Probably a modal dialog box where the system manages the message loop and presumably calls IsDialogMessage internally. With modeless dialog boxes you manage your own message loop and are therefore free to include or exclude default dialog box keyboard behaviour at your discretion.
>>Why would Windows need a separate IsDialogMessage() call to do the message-converting anyways?<<
By having a separate function you could give a 'normal' window (ie. one created with CreateWindowEx) similar 'tabbing' and other dialog-type keyboard handling capability. You are also free, as previously mentioned, to use a modeless dialog with or without that aspect of default dialog behaviour.
If you want that kind of keyboard response by default without using IsDialogMessage or a message loop then use a modal dialog box.
Ah, thanks. Makes sense :)