Program with CS_OWNDC.
I'm just learning how to program with the windows API, so maybe I'm missing something, but it seems odd to me.
I've been reading "Programming Windows" and started to make something using the mapping modes so I could get a better idea of how they worked. I noticed that if I held the cursor over any of the buttons at the top of the window (close, minimize, etc...) that the description of that button doesn't completely go away.
After playing with it for a while I noticed that if I had CS_OWNDC set in my window class it would do this if the function SetViewportOrgEx() was present. If one of those two things weren't there it would work.
Does anyone know why this happens? I'd really appreciate any help.
Here's some code. I took a bunch of stuff out of it so it would be shorter.
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam,
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR CmdLine, int iCmdShow)
TCHAR szProg = TEXT ("Program...");
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hInstance = hInstance;
wndclass.lpfnWndProc = WndProc;
wndclass.lpszClassName = szProg;
wndclass.lpszMenuName = NULL;
wndclass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
if ( !RegisterClass(&wndclass) )
MessageBox(NULL, TEXT("Error registering window class"),
hwnd = CreateWindow(szProg, TEXT("..."),
NULL, NULL, hInstance, NULL);
while ( GetMessage(&msg, NULL, 0, 0) )
LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
static int cxClient, cyClient;
switch ( message )
cxClient = LOWORD (lParam);
cyClient = HIWORD (lParam);
hdc = BeginPaint(hwnd, &ps);
SetViewportOrgEx(hdc, cxClient / 2, cyClient / 2, NULL);
SetWindowExtEx(hdc, 1, 1, NULL);
SetViewportExtEx(hdc, 5, -5, NULL);
return DefWindowProc(hwnd, message, wParam, lParam);