News:

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

How to change color to a window?

Started by RHL, March 20, 2012, 12:20:43 AM

Previous topic - Next topic

RHL

Hello all, well looking for a way but still I find nothing :/
I want change the colour background of a windows, how to do?
thanks

dedndave

what kind of window ?
for a "normal" window, you can set the background color in the WNDCLASSEX structure

attached is a simple window with a red background
there are a few ways to get a background brush
in this case, i used CreateSolidBrush
when you do it that way, the brush handle should be deleted with DeleteObject when you're done using it

i also included a text file that describes most of the ways to get a background color/handle
(ignore the 4 equates at the beginning of the file - those were for a program i wrote   :P )

RHL

which is complicated  :(
is a window made ​​of a .res I think it's normal, and I wanted to do it in runtime
is I want to do a loop that change color every few seconds

dedndave

nah - lol
it isn't that bad, once you get the basics

but - for now, let's play with a dialog box, which i think is what you are talking about...

in the DlgProc, you can answer the WM_CTLCOLORDLG message to change the background color
however, that message is only received whenever windows needs to redraw part or all of the dialog background

to force it to update, you can use InvalidateRect or InvalidateRgn and UpdateWindow

dedndave

i notice that you have been shy about playing with CreateWindowEx   :P
as i said, it isn't that bad
1) you need a WndProc - very much like a DlgProc
2) you register the window class, using RegisterClassEx and a WNDCLASSEX structure
- in some cases, you can use a pre-defined system class and skip this step
3) use CreateWindowEx to create the window
-  here, you can use the style and extended style flags to make different types of windows
4) a message loop to dispatch messages

Iczelion's tutorials take you through this stuff   :U

after dinner, i will play with some code to change the background color of a dialog box   :bg

RHL

okay... I try dedndave ^^'
thanks, also I hope you also share your code to learn from you  :bg

P1

Quote from: RHL on March 20, 2012, 02:18:14 AM
which is complicated  :(
is a window made ​​of a .res I think it's normal, and I wanted to do it in runtime
is I want to do a loop that change color every few seconds
I suggest that would be an option.

It could trigger epileptic attack for some users.

Regards,  P1   :8)

RHL

hahaha
I am new in ASM I have four months since I started  :(
also C/C++.  all autodidact because I have not money to pay for professional studies

dedndave

that's ok..
i came from 16-bit DOS days - lol
when i started, i played with 32-bit console programs for about 6 months before i started messing with GUI's   :P

give this program a try...
i even set the static text background color to match the dialog

RHL

dedndave very thanks dude  :clap:
I will study your code

dedndave

 :U

not a big deal...
but, i had the manifest file commented out in the resource file for some testing
if you want to see the button with UxTheme, uncomment the manifest line and run the batch to rebuild