WM_CTLCOLOREDIT and GetWindowText()

I use the WM_CTLCOLOREDIT message to set the colour of the text in my edit controls to a custom value when they hold no user-generated data.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
BOOL On_WM_CTLCOLOREDIT(HWND dialog, HDC control_DC, HWND control)
{
	int control_ID = 0;

	control_ID = GetDlgCtrlID(control);
	
	switch (control_identifier) {
	case IDC_SWITCHES:
		if (gp_data->Is_Switches_Set() == false) {
			SetTextColor(control_DC, gp_data->Get_Inactive_Colour());
		}

		SetBkColor(control_DC, gp_data->Get_Bk_Colour_RW());
		return reinterpret_cast<BOOL>(gp_data->Get_Bk_Brush_RW());

	case IDC_ARGUMENTS:
		if (gp_data->Is_Arguments_Set() == false) {
			SetTextColor(control_DC, gp_data->Get_Inactive_Colour());
		}

		SetBkColor(control_DC, gp_data->Get_Bk_Colour_RW());
		return reinterpret_cast<BOOL>(gp_data->Get_Bk_Brush_RW());

	default:
		return FALSE;
	}
}


Part of the time this works as expected. However, once I call GetWindowText(), use the Edit_GetText() macro or even send the raw WM_GETTEXT message to the control its text colour reverts to the default black.

Have any of you chaps encountered this behaviour? Is there any way around it? It seems like a bug in the common control library, but I totally accept I may be missing something obvious somewhere.
Topic archived. No new replies allowed.