Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how can i change dialog box color by clicking button

Not open for further replies.


Member level 1
Feb 24, 2007
Reaction score
Trophy points
Activity points

i will change the color of dialog box by using the "SetBkColor" method in InitInstance of app class..

but it works only once....

if i want to change the background color of dialoge frequently by clicking on a Button......

what can i do.....?

plz suggest me friends........

Have a static circular buffer in the button event routine containing the colors you want, and step through the array.

There was a message from alishirazi63 wrongly posted in report system.

hello, you should handle event on button and write this code: CClientDC dc(this); CRect rect; GetClientRect(rect); dc.FillRect(&rect, &CBrush(RGB(0,0,128)));

when you repaint a new colour by setting any entity colour

a message is sent to mainWnd frame message... WM_PAINT
but sometimes this routine is guarded
by a qualifed what it was called to repaint
like whole window . entity , group etc... as you see

so you basicaly need to refresh the whole window after a change
by repainting the whole window each time an event
like a change to its self happens

so its a trip to repost window {simply redraw the whole window class condusive}

if a window itterates with other changes that go in to its accepts
then it will normaly only repaint the entity within the frame
unless a menu choice is then made
but wont repaint what made the actual window frame depending on how your menus are scheduled to redraw there background etc...

unless you asked it to and this happens with only some events or a refresh all open apps within any o/s as does happen on some events

unless its a simple window entity change like a button press in a client area

and this does'nt happen each time you change colour unless you specify a repaint
via any WM CREATE.... unless it repaints the whole frame by recreating it

only if another accept changes the whole frame
like a stretch or refresh hierachie ...change window focus
within windows itself
this causes a global repaint event anyway....
and can be confuced with an ide or apps redraw accepts or self
when a colour is changed and the app looses focus even from a child window
or a global refresh occurs within windows normal schedules

unless you call a recall event within the msg class your ::main will construct

remember windows messages work in tears
MMsg... millions of time events later...
Msg.. actual realtime events you choose
mMsg .. miliseconds events used to decide what you do or the ide does...
uMsg .. micro message events {time frame of the event allowed }
nMsg ... nano seconds time windows
pMsg pico message events {picoseconds time allowance }
self explainitary event ladder that keeps windows timed no matter how fast an event happend to the main MSG of your apps function calls
from ide menus choices and realtime YOU

best use a repaint on bkg colour change function
constructed window flag .. etc however the main window
within the container you used is cast and constructed at runtime

Not open for further replies.

Part and Inventory Search

Welcome to