News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

not shows a static control into TabStrip control

Started by x64Core, June 11, 2012, 04:30:45 PM

Previous topic - Next topic

x64Core

hello all!  :biggrin:, well, I'm programming a small program but for example, I have problem to show a static control into a tabstrip control:

I have no idea why it not shows the static control...

include masm32rt.inc
DlgProc PROTO :HWND,:UINT,:WPARAM,:LPARAM
.const
IDD_DIALOG1 equ 101
IDD_TAB1 equ 1001
.data
StaticClass db "Static",0
.data?
hInstance dd ?
hTab dd ?
hstatic1 dd ?
.code

start:

invoke GetModuleHandle,NULL
mov hInstance,eax

    invoke InitCommonControls
invoke DialogBoxParam,hInstance,IDD_DIALOG1,NULL,addr DlgProc,NULL
invoke ExitProcess,0

DlgProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

mov eax,uMsg
.if eax==WM_INITDIALOG
invoke GetDlgItem,hWin,IDD_TAB1
mov hTab,eax

invoke CreateWindowEx,NULL,addr StaticClass,addr StaticClass,WS_CAPTION or WS_CHILD ,100,100,200,200,hTab,NULL,hInstance,NULL
mov hstatic1,eax
.elseif eax==WM_CLOSE
invoke EndDialog,hWin,0
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret

DlgProc endp

end start


rc:

#define IDD_DIALOG1 101
#define IDC_TAB1 1001
IDD_DIALOG1 DIALOGEX 6,6,358,191
FONT 8,"MS Sans Serif",0,0
STYLE 0x10CF0800
EXSTYLE 0x00000000
BEGIN
  CONTROL "",IDC_TAB1,"SysTabControl32",0x50018000,28,14,292,118,0x00000000
END



5k3l3t0r

hi
here is a small tutorial on how to work with tabcontrol:

http://win32assembly.online.fr/TabTutorial.txt

hope it help

5k3l3t0r

dedndave

Bill Cravener has a nice little example...

masm32\examples\Bill_Cravener\tabs

x64Core

thanks! but now I have another problem  :icon_rolleyes:
I added a manifest file to example by Bill Cravener, but the static controls are not the same style... I tried with transparency style but it dfoes  no works, could help me? I do not know how to fix



thanks a lot :)

Gunner

.data
; #######           DLLS
szuxtheme                   db    "uxtheme", 0

; #######           Procs
szThemeProc                 db    "EnableThemeDialogTexture", 0


In your startup code somewhere:
    push    offset szuxtheme                            ; see if we can theme our app
    call    LoadLibrary                                 ;
    test    eax, eax                                    ; is UXTheme.dll on system?
    jz      CantTheme                                   ; Nope
   
    mov     hThemeLib, eax                              ; yes, save handle to library
   
    push    offset szThemeProc                          ; get proc address of EnableThemeDialogTexture
    push    eax                                         ;
    call    GetProcAddress                              ;
    mov     hThemeProc, eax                             ;
    jmp     ContinueStartup                             ;
   
CantTheme:
    mov     hThemeLib, edi                              ; 0


In your WM_INITDIALOG handler:
    mov     ecx, hThemeLib
    test    ecx, ecx
    jz      NoTheme
     
            push    6
            push    hWin
            call    hThemeProc
       
    NoTheme:


And in your close code:
    mov     eax, hThemeLib
    test    eax, eax
    jz      @F
    push    eax
    call    FreeLibrary

@@: 
~Rob

dedndave

not sure about what Rob says - he may be right

but - from my experience...
if you add a manifest file, you should use InitCommonControlsEx at the beginning of the program
        .DATA?
icc INITCOMMONCONTROLSEX <>

        .CODE
Start:  mov     icc.dwSize,sizeof INITCOMMONCONTROLSEX
        mov     icc.dwICC,<SomeFlags>
        INVOKE  InitCommonControlsEx,offset icc

<SomeFlags> should be the appropriate combination of flags, as described here...
http://msdn.microsoft.com/en-us/library/windows/desktop/bb775507%28v=vs.85%29.aspx

for example
        mov     icc.dwICC,ICC_STANDARD_CLASSES or ICC_TAB_CLASSES

x64Core

@Gunner: thanks mate, but it's the only way? well, just wondering...  :biggrin:
@Dave,: thanks mate, but it does not works... I tried with all flags lol  :biggrin:

Gunner

Yes the only way that I know of.  A manifest doesn't take care of the problem you see.  The code I posted allows the OS to properly color/draw your controls.
~Rob

5k3l3t0r

hi.
in your dialog procedure:


.elseif uMsg==WM_CTLCOLORSTATIC
   invoke CreateSolidBrush,White
   ret



hope it help

5k3l3t0r

dedndave

well - close   :P
you don't want to create a new brush everytime the message is recieved
but - create the brush in WM_INITDIALOG, and store the handle so it may be deleted when done (WM_CLOSE)
;WM_INITDIALOG

        INVOKE  CreateSolidBrush,crefStaticBkColor
        mov     hbrStaticBackground,eax


when you receive WM_CTLCOLORSTATIC, wParam holds the hDC for the static control
set the background color and return a handle to the brush in EAX
;WM_CTLCOLORSTATIC

        INVOKE  SetBkColor,wParam,crefStaticBkColor
        mov     eax,hbrStaticBackground
        ret


not sure how well that will work with XP uxTheme enabled, however
i know it can't work correctly with buttons because the theme creates a different window hierarchy
but - it probably works ok with static controls

x64Core

thank you all: biggrin: The problem with using a brush is that if windows has a theme installed,
the static control would not have the same style lol

dedndave

a static doesn't really have much of a style   :P
you should be able to use
        INVOKE  GetSysColor,COLOR_BTNFACE
i think that's the right index to get the color value
i have been busy, or i would have tried it

x64Core


dedndave

well - i don't know how much help i was   :redface:

i tried the CTLCOLOR* method, with no luck
that's probably because there is no WM_CTLCOLORTAB message   :P
the tab control is not a static

there are other methods to set the bacground color
one method is to create a static for each page
another is the item draw method

anyways, after looking it over, the background color (which looks nearly white - actually a light blue)
is the correct background color for the theme
in other words, we are trying to change the wrong thing
if you select the third tab (with push buttons), you will see that it looks pretty good
what seems to be incorrect is the background color for the radio and checkbox buttons
i think i would subclass the tab control and set the background color for those
for that - the CTLCOLOR* method should work
i seem to recall that the buttons use WM_CTLCOLORSTATIC, not WM_CTLCOLORBTN as one might think