how do i set the background color of my dialog window and all my controls ( buttons) and a groupbox to black and the text color of the buttons and groupbox to creamywhite?
Posted on 2002-07-13 23:01:18 by Qages
WM_CTLCOLOR*
Posted on 2002-07-13 23:14:01 by comrade
that helps, but doesn't solve my entire problem
Posted on 2002-07-13 23:16:29 by Qages
SetBkMode, SetBkColor, SetTextColor
Posted on 2002-07-14 12:50:32 by comrade
ive dabbled with it all night and i have gotten the dialog colored, but not the PUSHBUTTONS!!!!!! arrgh, how do i color them?????
please, i need some actual code to help me not a few apis listed.
Posted on 2002-07-14 12:54:31 by Qages
CAN BE .. WM_CTLCOLORBUTTON, WM_CTLCOLOREDIT... I think this is right if not i go find the whole thing for you ... just let me know... I use real windows but it should work with diaolgs windows somehow...


.elseif == WM_CTLCOLORSTATIC
;mov eax,lParam

;PUSH TRANSPARENT
;PUSH
;CALL SetBkMode
; .....................

;PUSH offset 00C5C5E2h;;;;00C5C5E2h ;
;CALL CreateSolidBrush
;mov hBrush,eax


;HERE SOMETHING ELSE I FOUNDED but never used

; ColorDialog proc hWin:DWORD, instance:DWORD, Flags:DWORD

LOCAL ccl:CHOOSECOLOR
LOCAL crv[16]:DWORD

lea edi, crv[0]
mov ecx, 16
mov eax, 0FFFFFFh
rep stosd

mov ccl.lStructSize, sizeof CHOOSECOLOR
push hWin
pop ccl.hwndOwner
push instance
pop ccl.hInstance
mov ccl.rgbResult, 0
lea eax, crv ; address of 16 item DWORD array
mov ccl.lpCustColors, eax
push Flags
pop ccl.Flags
mov ccl.lCustData, 0
mov ccl.lpfnHook, 0
mov ccl.lpTemplateName, 0

invoke ChooseColor,ADDR ccl

.if eax != 0
mov eax, ccl.rgbResult
.endif

ret

ColorDialog endp
Posted on 2002-07-14 14:00:37 by cmax
ive tried it under WM_CTLCOLORSTATIC and the buttons are still grey background and black text. i have no idea. this is what i have to make the window background black

.IF uMsg==WM_ERASEBKGND
mov LogBrush.lbStyle,BS_SOLID
RGB 0,0,0
mov LogBrush.lbColor,eax
invoke CreateBrushIndirect,addr LogBrush
mov hBrush,eax
invoke GetClientRect,hWin,addr rect
invoke FillRect,wParam,addr rect,hBrush
mov eax,TRUE
ret

.ELSEIF uMsg==WM_CTLCOLORSTATIC



invoke GetDlgCtrlID,lParam
;.if eax==101 || eax==102 ||eax==103 || EAX==104 || EAX==106 || EAX==108
RGB 245,245,245
invoke SetTextColor,wParam,eax
RGB 70,70,70
INVOKE SetBkColor,wParam,eax
invoke GetStockObject,NULL_BRUSH
;.ELSE
; MOV eax,FALSE
; ret
; .endif
ret
Posted on 2002-07-14 14:22:57 by Qages
Are they Static Buttons or Window Buttoms if they are Window Style buttons use WM_CTLCOLORBUTTON.

One more question are you using a Dialog Window created in rsrc.RC if so have you included this line #include "\masm32\include\resource.h" if not it may have something to do with it....

I don't like diaolgs because of the sizing system that it use... I reather make a real windows that use popup windows if it need them...But thats my problem tho...

I go see if i can find something about dialog window color on my machine with-in a hour....I'm 100% sure i got a few things...
Posted on 2002-07-14 14:58:42 by cmax
i have my resource file 100% right even that line,
PUSHBUTTON "Exit",108,73,30,61,14 this is what im using its on a dialog in that .rc
Posted on 2002-07-14 15:06:53 by Qages
This one uses Dialog, I forgot where i got the zip from proberly Icz. Someone will recognize it. I could send the whole zip i guest but i don't know how.... This WM_CTLCOLORSTATIC & WM_CTLCOLOREDIT but just end up showing 3 controls with color in them. This the only thing i got that can even come close to what you are trying to do. I think the key is to GetWinowLong or SetWindowLong as done here.


.386
.model flat, stdcall ;32 bit memory model
option casemap :none ;case sensitive

include DialogBox.inc

.code

start:

invoke GetModuleHandle,NULL
mov hInstance,eax

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

