Determine whether the current window is a full screen version of the cottage and official version

Source: Internet
Author: User

 

The version is very powerful:

I have used this to obtain the handle of the four vertices on the screen (a pixel can be cut to the center of the screen during the detection, for example, the handle of the window where instead, if the four handles are the same, they are regarded as full screen. In fact, there is a problem. Some programs will pop up in full screen mode, such as playing software. In full screen mode, there is also a toolbar below, which is different from the playing window below, so the detection fails. To enhance this method, obtain the process PID of the four vertex windows. If the PID is the same, it is regarded as full screen, but there is still a problem, when detecting explorer, it is regarded as full screen. In short, the implementation is simple, but inaccurate, and is not recommended.

 

Recommended official practices:

Registering An appbar (desktop toolbar) is a window similar to a job bar in Microsoft Windows. It is close to the edge of the screen. A typical desktop toolbar includes buttons for quick access to other applications and windows. The system prevents other applications from using the area occupied by AppBar. The desktop can coexist with multiple appbars at any time.

APIs used:

Shappbarmessage

Winshellapi uint apientry shappbarmessage (

DWORD dwmessage,

Pappbardata pdata );

This API can send An appbar message (dwmessage) to the system, which has many messages and can be viewed by msdn. Then, the system returns the information you want to know through pdata, here we mainly use this API to register a new AppBar. Here, you need to pay attentionAppbardataThis struct.

 

The specific implementation of full screen detection.

The following code registers An appbar by calling shappbarmessage (abm_new, & Abd:

Appbardata Abd; <br/> memset (& Abd, 0, sizeof (ABD); </P> <p> // specify the structure size and handle to the AppBar. <br/> Abd. cbsize = sizeof (appbardata); <br/> Abd. hwnd = hwndaccessbar; </P> <p> Abd. ucallbackmessage = msg_appbar_msgid; </P> <p>! : Shappbarmessage (abm_new, & Abd );

Note that msg_appbar_msgid is the message id defined by you. When a full screen is created or canceled, a message whose ID is msg_appbar_msgid will be sent to the window with the handle of hwndaccessbar, for full-screen messages, wparam is abn_fullscreenapp, while lparam can determine whether a window is full screen or a window is canceled. (bool) lparam is true, indicating that a window is full screen, if the value of (bool) lparam is false, a window is canceled in full screen. The Code is as follows:

Lresult cwinhook: windowproc (uint MSG, wparam WP, lparam LP) <br/>{< br/> If (msg_appbar_msgid = MSG) <br/>{< br/> switch (uint) WP) <br/>{< br/> case abn_fullscreenapp: <br/> {<br/> If (true = (bool) LP) <br/>{< br/> trace (text ("a window is full screen/N"); <br/> kappbarmsg: m_bfullscreen = true; <br/>}< br/> else <br/> {<br/> trace (text ("A Window cancels full screen/N ")); <br/> kappbarmsg: m_bfullscreen = false; <br/>}< br/> break; <br/> default: <br/> break; <br/>}</P> <p> return csubclasswnd: windowproc (MSG, WP, LP); <br/>}

Note: Later I found that Vista is not as sensitive as XP, and I don't know what's going on. Vista occasionally fails, which is strange.

 

Refer to msdn2005:

Appbardata Structure
MS-help: // Ms. msdnqtr. v80.en/ms. msdn. v80/ms. win32com. v10.en/shellcc/platform/Shell/reference/structures/appbardata.htm

Abm_new message
MS-help: // Ms. msdnqtr. v80.en/ms. msdn. v80/ms. win32com. v10.en/shellcc/platform/Shell/reference/messages/abm_new.htm

Abn_fullscreenapp notification
MS-help: // Ms. msdnqtr. v80.en/ms. msdn. v80/ms. win32com. v10.en/shellcc/platform/Shell/reference/messages/abn_fullscreenapp.htm

 

 

 

 

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.