Win32 Dialog Boxes and Tab/Tab Stop

This topic is 4933 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I am making a program for a friend to help him calculate sell prices and such for an online game. It has alot of edit/combo box's to enter stuff so obviously it would be easiest to just hit tab to switch around(Like most programs do). Im using dialog boxes/MSVC++ to make this program, but the problem is that I usualy dont make windows apps and im more of a game programmer. I have read the forums and looked at more sites on google than I can count. Heres the deal: Ive set up the tab order and such with Layout->Tab Order, and when I hit Layout->Test it works perfect. But when I compile and run the program it just plays the little error sound and doesnt switch to the next edit box. Does anyone know how I could fix this? Please ask if you need anymore information.

Share on other sites
I'm not sure if this will fix your problem as I've never used dialog resources before (which is what it sound like you are using) and I'm not sure if my app made the error sound(I turn off windows sounds), but changing my message loop to the following enabled tab stop functionality:
while(GetMessage(&mMsg,0,0,0)){	if(!IsDialogMessage(hWnd, &mMsg))	{		TranslateMessage(&mMsg);		DispatchMessage(&mMsg);	}}
The change was adding "if(!IsDialogMessage(hWnd, &mMsg))" around the translate and dispatch calls. Without that, tab didn't do anything that I noticed in my program.

Share on other sites
Quote:
 Original post by EponickI am making a program for a friend to help him calculate sell prices and such for an online game. It has alot of edit/combo box's to enter stuff so obviously it would be easiest to just hit tab to switch around(Like most programs do).Im using dialog boxes/MSVC++ to make this program, but the problem is that I usualy dont make windows apps and im more of a game programmer. I have read the forums and looked at more sites on google than I can count. Heres the deal:Ive set up the tab order and such with Layout->Tab Order, and when I hit Layout->Test it works perfect. But when I compile and run the program it just plays the little error sound and doesnt switch to the next edit box.Does anyone know how I could fix this?Please ask if you need anymore information.

[EDIT] -- Actually, Extrarius' advice is better/easier. Use it :)

---

The problem is that a tab character is an "illegal character" in a single-line Edit Control. You'll have to "subclass" (as in MS Window subclassing) the Edit Control and substitute a new WndProc for it that handles the WM_CHAR... but that's only half the problem.

The WM_CHAR message would normally go to the parent window (the dialog) so you'd have to either intercept the WM_CHAR message for each control in the DlgProc, or just forward the WM_CHAR message back to the edit control itself (after subclassing it).

While processing the VK_TAB virtual key code, you may as well process VK_RETURN too, and make it send the parent window a WM_COMMAND/IDOK message.

Share on other sites
Quote:
 Original post by ExtrariusI'm not sure if this will fix your problem as I've never used dialog resources before (which is what it sound like you are using) and I'm not sure if my app made the error sound(I turn off windows sounds), but changing my message loop to the following enabled tab stop functionality:*** Source Snippet Removed ***The change was adding "if(!IsDialogMessage(hWnd, &mMsg))" around the translate and dispatch calls. Without that, tab didn't do anything that I noticed in my program.

Thanks :)
Worked like a charm.