{SOLVED: found another option SM_C(X/Y)(FIXED/SIZE)FRAME}Hi. I'm trying to create a Clock Application and I'm clipping my window in a circle. But somehow, 1 pixel row of the caption and pixel coloumn of the left border is NOT being clipped out. What am I doing wrong here?
I obtained the caption height, border height & border width from GetSystemMetrics() (SM_CYCAPTION, SM_CYEDGE, SM_CXEDGE).
But SM_C(X/Y)EDGE gives me a value of 2 while acually my border is 3 pixels wide (WS_EX_WINDOWEDGE style). This is why my caption and left border are showing.
Is there some other SM_C(X/Y) value which will give me the correct border width?
P.S. I tried substituting SM_C(X/Y)BORDER instead of EDGE. But It gives a value of 1 rather than 2 or 3 !
P.S. Yes, this can be rectified by simply adding a '+1' to the values but then I would be hard coding the values which i'm trying to avoid.
Heres' the simplified code strped to bare minimum(?):
The caption & border are seen as yellow below:Code:#include<windows.h> #include"../clock/res.h" LRESULT CALLBACK MainProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam){ switch(Msg){ case WM_CREATE: { int border_width = GetSystemMetrics(SM_CXEDGE), border_height = GetSystemMetrics(SM_CYEDGE), title_height = GetSystemMetrics(SM_CYCAPTION); HRGN hRgn = CreateEllipticRgn(0, 0, 200, 200); OffsetRgn(hRgn, border_width, title_height + border_width); if( !hRgn ) break; SetWindowRgn(hWnd, hRgn, TRUE); DeleteObject(hRgn); } break; case WM_DESTROY: { PostQuitMessage(0); } break; } return DefWindowProc(hWnd, Msg, wParam, lParam); } int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nCmdShow ) { WNDCLASSEX WndCls; WndCls.cbSize = sizeof(WNDCLASSEX); WndCls.style = 0; WndCls.lpfnWndProc = MainProc; WndCls.cbClsExtra = 0; WndCls.cbWndExtra = 0; WndCls.hInstance = hInst; WndCls.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICONSM)); WndCls.hIconSm = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICONSM)); WndCls.hCursor = LoadCursor(NULL, IDC_ARROW); WndCls.hbrBackground = HBRUSH( COLOR_DESKTOP + 1); WndCls.lpszMenuName = NULL; WndCls.lpszClassName = "MainClass"; if( !RegisterClassEx(&WndCls) ){ MessageBox(NULL, "Error Registering Class", "Exiting...", MB_OK); return 1; } HWND hWnd = CreateWindowEx(WS_EX_WINDOWEDGE, "MainClass", "Clock", WS_SYSMENU | WS_MINIMIZEBOX, 0, 0, //CW_USEDEFAULT, CW_USEDEFAULT, 210, 250, NULL, NULL, hInst, NULL); if( !hWnd ){ MessageBox(NULL, "Error Creating Window", "Exiting...", MB_OK); return 1; } ShowWindow(hWnd, SW_SHOW); MSG Msg; while( GetMessage(&Msg, NULL, 0, 0) > 0 ){ TranslateMessage(&Msg); DispatchMessage(&Msg); } return 0; }
Attachment 6711



LinkBack URL
About LinkBacks


