The implementation of an elliptical form

Source: Internet
Author: User

The code-run effect is shown below:

I'll introduce the implementation of this program in three parts:

1. Generates an elliptical graphical interface, and writes italic-colored child and mouse drag on it.

2. Add the right mouse button menu and implement the feature that always covers the front and other programs automatically.

3. Generates a global hook for the mouse, intercepts mouse events, and returns the value of * * * *.

1. Generates an elliptical graphical interface and writes italic colored children above.

In the VC integrated compilation environment, select File, New, and then select the Project tab. Select "MFC Appwizard[exe]" in the project selection on the left, and enter "Ellipsewindow" in the edit box under the project title on the right.

Click the OK button to go to the MFC AppWizard step-1 Selection page, select the radio button on the left of the D Basic dialog box, set the application type to the basic dialog, and click OK when you click the "Finish" button.

In the automatically generated Idd_ellipsewindow_dialog dialog resource, delete the Cancel, OK button, and the text box titled "TODO: Set dialog here." At this point, the compilation runs this program, should be able to pop up an empty dialog box in the window.

The implementation of elliptic forms is mainly achieved by CRGN classes.

1. 1 Generating an oval form

In the definition of class Cellipsewindowdlg, add the protected variable of CRgn M_rgnwnd. In Cellipsewindowdlg::oninitdialog (), add the following code:

CRect rc;
GetClientRect(rc);
m_rgnWnd.CreateEllipticRgn(rc.left+32,rc.top+32,rc.Width()-64,rc.Height()-20);
SetWindowRgn((HRGN)m_rgnWnd,TRUE);

When you run this program, a gray oval form appears. If you cannot close this application, you can use ALT+F4 to close this program.

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.