flat assembler
Message board for the users of flat assembler.

Index > Windows > WS_TABSTOP not working in TabCtrl

Author
Thread Post new topic Reply to topic
kasake36



Joined: 28 Mar 2006
Posts: 68
kasake36
Alas, alas! I have created a TabCtrl with Dialogs (WS_CHILD) in it. Some items in the dialog have the WS_TABSTOP option set, but they won't get focused, when the tab-key is pressed. I've tried to catch the WM_KEYDOWN message in all dialogs including the main-dialog with the TabCtrl to track down where they get posted to, but no success.

I assume i have to use the SetWindowLong-function, but had no luck yet either. What do i have to consider in such a case (TabCtrl Dialog with dialogs) to get the WS_TABSTOP-thing to work? Thank you.
Post 05 May 2006, 09:12
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1608
Location: Ukraine
shoorick
it seems child dialogs do not have WS_TABSTOP set, thus do not ever focused by tab-key. controls on them are child of the child. never tried such combination, just can suggest to subclass tab control, and catch, if tab there pressed - set focus to current child dialog (or it current item)
Post 05 May 2006, 10:53
View user's profile Send private message Visit poster's website Reply with quote
kasake36



Joined: 28 Mar 2006
Posts: 68
kasake36
Hm. That's a mess. I can't catch the tab (09h) either. I believe i have screwed up my windows procedure a bit and am telling windows that i've handled all the messages.
Post 05 May 2006, 11:08
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1608
Location: Ukraine
shoorick
post your source
Post 05 May 2006, 11:09
View user's profile Send private message Visit poster's website Reply with quote
kasake36



Joined: 28 Mar 2006
Posts: 68
kasake36
This is the source for the Main-Proc. I believe the error must be "spawned" somewhere in this part. I've translated the main-comments into english. Thank you for the help!
Code:
proc MainDialogProc hwnddlg,msg,wparam,lparam
        push    ebx esi edi
        cmp     [msg],WM_INITDIALOG
        je      wminitdialog
        cmp     [msg],WM_COMMAND
        je      wmcommand
        cmp     [msg],WM_KEYDOWN
        je      wmkeydown
        cmp     [msg],WM_NOTIFY
        je      wmnotify
        cmp     [msg],WM_CLOSE
        je      wmclose
        xor     eax,eax
        jmp     finish
    wminitdialog:
        ; ----------------------------------------------------------------------
        ; -- Connect to db
        cinvoke sqliteOpen,dbnam,dbpont
        cmp     eax,SQLITE_OK
        jne     schwedb
        ; ----------------------------------------------------------------------
        ; -- Create Statusbar
        invoke  CreateWindowEx,0,cStaB,\
                NULL,WS_CHILD +\ 
                WS_VISIBLE,\
                0,0,0,0,[hwnddlg],\
                NULL,[hInst],NULL
        mov     [hStaB],eax
        invoke  SendMessage,[hStaB],\
                SB_SETPARTS,2,stapa
        ; ----------------------------------------------------------------------
        ; -- Create TabControl
        invoke  CreateWindowEx,0,cTab,\
                NULL,WS_CHILD+WS_VISIBLE,\
                2,10,580,410,[hwnddlg],\
                IDC_TAB,[hInst],NULL
        mov     [hTab],eax
        mov     [tci.imask],TCIF_TEXT       ; Erzeugen der Tabs
        mov     [tci.iImage],-1
        mov     [tci.pszText],taba
        invoke  SendMessage,eax,\
                TCM_INSERTITEM,0,tci
        mov     [tci.pszText],tabb
        invoke  SendMessage,[hTab],\
                TCM_INSERTITEM,1,tci
        mov     [tci.pszText],tabc
        invoke  SendMessage,[hTab],\
                TCM_INSERTITEM,2,tci
        mov     [tci.pszText],tabd
        invoke  SendMessage,[hTab],\
                TCM_INSERTITEM,3,tci
        invoke  CreateDialogParam,\         ; Erzeugen der Dialoge in den
                [hInst],IDD_AKA,\           ; Reitern. Der erste Dialog
                [hwnddlg],AkaDlgProc,0      ; (Arbeitskarten) wird nicht
        mov     [hAka],eax                  ; versteckt.
        invoke  ShowWindow,[hAka],SW_SHOW
        invoke  CreateDialogParam,\
                [hInst],IDD_AUF,\
                [hwnddlg],AufDlgProc,0
        mov     [hAuf],eax
        invoke  ShowWindow,[hAuf],SW_HIDE
        invoke  CreateDialogParam,\
                [hInst],IDD_TATI,\
                [hwnddlg],TatiDlgProc,0
        mov     [hTati],eax
        invoke  ShowWindow,[hTati],SW_HIDE
        invoke  CreateDialogParam,\
                [hInst],IDD_MIT,\
                [hwnddlg],MitDlgProc,0
        mov     [hMit],eax
        invoke  ShowWindow,[hMit],SW_HIDE
        invoke  CreateFont,15,0,0,0,0,\     ; Ändern der Schriftart
                0,0,0,0,0,0,0,0,taschi      ; für die TabControl
        or      eax,eax
        jz      failed
        invoke  SendMessage,[hTab],\
                WM_SETFONT,eax,FALSE
        jmp     processed
    wmnotify:
        cmp     [wparam],IDC_TAB
        jne     finish
        mov     esi,[lparam]
        cmp     [esi+NMHDR.code],\
                TCN_SELCHANGING
        je      hidetab
        cmp     [esi+NMHDR.code],\
                TCN_SELCHANGE
        je      unhidetab
        jmp     processed
    wmcommand:
        jmp     wmclose
    wmkeydown:
        mov     eax,[wparam]
        cmp     al,1Bh                      ; ESCAPE = 27
        je      wmclose
        cmp     al,09h                      ; Tabulator
        je      wmtabpressed
        jmp     finish
    wmtabpressed:
        invoke  MessageBox,HWND_DESKTOP,\
                dbnam,0,MB_YESNO
    wmclose:
        invoke  EndDialog,[hwnddlg],0
    ; --------------------------------------------------------------------------
    ; -- Hide TabCtrl Dialog
    hidetab:
        invoke  SendMessage,[hTab],\
                TCM_GETCURSEL,0,0
        mov     [tabsel],eax
        cmp     [tabsel],0
        je      hideaka
        cmp     [tabsel],1
        je      hideauf
        cmp     [tabsel],2
        je      hidetati
        cmp     [tabsel],3
        je      hidemit
        jmp     finish
    hideaka:
        mov     ebx,hAka
        jmp     hide
    hideauf:
        mov     ebx,hAuf
        jmp     hide
    hidetati:
        mov     ebx,hTati
        jmp     hide
    hidemit:
        mov     ebx,hMit
        jmp     hide
    hide:
        invoke  ShowWindow,[ebx],SW_HIDE
        jmp     finish
    ; --------------------------------------------------------------------------
    ; -- Show TabCtrl Dialog
    unhidetab:
        invoke  SendMessage,[hTab],\        ; Anfrage, welcher Tab
                TCM_GETCURSEL,0,0           ; ausgewählt wurde.
        mov     [tabsel],eax
        cmp     [tabsel],0
        je      unhideaka
        cmp     [tabsel],1
        je      unhideauf
        cmp     [tabsel],2
        je      unhidetati
        cmp     [tabsel],3
        je      unhidemit
        jmp     processed
    unhideaka:
        mov     ebx,hAka
        jmp     unhide
    unhideauf:
        mov     ebx,hAuf
        jmp     unhide
    unhidetati:
        mov     ebx,hTati
        jmp     unhide
    unhidemit:
        mov     ebx,hMit
        jmp     unhide
    unhide:
        invoke  ShowWindow,[ebx],SW_SHOW
        jmp     processed
    failed:
        invoke  MessageBox,[hwnddlg],\
                fem,cMain,\
                MB_ICONERROR+MB_OK
        jmp     processed
    processed:
        mov     eax,1
    finish:
        pop     edi esi ebx
        ret
