VC to determine whether the specified window is obscured by other windows

Source: Internet
Author: User

Originally is to determine whether the current window is in the front, helpless means exhausted is not, so want to change the idea: To determine whether the specified window is obscured by other windows. Then dig the net three feet, found this:

BOOL Ctesttray2dlg::iscoveredbyotherwindow (HWND hwnd)
{
RECT Rctarget;
:: GetWindowRect (HWnd, &rctarget);

BOOL IsChild = (Ws_child = = (:: GetWindowLong (HWnd, Gwl_style) & Ws_child));

if (:: GetDesktopWindow () = = hWnd)
HWnd =:: GetWindow (:: Gettopwindow (HWnd), gw_hwndlast);

do{
HWND Hcurwnd = hwnd;

while (NULL! = (hwnd =:: Getnextwindow (hwnd, Gw_hwndprev))) {
if (:: IsWindowVisible (hWnd)) {
RECT Rcwnd;
:: GetWindowRect (HWnd, &rcwnd);

if (! ( (Rcwnd.right < rctarget.left) | | (Rcwnd.left > Rctarget.right) | |
(Rcwnd.bottom < rctarget.top) | | (Rcwnd.top > Rctarget.bottom))) {
return true;
}
}
}

if (ischild) {
HWnd =:: GetParent (Hcurwnd);
IsChild = hWnd? (Ws_child = = (:: GetWindowLong (HWnd, Gwl_style) & Ws_child)): false;
}
Else
Break
}while (TRUE);

return false;
}

The main idea is to traverse the window from the bottom up layer to check if there are any overlapping windows with the specified window.

Try it, it's OK. Reluctantly solved a problem, thank netizens: Pear (Crabshai)

And his good stickers: http://topic.csdn.net/u/20081007/23/4c84494d-6caa-4eb2-a2c4-2f73c67e8a63.html

http://blog.csdn.net/yuvmen/article/details/4546427

VC to determine whether the specified window is obscured by other windows

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.