The following are three methods for implementing the multi-angle rectangle of the program window rounded corner, but the effect is relatively poor. Simply cutting corners
Cut, you can see from the border and the title bar. However, you can use these three functions to learn
Setjavaswrgn () and create an hrgn.
Method 1
void SetWindowEllipseFrame1(HWND hwnd, int nWidthEllipse, int nHeightEllipse){HRGN hRgn;RECT rect;GetWindowRect(hwnd, &rect);hRgn = CreateRoundRectRgn(0, 0, rect.right - rect.left, rect.bottom - rect.top, nWidthEllipse, nHeightEllipse);SetWindowRgn(hwnd, hRgn, TRUE);}
Method 2
Void setwindowellipseframe2 (hwnd, int nwidthellipse, int partition) {hrgn; rect; HDC, hdcmem; HDC = getdc (hwnd); hdcmem = createcompatibledc (HDC ); releasedc (hwnd, HDC); getwindowrect (hwnd, & rect); beginpath (hdcmem); roundrect (hdcmem, 0, 0, rect. right-rect. left, rect. bottom-rect. top, nwidthellipse, nheightellipse); // draw a rounded rectangle. Endpath (hdcmem); hrgn = pathtoregion (hdcmem); // Finally, convert the path to a region. Setjavaswrgn (hwnd, hrgn, true );}
Method 3
Void setwindowellipseframe3 (hwnd, int nwidthellipse, int nheightellipse) {hrgn; rect; int nheight, nwidth; getwindowrect (hwnd, & rect); nheight = rect. bottom-rect. top; // calculate the nwidth = rect. right-rect. left; // calculate the width of point [8] = {0, nheightellipse}, // left-top {nwidthellipse, 0 }, // left-top-left {nwidth-nwidthellipse, 0}, {nwidth, nheightellipse}, // right-top {nwidth, nheight-nheightellipse }, // right-bottom-right {nwidth-nwidthellipse, nheight}, // right-bottom {nwidthellipse, nheight}, // left-bottom {0, nheight-nheightellipse }}; hrgn = createpolygonrgn (point, 8, winding); set1_wrgn (hwnd, hrgn, true );}
Next, describe setjavaswrgn ().
1. the coordinates of a window's window region are relative to the upper-left corner of the window, not the client area of the window.
The RGN Coordinate System of the window is not the screen coordinate, but starts from the upper left corner of the window.
2. after a successful call to setmediawrgn, the system owns the region specified by the region handle hrgn. the system does not make a copy ofthe region. thus, you shoshould not make any further function CILS withthis region handle. in particle, do not delete this region handle. thesystem deletes the region handle when it no longer needed.
After setdomainwrgn () is set successfully, the system will take over the hrgn handle.
Call method Win32 can be called in wm_createt and wm_initdialog message processing. The MFC program can be called in oninitdialog. For example:
Setwindowellispeframe1 (hwnd, 50, 50)
Or setwindowellispeframe1 (this-> getsafehwnd (), 50, 50 );
I would like to express my thanks for your reference to the code on the Internet.