I have recently started learning windows API and would like to make more interactive GUI applications. All code is written in C++.
What I have done is made a custom button window, not using the built in button class. I want each button to have different text and would like to set this in the parent window.
So I create the button and save the handle:
hNavBtnNews = CreateWindow(szUW_NAV_BTN, "News", WS_CHILD | WS_VISIBLE, 540, 0, 100, HEADER_HEIGHT, header, NULL, NULL, NULL);
Then to make sure this hasn't failed I check the handle and attempt drawing text:
if(hNavBtnNews == NULL){
printf("\nFailed to Create Window Nav Button \n");
}else{
printf("\nCreated Window Nav Button");
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
hdc = BeginPaint(hNavBtnNews, &ps);
SetBkMode(hdc, TRANSPARENT);
SetTextColor(hdc, BG_TXT_COLOR);
GetClientRect(hNavBtnNews, &rect);
DrawText(hdc, "News", -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
EndPaint(hNavBtnNews, &ps);
}
This is all done in the WM_CREATE case of the parent window procedure (which itself works just fine). The text is a light grey color and the background of the button is a dark blue. Except the text is not being drawn. There are no compiler warnings or errors either. Perhaps subclassing built in controls would be better for this, though I don't know how. Any help in solving this issue would be greatly appreciated.