News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Font and Color

Started by Shooter, December 29, 2010, 04:45:35 PM

Previous topic - Next topic

Shooter

How does one change the color of a static control using RadASM 3.x? I've tried
INVOKE SetTextColor,IDC_STC6,10
but I have no idea what numbers equate to what colors, and the font is still black on gray. I didn't find anything relating to colors in the dialog editor.

Thanks
-Shooter
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

dedndave

well - the 1st parameter to that function is a handle to the DC
the second parameter is the color value:
65536*blue + 256*green + red
(red, green, and blue = 0 to 255)

SetTextColor
http://msdn.microsoft.com/en-us/library/dd145093%28v=vs.85%29.aspx

you might use these functions with it...

SetBkColor
http://msdn.microsoft.com/en-us/library/dd162964%28v=VS.85%29.aspx

SetBkMode
http://msdn.microsoft.com/en-us/library/dd162965%28v=VS.85%29.aspx

there are a few other functions, too - but those will get you started

oh - and on the left side of the webpage - play with the menus   :bg
there are references to keep you busy all day

Gunner

radasm is not vb, you cannot change individual control fonts or colors with dialog editor...  you have to do it in code...
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

Shooter

I take it that hDc and ItemID are not the same things?
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

dedndave

i think the IDC_STC6 value is an EQUate from someplace - a dialog box static identifier (=1009 - go figure)
should be in one of the inc files, like windows.inc, but i don't find it
i am not sure if it's a handle or not

hDc is the handle to the device context
if you don't already have it.....
        INVOKE  GetDC,0
        mov     hDc,eax
;
;
        INVOKE  ReleaseDC,0,hDc

Gunner

when i get home in about 3 hours i will be of more help, ther are 2 messages you need to handle to change the colors also... i don't  remember them..
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

Shooter

Dave,
I just can't seem to get past that hDc. IDC_STC6 is indeed an EQU set to 108, the ItemID of the static text that I'm wanting to change.

I found a tutorial on Iczelion's site, but it sure seems like an awful lot of work involved for something seemingly so simple.

Rob, I look forward to yet another lesson in the fine arts of Assembly.  :bg
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

jj2007

You need to respond to the right message.

SWITCH uMsg
...
CASE WM_CTLCOLORSTATIC
mov eax, lParam
.if eax==hStatus
invoke SetTextColor, wParam, 0000D0h    ; BGR
invoke SetBkMode, wParam, TRANSPARENT
invoke GetSysColorBrush, COLOR_BTNFACE
ret
.endif

Gunner

Ah, I see JJ beat me too it  :8)

The second message I was thinking of is WM_SYSCOLORCHANGE
I think you need to process that also...
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

Shooter

I'm confused as to what sets hStatus.
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

Gunner

Wait one... found something in my files:

This is from Bill Cravener  :U

hStatus is the handle to your static control... I usually get the handles in WM_INITDIALOG
invoke GetDlgItem,hWin,IDC_STATIC1
mov hStatus, eax
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

Shooter

Question:
If I comment out the last line here:
            invoke SetBkMode,wParam,TRANSPARENT
            invoke SetTextColor,wParam,Red
            ;invoke GetStockObject,BLACK_BRUSH

Nothing changes. But if I include it, while the text itself does change, the background is black, which is not what I want (I want just plain old gray like the rest of the window).

I looked up GetStockObject, but didn't really get why it's needed in my case, nor did I find how to use it for what I want to achieve. Perhaps that's because I don't understand it's use here just yet.

Got any advice?
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

Gunner

What exactly do you want to do?  What color do you want the text of the static control?  What color do you want the background of the static control?
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

Gunner

 invoke GetStockObject,WHITE_BRUSH
                    ret
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

Shooter

Quote from: Gunner on December 29, 2010, 11:35:33 PM
What exactly do you want to do?  What color do you want the text of the static control?  What color do you want the background of the static control?

Well, I want red text on the normal gray background of the dialog box.

This is supposed to check and see if the Screen Saver is turned on, which we don't want in this case, and if it is, I want the text to stand out as a warning. Red on Gray.
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.