1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 2000
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
39 // We have to do this in order to have access to the multiple-monitor
40 // APIs that are only defined when WINVER is >= 0x0500. Don't worry,
41 // these won't actually be called unless they are present.
46 #define _WIN32_WINNT 0x0500
48 #include "nsScreenWin.h"
53 nsScreenWin :: nsScreenWin ( void* inScreen
)
57 HDC hDCScreen
= ::GetDC(nsnull
);
58 NS_ASSERTION(hDCScreen
,"GetDC Failure");
59 NS_ASSERTION ( ::GetDeviceCaps(hDCScreen
, TECHNOLOGY
) == DT_RASDISPLAY
, "Not a display screen");
60 ::ReleaseDC(nsnull
,hDCScreen
);
63 // nothing else to do. I guess we could cache a bunch of information
64 // here, but we want to ask the device at runtime in case anything
69 nsScreenWin :: ~nsScreenWin()
71 // nothing to see here.
75 // addref, release, QI
76 NS_IMPL_ISUPPORTS1(nsScreenWin
, nsIScreen
)
80 nsScreenWin :: GetRect(PRInt32
*outLeft
, PRInt32
*outTop
, PRInt32
*outWidth
, PRInt32
*outHeight
)
86 info
.cbSize
= sizeof(MONITORINFO
);
87 success
= ::GetMonitorInfoW( (HMONITOR
)mScreen
, &info
);
89 *outLeft
= info
.rcMonitor
.left
;
90 *outTop
= info
.rcMonitor
.top
;
91 *outWidth
= info
.rcMonitor
.right
- info
.rcMonitor
.left
;
92 *outHeight
= info
.rcMonitor
.bottom
- info
.rcMonitor
.top
;
97 HDC hDCScreen
= ::GetDC(nsnull
);
98 NS_ASSERTION(hDCScreen
,"GetDC Failure");
100 *outTop
= *outLeft
= 0;
101 *outWidth
= ::GetDeviceCaps(hDCScreen
, HORZRES
);
102 *outHeight
= ::GetDeviceCaps(hDCScreen
, VERTRES
);
104 ::ReleaseDC(nsnull
, hDCScreen
);
112 nsScreenWin :: GetAvailRect(PRInt32
*outLeft
, PRInt32
*outTop
, PRInt32
*outWidth
, PRInt32
*outHeight
)
114 BOOL success
= FALSE
;
118 info
.cbSize
= sizeof(MONITORINFO
);
119 success
= ::GetMonitorInfoW( (HMONITOR
)mScreen
, &info
);
121 *outLeft
= info
.rcWork
.left
;
122 *outTop
= info
.rcWork
.top
;
123 *outWidth
= info
.rcWork
.right
- info
.rcWork
.left
;
124 *outHeight
= info
.rcWork
.bottom
- info
.rcWork
.top
;
130 ::SystemParametersInfo(SPI_GETWORKAREA
, 0, &workArea
, 0);
131 *outLeft
= workArea
.left
;
132 *outTop
= workArea
.top
;
133 *outWidth
= workArea
.right
- workArea
.left
;
134 *outHeight
= workArea
.bottom
- workArea
.top
;
144 nsScreenWin :: GetPixelDepth(PRInt32
*aPixelDepth
)
146 //XXX not sure how to get this info for multiple monitors, this might be ok...
147 HDC hDCScreen
= ::GetDC(nsnull
);
148 NS_ASSERTION(hDCScreen
,"GetDC Failure");
150 *aPixelDepth
= ::GetDeviceCaps(hDCScreen
, BITSPIXEL
);
152 ::ReleaseDC(nsnull
, hDCScreen
);
159 nsScreenWin :: GetColorDepth(PRInt32
*aColorDepth
)
161 return GetPixelDepth(aColorDepth
);