-
June 15th, 2010, 02:15 PM
#1
Detect Current Display/Screen
Hello,
I want to build a tiny application in Windows Vista. It should tell me, whether it (the application window itself) is displayed on the screen of a laptop or on an external screen. I'd like to use C++ in VisualStudio 08.
I seriously don't have a clue about programming for Windows, don't even know which way to approach this problem or which libraries to use. I would totally appreciate if someone of you guys/girls could help me out with a quick hint.
Cheers, Seb
-
June 15th, 2010, 02:24 PM
#2
Re: Detect Current Display/Screen
Victor Nijegorodov
-
June 15th, 2010, 05:47 PM
#3
Re: Detect Current Display/Screen
I am not sure you CAN tell which monitor is external.
The suggested GetMonitorInfo function will return a device (adapter) name like “\\.\DISPLAY1”. How would that help?
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
June 15th, 2010, 09:06 PM
#4
Re: Detect Current Display/Screen
Hi again, and thanks for both answers!
The Multiple Displays Monitor Functions was exactly what I was looking for, I hope..at least, it feels good. When I understood Vladimir right, you can't yet tell which monitor is external, since one could use the external monitor as primary display.
On the other hand, with making a WQL Query on the WmiMonitorConnectionParams (by stupidly altering about two lines of the example code as seen on http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx ), I can distinguish between an internal and an external display.
Well, now I'm not yet quite sure if I can map these both informations...or if i don't see the simple solution..
-
June 16th, 2010, 09:57 AM
#5
Re: Detect Current Display/Screen
Ok, I have to do it another way, because:
GetMonitorInfo gives me \\.\DISPLAY1
WMIMonitorID querying gives me sth. like DISPLAY\LGD0032\7&14066721&0&UID50331920_0
MonitorConnectionParams querying gives me 2147483648 for internal and sth. else for all external screens
that's pretty much it...i must have missed something, because this looks not too good for mapping, no clue how to proceed from there
anyone does?
-
June 16th, 2010, 12:28 PM
#6
Re: Detect Current Display/Screen
Originally Posted by SebGarcia
...MonitorConnectionParams querying gives me 2147483648 for internal and sth. else for all external screens
That is actually a pretty interesting result: 2147483648 is 0x8000000 in hex. The highest bit set in the result usually indicate some special condition. Could you possibly use that?
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
June 16th, 2010, 01:25 PM
#7
Re: Detect Current Display/Screen
yes, the 0x8000000 is the flag (http://msdn.microsoft.com/en-us/library/ff546605.aspx) for an internal display.
actually i have all the information i need, just the link is missing
* a window is positioned on \\.\DISPLAY1 or \\.\DISPLAY2 and this monitor is primary or not
* MISSING: \\.\DISPLAY1 == \DISPLAY\LGD0032\7&14066721&0&UID50331920_1 or
\DISPLAY\NEC6692\7&14066721&0&UID50331921_1
* \DISPLAY\..... is internal or external
and this is the problem...or..the challenge
tricky tricky
puh...more infos:
* WMIMonitorConnectionParams and WMIMonitorID classes give me an InstanceName "\DISPLAY\LGD0032\..." etc.
* EnumDisplayDevices and Victors GetMonitorInfo functions give me a DeviceName "\\.\DISPLAY1" etc.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|