blob: acf27755df9ac5d760454aabe9c525726d5740e3 [file] [log] [blame]
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
19// Helper class used to obtain information about a particular monitor.
20// This class wraps the Windows MONITORINFOEX ASCII structure, providing
21// methods that can safely be called on both multi-monitor aware systems
22// and older "legacy" systems.
23
24
25#ifndef __RFB_WIN32_MONITORINFO_H__
26#define __RFB_WIN32_MONITORINFO_H__
27
28#include <windows.h>
29#ifdef MONITOR_DEFAULTTONULL
30#define RFB_HAVE_MONITORINFO
31#endif
32
33namespace rfb {
34 namespace win32 {
35
36 // Structure containing info on the monitor nearest the window.
37 // Copes with multi-monitor OSes and older ones.
38#ifdef RFB_HAVE_MONITORINFO
39 struct MonitorInfo : MONITORINFOEXA {
40#else
41 struct MonitorInfo {
42 DWORD cbSize;
43 RECT rcMonitor;
44 RECT rcWork;
45 DWORD dwFlags;
46 char szDevice[1]; // Always null...
47#endif
48
49 // Constructor: Obtains monitor info for the monitor that has the
50 // greatest overlap with the supplied window or rectangle.
51 MonitorInfo(HWND hwnd);
52 MonitorInfo(const RECT& r);
53
54 // Constructor: Obtains monitor info for the name monitor. Monitor
55 // names should be those obtained from the MonitorInfo
56 // szDevice field, and usually look like "\\.\DISPLAY<n>"
57 MonitorInfo(const char* devName);
58
59 // Move the specified window to reside on the monitor.
60 void moveTo(HWND handle);
61
62 // Clip the specified rectangle or window to the monitor's working area.
63 // The rectangle/window is moved so that as much as possible resides
64 // on the working area of the monitor, and is then intersected with it.
65 void clipTo(HWND handle);
66 void clipTo(RECT* r);
67 };
68
69 };
70};
71
72#endif