VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/platform/win/VBoxUtils-win.cpp@ 74942

Last change on this file since 74942 was 71784, checked in by vboxsync, 6 years ago

FE/Qt: bugref:9049: VBoxGlobal library fixes for Windows.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1/* $Id: VBoxUtils-win.cpp 71784 2018-04-09 15:56:21Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - Declarations of utility classes and functions for handling Windows specific tasks.
4 */
5
6/*
7 * Copyright (C) 2010-2018 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/* GUI includes: */
19#include "VBoxUtils-win.h"
20
21
22/** Namespace for native window sub-system functions. */
23namespace NativeWindowSubsystem
24{
25 /** Enumerates visible always-on-top (top-most) windows. */
26 BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam);
27 /** Contains visible top-most-window rectangles. */
28 QList<QRect> topMostRects;
29}
30
31BOOL CALLBACK NativeWindowSubsystem::EnumWindowsProc(HWND hWnd, LPARAM)
32{
33 /* Ignore NULL HWNDs: */
34 if (!hWnd)
35 return TRUE;
36
37 /* Ignore hidden windows: */
38 if (!IsWindowVisible(hWnd))
39 return TRUE;
40
41 /* Get window style: */
42 LONG uStyle = GetWindowLong(hWnd, GWL_STYLE);
43 /* Ignore minimized windows: */
44 if (uStyle & WS_MINIMIZE)
45 return TRUE;
46
47 /* Get extended window style: */
48 LONG uExtendedStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
49 /* Ignore non-top-most windows: */
50 if (!(uExtendedStyle & WS_EX_TOPMOST))
51 return TRUE;
52
53 /* Get that window rectangle: */
54 RECT rect;
55 GetWindowRect(hWnd, &rect);
56 topMostRects << QRect(QPoint(rect.left, rect.top), QPoint(rect.right - 1, rect.bottom - 1));
57
58 /* Proceed to the next window: */
59 return TRUE;
60}
61
62const QRegion NativeWindowSubsystem::areaCoveredByTopMostWindows()
63{
64 /* Prepare the top-most region: */
65 QRegion topMostRegion;
66 /* Initialize the list of the top-most rectangles: */
67 topMostRects.clear();
68 /* Populate the list of top-most rectangles: */
69 EnumWindows((WNDENUMPROC)EnumWindowsProc, 0);
70 /* Update the top-most region with top-most rectangles: */
71 for (int iRectIndex = 0; iRectIndex < topMostRects.size(); ++iRectIndex)
72 topMostRegion += topMostRects[iRectIndex];
73 /* Return top-most region: */
74 return topMostRegion;
75}
76
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use