Link to home
Start Free TrialLog in
Avatar of bradsoblesky
bradsoblesky

asked on

Form Color

How do I change the background color and text color of one form?
Avatar of bradsoblesky
bradsoblesky

ASKER

Could you also tell me how to change the size of individual text?
You can tell I just started the language. :)
In what contect?  What do you mean by "form"?

In a windows DC you can use SetBkColor() and SetTextColor().  Does that help?
In a window procedure you can respond to the WM_CTLCOLORxxxx messages.  (There is a whole bunch of messages hence the xxxx) to change the color and text of child controls.
Note that this is a C++ topic area.  There are topic areas for particular OSs.
This is visual C++ 6.0 for win 98 by form I mean an individual dialog box.  For example just the About form. They use form in Visual Basic for the "window" of the program. I need how to do it and were to put it.
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
How do you then change the background of a form once you added the WM_CTLCOLOR message?

(I just want to change the background color when I press a button.)
Sorry Brad, hope you don't mind me asking a similar question in here.
Those messages can be used to change the color of child windows (i.e. controls on the window that handles the message).  The window just changes the background color of the DC specified in the message and that DC is then used to paint the control's client area.   The problem is that not all types of controls are good about using this feature, so it doesn't always work.
But now is there really a way, if so how do you do it. (code) I hopefully speak on behalf of Brad and myself.
You know change the color of just the about dialog box not your main program dialog box.
The about dialog box must have its own (dialog) window procedure that is seperate from the main window procedure.  Just do this in the about dialog's window procedure, not the main window procedure.
This is for a game and I want the window to be all black but not the other dialog boxes or windows in the program. Is what you are saying is that there is no way to do it in Visual C++ 6. It is a click of a button in Visual Basic 6.
>> what you are saying is that there is no way to do it in Visual C++ 6
No.  I expained how to do it above.  You must manually paint the window's background.  If the window has child controls, you must handle the WM_CTLCOLORxxxx messages from those or they won't "blend in".  Unfortunately, not all types of controls are good about this.  If you are using one that doesn't handle the WM_CTLCOLORxxxx message well, the results might not look great.  Then you have to give up, or sub-class the control or write your own control.
>>WM_CTLCOLORxxxx   ???????????????
I don't know how or were to use it. I'm a complete moron :(
Look it up in the help.  The information is quite extensive.  More than I can type here.
Guess what I did that first; And It was so extensive that I didn't know what the hell to do.  I just want one damn example of how to do it and some one to tell me where to put it. Not a hole bunch of C jargon that I don't understand because I have no clue what I am doing, I have no background in C/C++. Someone out there has to know an easy way to do it.
For example check this answer from "Answer 2000" it says exactly where to put it and how to do it.Only one problem with this it changes all of the backgrounds and not just one:


 MFC program - background dialog color - stick in InitInstance
SetDialogBkColor( RGB(0,0,0), RGB(255,255,255) ) ; // background to black, text to white (black on black is not to readable :-))
There is no easy way to do it.  It will take a good understanding of windows programming and a decent amount of trial and error.

At the very least, you must be familiar with:
Window procedures and handling window messages.
Windows Device contexts and graphics procedures.
The WM_CTLCOLORxxx messages.

if you are not, you will have to do some reading and learning.  You will HAVE to learn about these things if you plan to program in windows in C++.  But you don't have to do the research now.  This sounds like a feature that could wait until you are more familiar with the windows API.  If you are ready to learn about them.  I recomend you buy 2 or 3 good books on windows programming. (1 is not enough) and read them each twice.  (Seriously,  they tend not to make much sense in the beginning, read it anyways.  On the second time through things make much more sense and you pick up on lots that you miss the first timek, that is also a reason to read several instead of one.)
O.K. I'll take that advice, Thanks for your help.