Hi,
I have a case WM_PAINT in my WndProc() function that correctly displays some text.
first in my .h file
1 2 3 4 5 6 7
|
LPCTSTR g_DisplayText = _T("when in the course of human events");
LPCTSTR g_DisplayGreenText = _T("You selected Green.");
Rect g_Rect;
BOOL g_bDisplayGreenText;
int g_LineX = 15;
int g_LineY = 5;
int g_LineHeight = 21;
|
now in my WndProc() case WM_PAINT:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
// initialize the RECT that positions each line of text
g_Rect.left = g_LineX;
g_Rect.top = g_LineY;
// draw the first line of text
DrawText(hdc, g_DisplayText, -1, &g_Rect, DT_SINGLELINE | DT_NOCLIP);
g_Rect.top += g_LineHeight;
// conditionally draw the green text
if(g_bDisplayGreenText)
{
DrawText(hdc, g_DisplayGreenText, -1, &g_Rect, DT_SINGLELINE | DT_NOCLIP);
g_Rect.top += g_LineHeight;
g_Rect.top += g_LineHeight;
}
|
This correctly displays the first line of text but not the green text.
if(I set g_bDisplayGreenText = true; either in the .h or before the if(g_bDisplayGreenText) block, it also correctly displays the green text.
I have a dialog called as follows:
1 2 3 4 5 6 7 8 9 10 11
|
case ID_MODAL:
{
int ret = DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_MODALDLG), hWnd, ModalDlgProc);
if(ret == IDOK)
{
if(g_bDisplayGreenText)
{
PostMessage(hWnd, WM_PAINT, 0, 0);
}
}
}
|
ModalDlgProc() correctly sets g_bDisplayGreenText = true if the user selects green.
The code correctly gets to the PostMessage(hWnd, WM_PAINT, 0, 0); call in case ID_MODAL.
WM_PAINT correctly gets to the DrawText(hdc, g_DisplayGreenText, -1, &g_Rect, DT_SINGLELINE | DT_NOCLIP); call.
But the green text does not display! boo hoo :(
What's going on? Any ideas on how to fix this?