winAPI control coloring

Started by
3 comments, last by wing_majin 21 years, 11 months ago
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?
Advertisement
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.
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)
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)
A tutorial at Winprog explains how to change a dialog''s background color.

I will not make a list of links... I will not make a list of links... I will not make a list of links...
Invader''s Realm

This topic is closed to new replies.

Advertisement