GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 03-May-2006, 09:15
steph steph is offline
New Member
 
Join Date: May 2006
Posts: 15
steph is on a distinguished road

How do I change the background color of an entire edit control box, not just the...


Hello All!

How do I change the background color of an entire edit control box, not just the background color of its text?

Thanks in advance,
Steph
  #2  
Old 11-May-2006, 12:52
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,455
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

MOVED: change the background color of an entire edit control box


start with this article: http://support.microsoft.com/kb/q117778/

and let me know how it goes. It's been some time since I've played with specifically coloring controls.

basically, from the article,
1. override the WM_CTLCOLOR and WM_DESTROY messages
2. add a CBrush* member variable to the dialog class (that has the edit control) [see the article]
3. copy the code to the functions created for the messages
4. comment-out the SetTextColor() call (unless you want a change)
5. set a color in the class constructor [set (255, 255, 0) for yellow]
6. set the same color in SetBkColor() function.

That's about the basics of it, I believe.
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
Last edited by cable_guy_67 : 03-Jun-2006 at 09:16. Reason: Edited old title
  #3  
Old 19-May-2006, 14:23
steph steph is offline
New Member
 
Join Date: May 2006
Posts: 15
steph is on a distinguished road

MOVED: change the background color of an entire edit control box


TurboPT,

Well, I did that, and it looks fine. However, if the user clicks the edit boxes or uses the tab key many times, my program stops running. I thought it could have something to do with deleting the brushes (lack of memory or something). But, I deleted the brushes in the DESTROY function, as the website said to. Do you think it could be becuase I initialized the brushes at the beginning of the CTLCOLOR function?

Also, I added two new dialog windows to my program (so I had to add two new classes for them). Basically, when a specific button on the first dialog window is pressed, the second dialog window is supposed to appear (to do this I also had to add a member variable to my first (original) class, with its data type being the class name of my second dialog). Now, this worked. However, when I did the same thing for when a specific button button on the second dialog window is pressed (meaning the third dialog window is supposed to appear), the third dialog window does not display (it somewhat flashes when the specific button on the second dialog is pressed constantly).

Do you have any ideas?

Thanks Again,
Steph
Last edited by cable_guy_67 : 03-Jun-2006 at 09:16. Reason: Edited old title
  #4  
Old 19-May-2006, 15:29
steph steph is offline
New Member
 
Join Date: May 2006
Posts: 15
steph is on a distinguished road

MOVED: change the background color of an entire edit control box


TurboPT,

Regarding my last message, I figured out the problem that I mentioned in the second paragraph. So, thanks anyways.

However, I do still need help with what I wrote in the first paragraph.

Thanks,
Steph
Last edited by cable_guy_67 : 03-Jun-2006 at 09:17. Reason: Edited old title
  #5  
Old 19-May-2006, 20:28
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,455
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

MOVED: change the background color of an entire edit control box


Maybe, the brush in the article is created once, in the constructor.

See if making such a change helps that problem.
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
Last edited by cable_guy_67 : 03-Jun-2006 at 09:17. Reason: Edited old title
  #6  
Old 22-May-2006, 20:20
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,455
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

MOVED: change the background color of an entire edit control box


What's the latest on those brushes?

If you still have trouble, post your code (if you can) and we'll try and see what's happening.
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
Last edited by cable_guy_67 : 03-Jun-2006 at 09:18. Reason: Edited old title
  #7  
Old 25-May-2006, 16:00
steph steph is offline
New Member
 
Join Date: May 2006
Posts: 15
steph is on a distinguished road

MOVED: change the background color of an entire edit control box


TurboPT,

Sorry that I did not reply sooner....I have been so busy lately, that I did not get a chance to work on it until today. But your suggestion did work. I did have to place it in the constructor.

Thank you (again). I really do appreciate all your help.

Until Next Time,
Steph
Last edited by cable_guy_67 : 03-Jun-2006 at 09:18. Reason: Edited old title
  #8  
Old 02-Jun-2006, 09:15
steph steph is offline
New Member
 
Join Date: May 2006
Posts: 15
steph is on a distinguished road

MOVED: change the background color of an entire edit control box


TurboPT,

I wrote a message with the subject "Accessing values from a different dialog" (in the "MS Visual C++ / MFC Forum"). 20 people have read it, but no one has responded. Could you take a look please?

Thanks,
Steph
Last edited by cable_guy_67 : 03-Jun-2006 at 09:19. Reason: Edited old title
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
change dlg background inbal79 MS Visual C++ / MFC Forum 3 19-Mar-2006 06:49
[winapi] edit control is lying to me... ubergeek C Programming Language 8 15-May-2005 18:02
Can you change the background colors in a console app? swashplate C++ Forum 3 07-Dec-2004 20:19
Help! Some basal questions about MFC xutingnjupt MS Visual C++ / MFC Forum 1 05-Dec-2004 03:38

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 13:31.


vBulletin, Copyright © 2000 - 2014, Jelsoft Enterprises Ltd.