Could someone explain to me how to make it so when the user presses tab, it will switch to the next control?
Posted on 2001-03-25 02:06:00 by HeroInc
i think you must set the WS_TABSTOP style for the control.
Posted on 2001-03-25 07:58:00 by gael
*IF* you are using a dialog based window, yes, just set WS_TABSTOP. However, if you have a 'real' window based window (ie, you CreateWindow the window and all the controls), well... trouble. There is NO intrinsic tab method, you have to write this code out yourself. Dang. ----------------------- "Son, when you participate in sporting events, itís not whether you win or lose: itís how drunk you get."
Posted on 2001-03-25 09:04:00 by Ernie
Maybe an idea is to catch the WM_KEYDOWN message in the message loop of the program (GetMessage/DispatchMessage etc.), then see if the TAB key is pressed:

invoke GetMessage, .........
push eax
    mov eax, msg.wParam
   .IF ax==VK_TAB
     ;switch to next window
pop eax
..normal msg loop code...
Then keep an array (in taborder) of window handles and give the next window the focus in the array on the VK_TAB message. Thomas
Posted on 2001-03-25 09:54:00 by Thomas
I am using a dialog, and i have wm_tabstop set on the controls i want to be able to switch through, but it doesnt work. Thats what kinda got me confused.
Posted on 2001-03-25 11:08:00 by HeroInc
Tab controls are set up in your resource file - if you are using .res files (as I do) - there should be a menu option or something like that in the rsrc building prog. The actual order and grouping of tab items is all set up from there. It is NOT controlled through the code itself (well it could be but what a waste of time) James
Posted on 2001-03-25 20:52:00 by James
Not to disagree with Ernie, BUT... I have written several applications using a regular window and use the tab key to navigate between edits, comboboxes, buttons, etc. The best part is windows provides this for free ! I don't write special handlers at all. The secret ? Same as for a dialog. Set the control style as WS_TABSTOP and even if you don't have a dialog, use IsDialogMessage in the messsage loop. Try it, it works for me.
Posted on 2001-03-25 21:56:00 by anon
Ok, i have the WS_TABSTOP's in my resource file in the right place. And it still doesnt work. Is there something else i have to do?
Posted on 2001-03-25 22:22:00 by HeroInc
Hero, I think we would be best able to help if you post your .rc file here. poate it into a message, and I'll have a look - I have lots of nice windows tools which make this a doddle (and they ought to for $1,500) !!!! umbongo
Posted on 2001-03-26 09:27:00 by umbongo
///////////////////////////////////////////////////////////////////////////// // // Dialog // IDD_MAIN DIALOGEX 0, 0, 133, 95 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW CAPTION "RGB Mixer" FONT 8, "MS Sans Serif" BEGIN CONTROL "Slider1",IDC_SLIDER_RED,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,11,15,88,12 CONTROL "Slider1",IDC_SLIDER_GREEN,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,11,28,88,12 CONTROL "Slider1",IDC_SLIDER_BLUE,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,11,41,88,12 CTEXT "255",IDC_STATIC_RED,111,15,19,10,SS_SUNKEN CTEXT "255",IDC_STATIC_GREEN,111,28,19,10,SS_SUNKEN CTEXT "255",IDC_STATIC_BLUE,111,42,19,10,SS_SUNKEN CTEXT "000000",IDC_HEX,3,3,127,9,SS_SUNKEN LTEXT "",IDC_COLOR,3,56,127,36,SS_SUNKEN PUSHBUTTON "",IDC_RIGHT,101,15,6,38,0,WS_EX_STATICEDGE PUSHBUTTON "",IDC_LEFT,3,15,6,38,0,WS_EX_STATICEDGE END
Posted on 2001-03-26 14:01:00 by HeroInc
After setting WS_TABSTOP on the controls you want to step through: 1) If you are using a dialog resource, you need to open the dialog with a dialog box function. You need to replace the WndProc with a DialogProc. Although similar, there are important differences between the two kinds of Proc's. DialogBoxParam -- modal, provides tab stops w/o message loop CreateDialogParam -- modeless, requires calling IsDialogMessage in a message loop (see below) 2) If you are creating a normal window with CreateWindowEx and a normal WndProc, you only need to call IsDialogMessage:

    invoke GetMessage, addr msg, NULL, 0, 0
    test   eax,eax
    jz     quitloop

    ; check for keyboard shortcuts (dialog navigation and accelerators)
    ; hctlWindow (or whatever you call it) is the window that
    ;    contains the controls you want to step through with TAB
    invoke IsDialogMessage, hctlWindow, addr msg
    test   eax,eax
    jnz    msgloop      ; success! skip normal dispatch

    invoke TranslateMessage, addr msg
    invoke DispatchMessage, addr msg
    jmp    msgloop
This message was edited by tank, on 3/26/2001 4:07:25 PM
Posted on 2001-03-26 15:05:00 by tank