After already use SetWindowRgn function:
Can see out the window style has changed a lot, border becomes particularly coarse, style also becomes a classical Windows style, the key is I also found that the size of the window changes a little bit, is this why? Is there any way to avoid it?
The code is as follows:
HWnd2=CreateWindowExW (0, szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, 100, 100, 500, 500, nullptr, nullptr, hInstance, nullptr);
HRgn=CreateRoundRectRgn (0, 0, 500, 500, 50, 50);
SetWindowRgn (hWnd2 hRgn, FALSE);
The CloseHandle (hRgn);
ShowWindow (hWnd2, nCmdShow);
UpdateWindow (hWnd2);
CodePudding user response:
After a successful call to SetWindowRgn, the operating system owns the region specified by the region handle hRgn. The operating system does not make a copy of the region, so do not make any further function calls with this region handle, and do not close this region handle.CodePudding user response:
ExampleVoid CTransDlgDlg: : OnButton1 ()
{
//TODO: Add your the control notification handler code here
The static BOOL sw=FALSE;
if(! Sw)
{
Sw=TRUE;
CRect rcWin;
GetWindowRect (& amp; RcWin);
//
CRect rcClt;
GetClientRect (& amp; RcClt);
//rcClt. DeflateRect (20, 20);
The ClientToScreen (rcClt);
RcClt. OffsetRect (- rcWin. Left - rcWin. Top);
//
Int offX=rcClt. Left;
Int offY=rcClt. Top;
RcWin. OffsetRect (- rcWin. Left - rcWin. Top);
//
CRgn TMP.
TMP. CreateRectRgnIndirect (& amp; RcClt);
//client - CTRLS
RgnSubtractCtrls (TMP, offX offY);
//finally
CRgn RGN.
RGN. CreateRectRgnIndirect (& amp; RcWin);
Rgn.Com bineRgn (& amp; RGN, & amp; TMP, RGN_DIFF);
DeleteObject (TMP);
//
SetWindowRgn (RGN, TRUE);
M_Trans. SetWindowText (" opaque ");
}
The else
{
Sw=FALSE;
SetWindowRgn (0, TRUE);
M_Trans. SetWindowText (" transparent ");
}
}
CodePudding user response: