I. Full Screen Display in simple dialog box
Add the following to oninitdialog:
1. modifystyle (ws_caption, 0, 0); // if you do not want to remove the title bar, remove this sentence.
Sendmessage (wm_syscommand, SC _maximize, 0); // the taskbar is not displayed.
Showwindow (sw_maximize); // display the taskbar
2. showwindow (sw_showmaximized );
2. The full screen display method of the complex dialog box is adjusted according to the screen resolution
Void cmainframe: onfullscreen ()
{
Getwindowplacement (& m_oldwndplacement );
Crect windowrect;
Getwindowrect (& windowrect );
Crect clientrect;
Repositionbars (0, 0 xFFFF, afx_idw_pane_first, reposquery, & clientrect );
Clienttoscreen (& clientrect );
// Obtain the screen resolution
Int nfullwidth = getsystemmetrics (sm_cxscreen );
Int nfullheight = getsystemmetrics (sm_cyscreen );
// Display the customer area except the control bar in full screen from (0, 0) to (nfullwidth, nfullheight,
// Expand the original window and
// The difference between the customer's location to obtain the window position displayed in full screen
M_fullscreenrect.left = windowrect. left-ClientRect.left;
M_fullscreenrect.top = windows. top-ClientRect.top;
M_fullscreenrect.right = windowrect. right-ClientRect.right + nfullwidth;
M_fullscreenrect.bottom = windowrect. bottom-ClientRect.bottom + nfullheight;
M_bfullscreen = true; // set the full-screen display flag to true.
// Enter the full screen display status
Windowplacement wndpl;
Wndpl. Length = sizeof (windowplacement );
Wndpl. Flags = 0;
Wndpl. showcmd = sw_shownormal;
Wndpl. rcnormalposition = m_fullscreenrect;
Setwindowplacement (& wndpl );
}
3. Move the full screen dialog box and button control to the corresponding position
Void cxxxdlg: onlbuttondown (uint nflags, cpoint point)
{
Int Cx =: getsystemmetrics (sm_cxscreen );
Int Cy =: getsystemmetrics (sm_cyscreen );
Crect rtclient, rtbtn;
Cwnd * pwnd = getdlgitem (idc_button );
Getclientrect (& rtclient); // obtain the screen coordinates of the client area in the dialog box.
Clienttoscreen (& rtclient); // map to screen coordinates
Pwnd-> getwindowrect (& rtbtn); // obtain the screen coordinate of the button
Int Lx = rtbtn. Width (); // button Length
Int Ly = rtbtn. Height (); // button height
Int dx = rtclient. right-rtBtn.right; // distance from the Right Border
Int DY = rtclient. bottom-rtBtn.bottom; // distance from the bottom border
Movewindow (crect (0, 0, CX, CY); // move the window
Pwnd-> movewindow (crect (CX-DX-lx, cy-ly-dy, CX-dx, cy-dy); // move the button
Cdialog: onlbuttondown (nflags, point );
}
4. Specify the dialog box in the design status to be displayed in full screen.
1. Manually drag it like 1024x768, and then Alt + V u
2. modify it in the *. RC file, but the unit is different.
5. Use the movewindow or setwindowpos full screen dialog box
Calculate the size of the customer zone getclientrect ();
Calculate the size of the entire window. getwindowrect ();
Then get the current screen size getsystemmetrics ();
Finally, convert the three data based on the size of the window when the customer area is the screen size;
Call movewindow after calculation.
Article Source: http://www.diybl.com/course/3_program/c++/cppsl/2008315/104723.html