hey i got a few question here

first, how do i set the background color of a static control, (not just once, but everytime a color is selected)

second when i create a horizontal scroll bar, and try and set it's range (0 to 16) or it's position it don't work, and i'm also having trouble even moving it.

i've searched for both of these things, and heaps of stuff came up, but none of it helped, it just made me more confused, any example code would be greatly appreciated.

if anyone can help, thanks in advance.
Posted on 2004-04-22 11:36:50 by someone
anyone ?
Posted on 2004-04-25 04:42:13 by someone
For the static you process WM_CTLCOLORSTATIC in your window proc, return a handle of the brush you want to paint it with. The same for scrollbars but the message is WM_CTLCOLORSCROLLBAR, though for the scrollbar you might be disappointed. It is only sent for scrollbars that you create, not that are part of a control.
Posted on 2004-04-25 04:46:01 by donkey
so do i have to set any owner draw style stuff when i create the static control ?

also i don't need to color the scroll bar, but i can't get it to move or anything, it's not to scroll text, but to select a number (0-16) so it's not part of another control
Posted on 2004-04-25 04:52:06 by someone
No, no ownerdrawn stuff, just respond to that message in your Window proc. Much better to use a spinbox for picking a number, use an updown control and set it's buddy to a static. If you look at toolbar paint it has a 1-16 spinbox to set the brush width.
Posted on 2004-04-25 05:23:03 by donkey
ok, next problem, i can set the background color only of the text, not of the whole static control, how do i fix that ?
also, what is a spinbox ?
Posted on 2004-04-25 05:42:45 by someone
Hi someone,

You return a handle to a brush in order to set the background color for the static control, you generally just set the background mode to transparent and that way the background for the text will match the static control.

WM_CTLCOLORSTATIC

SetBkMode

SetBkColor

A spinbox is an updown control with a static as a buddy.

Updown controls

UDM_SETBUDDY
Posted on 2004-04-25 06:55:44 by donkey
ok, i got it working, but is this right ? shouldn't i create the brush then set the color, then destroy the brush ? cause i couldn't get it workin that way

.elseif uMsg==WM_CTLCOLORSTATIC
mov eax, lParam
.if eax==hClrThing
mov dwTemp, 11172386
invoke DeleteObject, hBrush
invoke SetBkColor, wParam, dwTemp
invoke SetBkMode, wParam, TRANSPARENT
invoke CreateSolidBrush, dwTemp
mov hBrush, eax
ret
.else
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
ret
.endif



also, one other thing, how can i make it repaint itself so that i can set a color, and make it redraw immediately, rather thatn waiting for this message
Posted on 2004-04-25 07:40:36 by someone
Looks OK to me I would just create the brush when needed and not in the WM_CTLCOLOR... message though, Not really much point in setting the background color if you set the mode to transparent. To force a window to be repainted invalidate it then call UpdateWindow...

invoke InvalidateRect, , NULL, NULL
invoke UpdateWindow,
Posted on 2004-04-25 07:49:25 by donkey
ok, thanks a lot for your help, it's all good now, thanks
Posted on 2004-04-25 08:00:33 by someone
ok, I have tried the code that "someone" posted:

.elseif uMsg==WM_CTLCOLORSTATIC
mov eax, lParam
.if eax==hClrThing
mov dwTemp, 11172386
invoke DeleteObject, hBrush
invoke SetBkColor, wParam, dwTemp
invoke SetBkMode, wParam, TRANSPARENT
invoke CreateSolidBrush, dwTemp
mov hBrush, eax
ret


Does anyone have the proper code for a Dialog Static Control, to set BOTH the text to one color and the background to any color.

.ELSEIF uMsg == WM_CTLCOLORSTATIC

Mov Eax,lParam
.if Eax == KSelHnd

; I guess this delete is here because this routine is being executed 28 times on my dialog. ? I only have one KSelHnd Static

invoke DeleteObject,Static_hBrush
RGB 255,0,0
invoke SetBkColor, wParam, Eax
RGB 0,255,0
Invoke SetTextColor,wParam,Eax
invoke CreateSolidBrush, Eax
Mov Static_hBrush, Eax
Invoke InvalidateRect,KSelHnd, NULL, NULL
Invoke UpdateWindow,KSelHnd
Mov Eax,Static_hBrush ; Now I return the new brush
ret
.Endif


The 28 time execution is caused by the InValidateRect, but it still doesn't color the static control.

Thanks
Posted on 2004-09-21 00:17:55 by StillLearning