Sometimes I see someone asking how can I tell if a window is currently in full screen?
But before solving this problem, let's solve a simple problem.
What is fullscreen?
Quite a few people think: if the window is maximized, then it is maximized? Is that true? It's bs!.
Full screen means that the overall size of the window occupies at least the entire screen, not just a portion of the space except the taskbar!
Maximizing is the window's overall size, which occupies the desktop's workspace (workarea)!
Therefore, do not simply call iszoomed () to determine whether the window is currently full-screen, that is to judge whether to maximize the act;
Also do not just compare the client area size and screen size of the window;
Also do not just compare the window's left and top if it is less than 0.
Can be judged in the following ways:
1#include <windows.h>2#include <iostream>3 4 BOOLCheckfullscreen ()5 {6 BOOLBfullscreen =false;7HWND hwnd =GetForegroundWindow ();8 RECT Rcapp, Rcdesk;9GetWindowRect (GetDesktopWindow (), &rcdesk);Ten if(Hwnd!=getdesktopwindow () && hwnd!=Getshellwindow ()) { OneGetWindowRect (HWnd, &Rcapp); A if(rcapp.left<=Rcdesk.left -&& rcapp.top<=Rcdesk.top -&& rcapp.right>=Rcdesk.right the&& rcapp.bottom>=rcdesk.bottom) - { -Bfullscreen =true; - } + } - returnBfullscreen; + } A at intMain () - { - for(;;) { -Std::cout << (checkfullscreen)?"have a":"No") <<"window full Screen ~\n"; -Sleep ( +); - } in return 0; -}
Reference:
Http://stackoverflow.com/questions/7009080/detecting-full-screen-mode-in-windows
http://bbs.csdn.net/topics/390838652#post-397826207