再 谈 Win32 窗口 去除标题栏以及所有的边框
使用 Rgn 来去除标题栏以及所有的边框
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
RECT rc;
int edgeX;
int edgeY;
hWnd = CreateWindow(szWindowClass, "Win32Tab", WS_SYSMENU,//WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
#if 1
//创建无边框无标题栏窗体区域
GetWindowRect(hWnd,&rc);//
OffsetRect(&rc,-rc.left,-rc.top);
edgeX=GetSystemMetrics(SM_CXDLGFRAME);// 3
edgeY=GetSystemMetrics(SM_CYDLGFRAME);// 3
rc.top=GetSystemMetrics(SM_CYCAPTION);// 21
HRGN wndRgn;
wndRgn=CreateRectRgn(rc.left+edgeX,rc.top+edgeY,rc.right-edgeX,rc.bottom-edgeY);
SetWindowRgn(hWnd,wndRgn,1);
#endif
//
g_btn1=CreateBT(hWnd,10, 160, 80, 24,IDC_BUTTON);// pages
g_btn2=CreateBT(hWnd,82, 4, 14,14,IDC_BUTTON1);// close
//
g_pages[0]=CreateDialog(hInstance, MAKEINTRESOURCE(IDD_PROPPAGE1), hWnd, PageProc1);
g_pages[1]=CreateDialog(hInstance, MAKEINTRESOURCE(IDD_PROPPAGE2), hWnd, PageProc2);
g_pages[2]=CreateDialog(hInstance, MAKEINTRESOURCE(IDD_PROPPAGE3), hWnd, PageProc3);
ShowWindow(g_pages[0],SW_SHOW);
//
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}