.elseif eax==WM_COMMAND
mov eax,wParam
mov edx,eax
shr edx,16
.if dx==BN_CLICKED
.if ax==IDOK
invoke MessageBox,hWin,addr szMsg,addr szMsg,MB_OK
.elseif ax==IDCANCEL
invoke EndDialog,hWin,0
.endif
.endif
.elseif eax==WM_CTLCOLORSTATIC
invoke GetWindowLong,lParam,GWL_ID
.if eax==1001
invoke CreateSolidBrush,0FFh
ret
.endif
mov eax,FALSE
ret
.elseif eax==WM_CTLCOLOREDIT
invoke GetWindowLong,lParam,GWL_ID
.if eax==1002
invoke SetBkMode,wParam,TRANSPARENT
invoke CreateSolidBrush,0FF00h
ret
.elseif eax==1003
invoke SetBkMode,wParam,TRANSPARENT
invoke CreateSolidBrush,0FF0000h
ret
.endif
mov eax,FALSE
ret
.elseif eax==WM_CLOSE
invoke EndDialog,hWin,0
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret

DlgProc endp

end start
Posted on 2002-07-14 15:41:02 by cmax
i dunno. i added it to my WndProc and still grey buttons. 101 102 etc are my buttons

.ELSEIF uMsg==WM_CTLCOLORSTATIC

invoke GetWindowLong,lParam,GWL_ID
.if eax==101
invoke CreateSolidBrush,0FFh
.endif

invoke GetDlgCtrlID,lParam
;.if eax==101 || eax==102 ||eax==103 || EAX==104 || EAX==106 || EAX==108
RGB 245,245,245
invoke SetTextColor,wParam,eax
RGB 70,70,70
INVOKE SetBkColor,wParam,eax
invoke GetStockObject,NULL_BRUSH
;.ELSE
; MOV eax,FALSE
; ret
; .endif
ret

.elseif uMsg==WM_CTLCOLOREDIT
invoke GetWindowLong,lParam,GWL_ID
.if eax==102
invoke SetBkMode,wParam,TRANSPARENT
invoke CreateSolidBrush,0FF00h
ret
.elseif eax==103
invoke SetBkMode,wParam,TRANSPARENT
invoke CreateSolidBrush,0FF0000h
ret
.endif
Posted on 2002-07-14 16:10:00 by Qages
As reported in Platform SDK documentation you need an owner-drawn button to use non standard colors:
By default, the DefWindowProc function selects the default system colors for the button. Buttons with the BS_PUSHBUTTON, BS_DEFPUSHBUTTON, or BS_PUSHLIKE styles do not use the returned brush. Buttons with these styles are always drawn with the default system colors. Drawing push buttons requires several different brushes-face, highlight and shadow-but the WM_CTLCOLORBTN message allows only one brush to be returned. To provide a custom appearance for push buttons, use an owner-drawn button.
Posted on 2002-07-14 16:44:11 by LuHa
EDIT:i give up. ive created 5 owner drawen buttons. all still gray and black.
Posted on 2002-07-14 16:54:56 by Qages
If your buttons are owner drawn the painting is up to you, you can use whatever color you like.
Posted on 2002-07-14 17:00:41 by LuHa
how do i do that??????
btw
im using this to draw them
invoke CreateWindowEx,0,ADDR btnClass,lpText,WS_CHILD or WS_VISIBLE,a,b,wd,ht,hParent,ID,hInstance,NULL
Posted on 2002-07-14 17:02:50 by Qages
With your invoke you are creating them and windows paints them for you. You have to add the BS_OWNERDRAW style and handle WM_DRAWITEM message. IIRC there is an example on Iczelion's website.
Posted on 2002-07-14 17:12:48 by LuHa
ive gotten some where, now the button doesnt lookin like a button any more it looks like a flat label, and is still gray.


.elseif uMsg==WM_DRAWITEM

invoke RtlMoveMemory,addr dii,addr lParam ,sizeof dii
invoke SetBkMode, dii.hDC, TRANSPARENT
RGB 245,245,245
invoke SetTextColor, dii.hDC, eax

RGB 245,245,245
invoke SetBkColor, dii.hDC, eax

ret
Posted on 2002-07-14 17:38:55 by Qages
see this post

and good luck :alright:
Posted on 2002-07-14 18:41:53 by NEMO
My throught on this is maybe using RGB is getting overwritten because it may not be set up right for this... There a program with source called Color Picker that let you find the nuber for a color in ASM, C++ EXACTLY of your chossing ...Numbers like this 0FF0000h. Now it can't go wrong...
Posted on 2002-07-14 18:59:01 by cmax
why is the text bold when creating a button?
Posted on 2002-07-14 19:12:05 by Qages