News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

HELP static color

Started by asmcoder, December 12, 2013, 06:49:18 PM

Previous topic - Next topic

asmcoder


       .elseif eax==WM_COMMAND
mov eax,wParam
and eax,0FFFFh
.if eax==IDC_BTN1
invoke SendMessage,hwnd_static,WM_SETTEXT,0,offset text1
; invoke UpdateWindow,hwnd_static
; invoke InvalidateRect,hwnd_static,0,TRUE
.endif

.elseif eax==WM_CTLCOLORSTATIC

mov eax,lParam ;hwnd
.if eax==hwnd_static
invoke SetTextColor,wParam,0FFh
invoke SetBkMode,wParam,TRANSPARENT
invoke GetStockObject,NULL_BRUSH
ret
.endif



Hi, all
I am trying to change the static color,
when i click the button, a new text show, but the pre text still exist.
i tried UpdateWindow and InvalidateRect, but they don't work.

jj2007

#1
User LTGRAY_BRUSH, or create your own.

EDIT: invoke GetSysColorBrush,COLOR_BTNFACE is a perfect solution :t

asmcoder

Thanks jj , but the LTGRAY_BRUSH don't match the background color

asmcoder

got it. :biggrin:
         invoke SetTextColor,wParam,0FFh
         invoke SetBkMode,wParam,TRANSPARENT   
         invoke GetSysColorBrush,COLOR_BTNFACE

dedndave

i would put the GetSysColorBrush(COLOR_BTNFACE) call in WM_INITDIALOG
and store the HBRUSH in a global variable, something like hbrStaticBg
    .if eax==WM_INITDIALOG
        invoke  GetDlgItem,hWin,IDC_STC1
        mov     hwnd_static,eax
        invoke  GetSysColorBrush,COLOR_BTNFACE
        mov     hbrStaticBg,eax


then, for WM_CTLCOLORSTATIC...
    .elseif eax==WM_CTLCOLORSTATIC
        mov     eax,lParam                                   ;hwnd
        .if eax==hwnd_static
            invoke  SetTextColor,wParam,0FFh
            invoke  SetBkMode,wParam,TRANSPARENT
            mov     eax,hbrStaticBg
        .else
            mov     eax,FALSE
        .endif
        ret

fearless

Im assuming this is on Windows 7/Vista or above.

I ran into similar issues with Send WM_SETTEXT, SetDlgItemText and tried various things like InvalidateRect, UpdateWindow etc.

The only solution i found that works is to hide and show the control - it then repaints it without the previous text underneath it

            invoke SendMessage,hwnd_static,WM_SETTEXT,0,offset text1
            Invoke ShowWindow, hwnd_static, SW_HIDE
            Invoke ShowWindow, hwnd_static, SW_SHOW


From what i can remember (been a while since i looked into the issue), and i cant remember the sources i found that relate to this (think it was in relation to listviews not displaying properly under win7 - seemed to be a lot of posts on various forums in relation to this issue, and i had a similar issue), but from what i recall it is to do with the Windows Presentation layer in Vista/7/8 etc that the common controls and other bits of win32 api that use it, call or are managed by that now instead. So you get a kind of buffering/queued update - if you minimize/maximise the main window the control probably will refresh, other times it would do it if you left it long enough, but trying to force it to update with SetDlgItemText, WM_SETTEXT only overwrites the old text. Windows XP isnt affected by this. Im running Win7 64bit - cant say for sure if this is the same on a Win7 32bit version or not. Vista and Win8 prob gonna be the same.

So if that helps. Ill try and dig out some references to the issue if i can. Maybe http://blogs.msdn.com/b/oldnewthing/ has something about the issue.

dedndave