A slight change to make it work just fine with -KEN-'s great suggestion ( and larry is true too, but following this method you don't have to worry about that); i've only altered/added relevant parts:
Code:
char cText01[]="Text 1";
char cText02[]="Text Number 2";
char cTheText[20];
RECT myRect = {1, 1, 635, 470};
.
.
case ID_NAVIGATION:
strcpy(cTheText,cText01);
InvalidateRect(hwnd,&myRect,1);
break;
case ID_NAVIGATION_2:
strcpy(cTheText,cText02);
InvalidateRect(hwnd,&myRect,1);
break;
.
.
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(hwnd,&ps);
SetTextColor(ps.hdc,RGB(TCR,TCG,TCB));
SetBkColor(ps.hdc,RGB(0,0,0));
DrawText(ps.hdc,cTheText,strlen(cTheText),&myRect,DT_WORDBREAK);
EndPaint(hwnd,&ps);
}
If you would prefer to get your own dc then perhaps:
Code:
void MyDrawTextFunction(char *cTxt)
{
hdc = GetDC(hwnd);
SetTextColor(hdc,RGB(TCR,TCG,TCB));
SetBkColor(hdc,RGB(0,0,0));
RECT myRect = {1, 1, 635, 470};
DrawText(hdccTxt,strlen(ctxt),&myRect,DT_WORDBREAK);
ReleaseDC(hwnd,hdc); //as larry pointed out
}
.
.
case ID_NAVIGATION:
MyDrawTextFunction("Text 1");
break;
case ID_NAVIGATION_2:
MyDrawTextFunction("Text Number 2");
break;
Although the principle of having a fn do this for you is sound enough I suspect that the wnd may get scrubbed anyway when ever a WM_PAINT occurs; using ValidateRect(hwnd,&myRect); might help prevent this.