Switch between full-screen and non-full-screen APS

Source: Internet
Author: User
On csdn, I see a lot of questions about how to implement it on PPC. Program Full Screen. I have collected and sorted it out here. Post the information that I passed the test. Code .

1. Full Screen

Rect RC;
Setrect (& rc, 0, 0, getsystemmetrics (sm_cxscreen), getsystemmetrics (sm_cyscreen ));
: Movewindow (m_hwnd, RC. Left, RC. Top, RC. Right, RC. Bottom, true );
: Shfullscreen (m_hwnd, shfs_hidetaskbar | shfs_hidesipbutton | shfs_hidestarticon );
You can add the above Code to your message response function in full screen mode, with no Start Menu or input method.

2. Restore normal display

Rect RC;
Setrect (& rc, 0, 0 + getsystemmetrics (response), getsystemmetrics (sm_cxvirtualscreen), getsystemmetrics (sm_cyvirtualscreen)-getsystemmetrics (sm_cymenu)-getsystemmetrics (response) + 3 ); // There is a "+ 3" here.
: Movewindow (m_hwnd, RC. Left, RC. Top, RC. Right, RC. Bottom, true );
: Shfullscreen (m_hwnd, shfs_showtaskbar | shfs_showsipbutton | shfs_showstarticon );

The comments in the Code are to deal with the customer area height is not enough, there will be a black line below, who have a better way to communicate.

3. Display and hide menus.

// Create a menu
Shmenubarinfo MBI;
Memset (& MBI, 0, sizeof (shmenubarinfo ));
MBI. cbsize = sizeof (shmenubarinfo );
MBI. dwflags = shcmbf_hmenu;
MBI. hwndparent = m_hwnd;
MBI. ntoolbarid = idr_menubar1;
MBI. hinstres = _ module. getmoduleinstance ();
Shcreatemenubar (& MBI );

// Hide the menu
Hwndhwndmb = shfindmenubar (m_hwnd );
: Showwindow (hwndmb, sw_hide); // This is written as: showwindow (hwndmb, sw_showmaximized). The full screen menu is displayed, haha.

// Restore the display of the menu
: Showwindow (hwndmb, sw_show );
When the restore menu is displayed, the menu handle hwndmb can only be obtained from the above. If shfindmenubar (m_hwnd) is used here, a null value is obtained. I guess this is because it is hidden.

About full screen. There are some code snippets on csdn.

You need to add it during DLG initialization.

Shinitdlginfo Shidi;
Zeromemory (& Shidi, sizeof (Shidi ));
Shidi. dwmask = shidim_flags;
Shidi. dwflags = shidif_fullscreennomenubar | shidif_sipdown;
Shidi. hdlg = m_hwnd;
If (! Shinitdialog (& Shidi ))
{
Return false;
}
This code can also be used. However, I prefer the above two sections of code. Haha

 

-------- The following text is supplemented by 2008.10.6 ----------

Today, we try to implement a lockscreen by using a false/transparent full screen window. It is found that the full screen is a little problematic.

1. directly execute the Code listed above in the DLG or view. The Start menu bar at the top of the mobile phone screen cannot be hidden. When a form is created, a message is sent to the form itself. The preceding problem can be solved by simulating a button message.

2. When the form is full-screen and false-transparent, you can find a way to remove the close button on the far right of the menu bar. I found it on csdn. Find two lines of code:

: Shdonebutton (m_hwnd, shdb_hide );
Modifystyle (ws_caption, ws_minimizebox, swp_nosize );

The test shows that the button in the upper right corner can be hidden successfully.

---------- The following text is supplemented by 2008.10.7 -----------

Today, I tested the above code in an MFC DLG project. The menu bar below is always unavailable. The menu bar or toolbar is not created in my code!
I carefully read the cdialog code. Something found

// Delete the menu bar, which is actually a tool bar ccontrolbar *
M_pwndemptycb-> destroywindow ();
Delete m_pwndemptycb;
M_pwndemptycb = NULL;

// Hide the input method button. Remember to restore it after the program exits. Haha
Cwnd * hwndtaskbar = findwindow (text ("ms_sipbutton"), null );
Hwndtaskbar-> showwindow (sw_hide );

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.