Archived

This topic is now archived and is closed to further replies.

wing_majin

winAPI control coloring

Recommended Posts

wing_majin    122
I''ve been looking through all the seemingly useful functions available etc. Yet I can''t seem to get my dialog box''s background color to change from the default. Also, I want to change the font/style of the text entered into my control (edit box specifically) within this dialog. I tried the following at the dialog initialization: hdc = GetDC(hwnd); //for the dialog itself OR hdc = GetDC(GetDlgItem(hwnd, IDC_CONTROL1)); //for control COLORREF Background = RGB(intvalue1, intvalue2, intvalue3); SetBkColor(hdc, Background); // for the background SetTextColor(hdc, g_rgbBackground); //for the text Neither seems to even try to work. Isn''t it possible to change a dialog''s default bgcolor? and text in an edit control without using DrawText() etc?

Share this post


Link to post
Share on other sites
Dean Harding    546
To change the background colour, the window class (that is the WNDCLASSEX structure) for the window has a member, hbrBackground which determines the brush used to draw the background. Set this to whatever you need.

To change the font, send the control the WM_SETFONT message.

Look in MSDN for more info about these two things...


codeka.com - Just click it.

Share this post


Link to post
Share on other sites
wing_majin    122
That would work for a standard window, however not for a dialog box right? I don''t have a normal window, winmain returns a dialog procedure call. Also, seting the font of an edit box sets the entire body of text to one font regardless of when it was entered. I''m trying to get separate pieces of text entered into an edit box at varying fonts/colors sort of like the way instant message windows do by having a username as a color and the message as another type of text. So simply setting the fonts via messaging etc wont work. Is there anyway to do this with a normal edit box or is it only possible with richedit. And if so, how can one be created via resource or runtime? (MSDN''s pages on richedit are all missing)

Share this post


Link to post
Share on other sites
wing_majin    122
That would work for a standard window, however not for a dialog box right? I don''t have a normal window, winmain returns a dialog procedure call. Also, seting the font of an edit box sets the entire body of text to one font regardless of when it was entered. I''m trying to get separate pieces of text entered into an edit box at varying fonts/colors sort of like the way instant message windows do by having a username as a color and the message as another type of text. So simply setting the fonts via messaging etc wont work. Is there anyway to do this with a normal edit box or is it only possible with richedit. And if so, how can one be created via resource or runtime? (MSDN''s pages on richedit are all missing)

Share this post


Link to post
Share on other sites