VC + + dialog box (CDialog) Full screen display and control center display

Source: Internet
Author: User

In writing some software, we tend to prefer a more concise, fresh user interface, and in order to avoid other programs or desktops and other effects on the attention of users, we are usually accustomed to the software interface full screen, the entire display screen, at the same time, we will be the interface in the control of the location of the corresponding adjustment, Let them be centered by the size of the screen and its relative position in the dialog box.

The following is a description of the example (the full instance can be downloaded in my CSDN resource:

In the initialization function OnInitDialog () of the dialog box, the following actions are done in three steps:

(1) Get the screen resolution

int Nfullwidth=getsystemmetrics (sm_cxscreen); int nfullheight=getsystemmetrics (Sm_cyscreen);

(2) Control center display

CRect c1,c2; GetClientRect (C1); Gets the coordinates for the window client area for (int i=idc_button1;i<=idc_button5;i++) {    GetDlgItem (i)->getwindowrect (C2); Gets the size of the bounding rectangle of the window    screentoclient (C2);//The screen coordinates of the specified point on the screen are converted to user coordinates    GetDlgItem (i)->setwindowpos (NULL, ( Nfullwidth-c1.right)/2+c2.left, (Nfullheight-c1.bottom)/,0,0,swp_nozorder| swp_nosize);}

(3) Full Screen display of dialog box (title bar removed)

CRect M_fullscreenrect; CRect Windowrect; GetWindowRect (&windowrect); CRect Clientrect; RepositionBars (0, 0xFFFF, Afx_idw_pane_first, Cwnd::reposquery, &clientrect); ClientToScreen (&clientrect); m_fullscreenrect.left=windowrect.left-clientrect.left;;m_fullscreenrect.right=windowrect.right-clientrect.right+nfullwidth;m_ Fullscreenrect.bottom=windowrect.bottom-clientrect.bottom+nfullheight; Windowplacement wndpl;wndpl.length=sizeof (windowplacement); wndpl.flags=0;wndpl.showcmd=sw_shownormal; Wndpl.rcnormalposition=m_fullscreenrect; SetWindowPlacement (&WNDPL);

VC + + dialog box (CDialog) Full screen display and control center display

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: 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.