VC Creating rounded corners form 2

Source: Internet
Author: User

In order to achieve the round corner of the dialog window, here the main use of two functions,

CreateRoundRectRgn, and SetWindowRgn.

The program first obtains the window rectangle through the GETWINDOWRGN function, then creates a rounded rectangle through the CREATEROUNDRECTRGN function, and finally changes the window shape through the SETWINDOWRGN function.


Here's how:

1 Open "Class View", right click "CMyDlg", a menu appears, select "AddWindow Message Handler ..."

After 2, in "New Windows messages\events", double-click "OnSize", "OK"

The 3 editing functions are as follows:

void Cmydlg::onsize (UINT nType, int cx, int cy) {cdialog::onsize (NType, CX, CY);//Todo:add your message handler code here CRGN M_rgn; CRect RC; GetWindowRect (&RC); rc-=rc. TopLeft (); M_rgn. CreateRoundRectRgn (rc.left,rc.top,rc.right,rc.bottom,100,100); SetWindowRgn (m_rgn,true);}

The other windows are basically the same operation, follow this action

The results of the operation are as follows:


VC Creating rounded corners form 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.