endp
    
Post 05 May 2006, 11:27
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1608
Location: Ukraine
shoorick
i see i'm not ready to give you fast solution, but you will not definetely cath tab or enter there in this way. there are some ways to do this:
1.subclass tabcontrol with procedure, which will detect tab pressing within it and notify parent window about it.
look there: http://board.flatassembler.net/topic.php?t=4786
2.try to use PropertySheet api function
3.also look there for another way to do this: http://board.flatassembler.net/topic.php?t=4359 for examples.
i had improoved dialog engine used in setup box example, but it is not ready to be posted yet.
Post 05 May 2006, 13:33
View user's profile Send private message Visit poster's website Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
kasake36,

Try modifying your message loop to include IsDialogMessage. This may be all you need to do to support tabbing. This is my "standard" message loop I use even when I don't want to tab between window controls.

Code:
        .while TRUE
                invoke GetMessage, msg, NULL, 0, 0
                .if eax, e, 0
                        jmp     @f
                .endif
                invoke  TranslateAccelerator, [gWnd], [hAccel], msg
                .if     eax, e, 0
                        invoke  IsDialogMessage, [gWnd], msg
                        .if eax, e, 0
                                invoke TranslateMessage, msg
                                invoke DispatchMessage, msg
                        .endif
                .endif
        .endw
@@:
        mov     eax, [msg.wParam]
        invoke  ExitProcess, eax
    


hth,

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 05 May 2006, 15:03
View user's profile Send private message Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
kasake36,

Attached is a small program with a window, and in that window are a number of different controls made with CreateWindow, and you can see how the tab key can be used to navigate from one to the other.

hth,

farrier


Description:
Download
Filename: TabWindows.zip
Filesize: 2.31 KB
Downloaded: 72 Time(s)


_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 05 May 2006, 15:32
View user's profile Send private message Reply with quote
kasake36



Joined: 28 Mar 2006
Posts: 68
kasake36
Shoorick and farrier: thanks for the fast replies. I already knew the threads but i hoped that there's an easier way to make this work (soo naive Wink.

So i'll first try to include the IsDialogMessage and if all fails drown myself or change the TabCtrl with a PropertySheet. I'll report back then! (Tomorrow)
Thanks for the example-code!!
Post 05 May 2006, 18:04
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1608
Location: Ukraine
shoorick
there's an easier way to make this work > i did that "dialog engine" exactly for easy and fast creating huge dialogs. i think, i will post my library unfinished...
Post 06 May 2006, 04:29
View user's profile Send private message Visit poster's website Reply with quote
kasake36



Joined: 28 Mar 2006
Posts: 68
kasake36
HELLO!! EUPHORIA!! Yes, there was an easier way to make tab-controls work in child-windows: using WS_EX_CONTROLPARENT for the child-dialogs! That's it!

I found out by reading the CreateWindowEx info in the Win32API-Help, and it says: "Allows the user to navigate among the child windows of the window by using the TAB key."

Thanks for all the kind help!!
Post 06 May 2006, 20:02
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.