In Windows, this problem is often encountered. Check whether an application is in full screen status. If yes, you need to perform some special actions.
I tried different methods,
Method 1: Check the hwnd of the four corners to see if they are in the same window. Normally, an application such as the player is in full screen with a progress control bar, as a result, four corners belong to two different windows.
Method 2: register the desktop toolbars. When a full screen program is opened or closed, there will be an abn_fullscreenapp Message notification, which can be processed after it is received.
The two methods are listed below:
Method 1:
bool IsFullScreen(){ HWND pWnd1 = NULL; HWND pWnd2 = NULL; HWND pWnd3 = NULL; HWND pWnd4 = NULL; int iCx=GetSystemMetrics(SM_CXSCREEN); int iCy=GetSystemMetrics(SM_CYSCREEN); POINT pt1; pt1.x = 1; pt1.y = 1; POINT pt2; pt2.x = 1; pt2.y = iCy-1; POINT pt3; pt3.x = iCx-1; pt3.y = 1; POINT pt4; pt4.x = iCx-1; pt4.y = iCy-1; pWnd1 = WindowFromPoint(pt1); pWnd2 = WindowFromPoint(pt2); pWnd3 = WindowFromPoint(pt3); pWnd4 = WindowFromPoint(pt4); if (pWnd1 == pWnd2 && pWnd2 == pWnd3 && pWnd3 == pWnd4) { return true; } return false;}
In fact, except for full screen of IE, none of the above methods have been tried successfully.
Method 2:
// Take dialog as an example. xdlg. hclass cxdlg {//... appbardata m_abd; //...}; xdlg. cpp
#define UM_APPBARIDWM_USER+1BEGIN_MESSAGE_MAP(cxdlg, CDialogEx)// ... ON_WM_POWERBROADCAST()// ...END_MESSAGE_MAP()BOOL cxdlg::OnInitDialog(){// ...memset(&m_abd, 0, sizeof(APPBARDATA));m_abd.cbSize = sizeof(APPBARDATA); m_abd.hWnd = this->m_hWnd;m_abd.uCallbackMessage = UM_APPBARID; ::SHAppBarMessage(ABM_NEW, &m_abd); // ...}LRESULT cxdlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam){// TODO: Add your specialized code here and/or call the base classif (UM_APPBARID == message) {TRACE(TEXT("==><== Get UM_APPBARID ... /n"));switch((UINT)wParam) { case ABN_FULLSCREENAPP: {if (TRUE == (BOOL)lParam){TRACE(TEXT("GetFullScreen On/n"));}else{TRACE(TEXT("GetFullScreen Off/n"));}}break;default:break;} }
return CDialogEx::WindowProc(message, wParam, lParam);}