flat assembler
Message board for the users of flat assembler.

Index > Windows > Tabcontrol use

Author
Thread Post new topic Reply to topic
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY 17 Apr 2005, 20:33
Hi! How to use tabcontrol?
I just build a resource file with my resource editor and put a tabcontrol on the dialog, but how to use it?

Thanks!
Post 17 Apr 2005, 20:33
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 17 Apr 2005, 21:14
Well, first of all - read carefully "Tab control reference" and related in win32.hlp
Then you have to create several tab items (TCM_INSERTITEM) and also, corresponding controls as a children of the tab control. Only one of them have to be visible at a time.
Store the handles of the children in corresponding tab item using lParam member of TCITEM structure.
Then process TCN_SELCHANGE and TCN_SELCHANGING notification messages (WM_NOTIFY) and on every new selected tab, hide the previous visible child and show the new one.
Of course you have to handle WM_SIZE of the parent to ensure the size of the tab control itself and the size of the children will fit exactly in the client area. You should use TCM_ADJUSTRECT to get the tab control client area, clear for children.

You can see pretty clear example in Fresh sources, file "editorhost.asm" - especially read WM_NOTIFY message handle and EHM_DOCKWINDOW (from the label .addtotabs) and _EHM_SETACTIVETAB (note that Windows doesn't send notification messages if the tab is selected through TCM_SETCURSEL message, so you have to send them yourself).

Regards.
Post 17 Apr 2005, 21:14
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: US
coconut 17 Apr 2005, 21:22
in masm syntax:
http://win32assembly.online.fr/files/TabbedDialog.zip

in tasm:
http://win32assembly.online.fr/files/TabTutorial.zip

fasmw also uses a tab control, you may want to browse thru the source
Post 17 Apr 2005, 21:22
View user's profile Send private message Reply with quote
veach1



Joined: 16 Jul 2004
Posts: 165
veach1 18 Apr 2005, 06:24
in fasm (without resources):


Description:
Download
Filename: tabctrl.rar
Filesize: 2.23 KB
Downloaded: 482 Time(s)


_________________
dream of mind creates a monster
Post 18 Apr 2005, 06:24
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 18 Apr 2005, 07:16
veach1 wrote:
in fasm (without resources):


Just replace the first line of source with:
Code:
include '%fasminc%\win32ax.inc'
    
Post 18 Apr 2005, 07:16
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
veach1



Joined: 16 Jul 2004
Posts: 165
veach1 19 Apr 2005, 18:09
sorry...
fasminc.ini (combined common 'includes' from version 1.56 with added ODBC32.DLL structures + constants and API calls)


Description:
Download
Filename: fasminc.rar
Filesize: 54.36 KB
Downloaded: 368 Time(s)


_________________
dream of mind creates a monster
Post 19 Apr 2005, 18:09
View user's profile Send private message Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend 25 Apr 2005, 14:22
The prototype (not checked) would look like this:
Code:
        FIRST_CHILD_WINDOW_ID = 1
       ;...
        uglobal
          ChildWindowHandles:
            .Child1 dd ?
            .Child2 dd ?
            .Child3 dd ?
            .Child4 dd ?
           ;...
            .Childn dd ?
            NB_OF_WNDS = (($-ChildWindowHandles)/4)
        endg
       ;...
        ; creating all windows
        push    esi edi ebx
        mov     edi, ChildWindowHandles         ; all window handles will be stored there
        mov     esi, NB_OF_WNDS                 ; counter
        mov     ebx, FIRST_CHILD_WINDOW_ID      ; windows' IDs
     @@:
        invoke  CreateDialogParam, [hInstance], ebx, [hMainWindow], ChildWndProc1, 0
        stosd
        inc     ebx
        dec     esi
        jnz     @B
        pop     ebx edi esi
       ;...
        invoke  ShowWindow, [ChildWindowHandles.Child1], SW_SHOW
       ;...
        ; in window procedure
        cmp     [.uMsg], WM_NOTIFY
        jz      .notify
       ;...
        ; check if notify message is about tab control
  .notify:
        mov     eax,[.lParam]
        cmp     [eax+NMHDR.code], TCN_SELCHANGE
        jz      .selchange
        return
      .selchange:
        ; hide last window
        mov     eax, [LastShowedTab]
        invoke  ShowWindow, [ChildWindowHandles+eax*4], SW_HIDE
        ; show newly selected window
        invoke  SendMessage, [hTabControl], TCM_GETCURSEL, 0, 0
        mov     [LastShowedTab], eax
        invoke  ShowWindow, [ChildWindowHandles+eax*4], SW_SHOW
        return
    
Post 25 Apr 2005, 14:22
View user's profile Send private message Visit poster's website Reply with quote
kasake36



Joined: 28 Mar 2006
Posts: 68
kasake36 20 Apr 2006, 12:50
This thread was very helpful for me, and finally i could compile the tabctrl example of veach1, which helped me a lot! But i have a question regarding the child-windows of the tabs. Veach1 creates elements by invoking CreateWindowEx, but since you often have more content in those child-windows than a button or an edit-box, i wanted to create the child-windows by invoking DialogBoxParam... which crashes successfully.
So could anyone please give me a hint of how one can create "complex" child-windows using resources? Thank you!

P.S. I ALREADY had a look into the Fresh-editorhost.asm file.
Post 20 Apr 2006, 12:50
View user's profile Send private message Reply with quote
kasake36



Joined: 28 Mar 2006
Posts: 68
kasake36 20 Apr 2006, 20:31
EUPHORIA!! I have now found out how to include "resource"-dialogs into the different tabs: For that i invoke the function CreateDialogParam.
The program "Sorting algorithms in Assembler", found on this site: http://www.codingcrew.de/marty/win32asm.php helped me out! Thank you dear program Wink
Post 20 Apr 2006, 20:31
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.