Quick Search for:  in language:    
code,will,change,background,color,resourced,d
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
C/ C++ Stats

 Code: 728,035. lines
 Jobs: 116. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login





Latest Code Ticker for C/ C++.
socket
By Muhammad Ahmed Siddiqui on 3/6


Click here to see a screenshot of this code!Flexible Screen Designer Classes
By John Indigo on 3/6

(Screen Shot)

Click here to see a screenshot of this code!Basic 2D Transformation with Simulation
By Siva Chandran.P on 3/6

(Screen Shot)

Message Digest (LINUX) 1.0
By Vikram Shinde on 3/6


Windows Application with modified Message Loop
By Rockwell on 3/5


Inheritance of CBox
By Rockwell on 3/5


Click here to see a screenshot of this code!Awesome Screen Shot System For OpenGL And Direct3D
By James Dougherty on 3/5

(Screen Shot)

Process Killer
By Ruud Koolen on 3/5


Click here to see a screenshot of this code!Get The PIII Processor Serial Number Like Intel Format
By haitham hamed housin on 3/5

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

Dialog Background Color (NOT MFC !!)

Print
Email
 

Submitted on: 2/9/2004 9:54:55 PM
By: Danny J 
Level: Advanced
User Rating: By 1 Users
Compatibility:C++ (general), Microsoft Visual C++

Users have accessed this article 956 times.
 

(About the author)
 
     This code will change the background color of a resourced dialog opposed to a Win32 window. Thanks Wolf McCould for reminding me of the CreateBrushIndirect() function. _________________________________________________ UPDATE: I've tested this code with static controls, it works perfectly.

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
1) You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
// insert this code into your dialog's W // inProc code

case WM_CTLCOLORDLG:
// case WM_CTLCOLORSTATIC:
LOGBRUSH lb;
static HBRUSH hBrush;

lb.lbColor = RGB(0,0,0);
lb.lbStyle = 0;

hBrush = CreateBrushIndirect(&lb;);

return (int)hBrush;
break;

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this article(in the Advanced category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
2/9/2004 9:55:30 PM:Danny J
psc stripped my newline tags....
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/9/2004 9:59:34 PM:Danny J
fixed the newline taggs, but your going to have to tab it yourself... If you need help with C++, I'm open on MSN
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/10/2004 6:04:45 PM:Wolf McCloud
Well, no problem. I posted it long time ago and I see it helped some people. I'm no newb anymore and I do much more complicated stuff, but it is always good to remember how to do basic things. Also, you should use CreateSolidBrush(color);
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/13/2004 3:53:01 PM:
I have looked for 4 hours how to do this. I have been through many tutorials and google groups. Thanks so much. It worked like a charm. All I could find was mfc stuff. Thanks again. Shawn Nedwidek smn4780@cs.rit.edu
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/13/2004 4:01:47 PM:
Not sure if the last message went through but I just wanted to thank you. I have spent many hours looking how to do this but could only find mfc. You rock. Thanks again
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/13/2004 7:51:08 PM:Danny J
I was in your shoes before. But after finding some kind of code (maybe C), I thought of how it was used in lpszBackground, and how you could use CreateBrushIndirect() to use a different color rather white, grey, black. I'm making a new submission on common controls, so get ready.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/14/2004 11:06:03 PM:
is C++ software like VB??
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/15/2004 1:58:28 PM:Danny J
C++ is very different from Visual Basic. First, it does not feature any RAD(ical) tools, most of everything in C++ has to be defined in code. In C++, you use APIs much more than STD, the main Win32 framework.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/15/2004 3:14:56 PM:Wolf McCloud
For newbies... Rapid Application Developpement (RAD)... Advanced Programming Interfac (API)... I don't know and I don't care about what STD means =P correct me if I'm wrong.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/15/2004 3:15:36 PM:Wolf McCloud
Danny, you should use CreateSolidBrush, which is a faster way to create a brush, since it does not require a LOGBRUSH.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/15/2004 3:39:46 PM:Danny J
If you want to use styles, LOGBRUSH is anyones answer.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/15/2004 10:16:03 PM:Wolf McCloud
Yea, but if you don't, like you are showing on the example, CreateSolidBrush is. Both ways are great. Anyways, I never, or rarely, use dialogs.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/15/2004 10:17:49 PM:Wolf McCloud
You do no need a  break;  if you have  return (int)hBrush;
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/18/2004 6:34:08 PM:
Yes you do need the break. The break keyword is what tells the program to leave the switch statement. Without it, after that one message is processed, the program will go back to switch statement and will try to process another case. Since you cannot have the same value case in the same switch statement, the program will go through the entire statement until it reaches the end. If the break keyword is implemented, though, the program will leave the switch statement and go on normally. It really doesn't make a difference, but if you're talking sufficient coding, you need the break.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/18/2004 6:35:22 PM:
If you need more help, look up 'switch statements' on MSDN for more information on this small technicallity.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/1/2004 8:13:05 PM:Jon braud
Wolf, API means Application programming Interface.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this article has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular article, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | C/ C++ Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.