Computing.Net > Forums > Programming > C++ Changing colour of Static Ctrl

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

C++ Changing colour of Static Ctrl

Reply to Message Icon

Name: Jeff80000
Date: October 12, 2004 at 05:42:04 Pacific
OS: WinXP Pro
CPU/Ram: 3.4GHz
Comment:

I'm am developing an application in VC++ 6 but i need to change the background colour and the text colour of a static text object that is on my dialog. I can't find a way to do this. I need to change the background colour to Grey and the text to White. Any ideas on a really simple solution, thanks



Sponsored Link
Ads by Google

Response Number 1
Name: gimmpy224
Date: October 12, 2004 at 15:16:46 Pacific
Reply:

are you using MFC?

GIMPS


0

Response Number 2
Name: waterdog
Date: October 13, 2004 at 19:39:39 Pacific
Reply:

When a static control is created, the parent window receives a WM_CTLCOLORSTATIC message. The WPARAM paramater equals the device context which can be used in the SetTextColor function to change the text colour in the control. The LPARAM paramater is the handle of the static control. You must return the handle to a colour brush that windows will use to colour the background of the control.
A rough example:
case WM_CTLCOLORSTATIC:
if((HWND)lParam == handleofstaticcontrol)

SetTextColor((HDC)wParam,RGB(0,0,255));
// set color of text in control

return (int)CreateSolidBrush(RGB(0,255,0);



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: C++ Changing colour of Static Ctrl

change excel cell colour using If www.computing.net/answers/programming/change-excel-cell-colour-using-if-/12146.html

Change password of acc--t on Internet. www.computing.net/answers/programming/change-password-of-acct-on-internet/1205.html

help needed with javascript code... www.computing.net/answers/programming/help-needed-with-javascript-code/8821.html