topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 9:20 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: RFI: Win32 API or WMI means of manipulating multiple video displays/monitors.  (Read 18240 times)

tinjaw

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,927
    • View Profile
    • Donate to Member
Help me Obi-Wan KenCody!

Here is what I want to automate...
12-17-2007 12-16-27 PM.png

It just so happens that I was looking for a way to do this today via AutoIt (or something similar) and was in the middle of researching it, when one coworker walked up to another coworker at the desk next to mine and asked if he knew of a way to do the same thing I was researching. So, If you help me, you will be helping two more via proxy.  :Thmbsup:

Here is the simple scenario:
I have a laptop. Sometimes I am only using my laptop's build in display. Other times I have an external monitor connected and I want to "Extend my Windows desktop onto this monitor." so I can use both displays. I am getting tired of having to do this manually. And then manually again to reverse things.

I have found some info on MSDN, but it is only for getting/setting display resolutions. I can't track down the API or WMI calls that are behind the Display Properties dialog. At this point I may have to employ a Windows API spy program unless I can find some documentation.

Have any of you gurus come across this info in your travels?
« Last Edit: December 17, 2007, 12:30 PM by tinjaw »

Ralf Maximus

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 927
    • View Profile
    • Read more about this member.
    • Donate to Member
I've got a VB6 class that allows reading of the system monitors object collection, and I *think* it allows writing to it too.  I use it all the time in my projects, but only for determining the user's multi-monitor environment.

Let me look at the code and see if I can discern the underlying stuff it's calling.  If so, I'll provide a translation into generic APIese. 

Or are you fluent enough in VB6 for me to just post the class?

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Oh man this would be sooooooo cool!

I hate those dialogs, they are a complete mess, specialy if you have an ati card, which forces you to close and open that dialog several times each time you want to go from single screen to dual-screen.
I'll keep monitoring this thread ;)

tinjaw

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,927
    • View Profile
    • Donate to Member
Ralf,

Thanks. That would be a great help.

Or are you fluent enough in VB6 for me to just post the class?

I can read VB6 code. I learned to do that while working for Borland supporting Delphi. We would find examples in MSDN and port them over to Delphi.

tinjaw

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,927
    • View Profile
    • Donate to Member
Oh man this would be sooooooo cool!
If I get this working I will turn it into a Coding Snack for you jgpaiva.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
I think ultramon let's you set up different profiles like this and switch between them.

Ralf Maximus

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 927
    • View Profile
    • Read more about this member.
    • Donate to Member
Tinjaw,

There are two classes inside the .zip: Monitors.cls is the main control structure & procedures, while Monitor.cls is the object definition for the collection.  Reading thru the code suggests it does not accept new values; it's just providing data about the video configuration.  So in that regard it's not helpful, but still it might yield a clue.  The API calls utilized are:

GetMonitorInfo
MonitorFromWindow
MonitorFromRect
GetSystemMetrics

Basically upon initialization you end up with a collection of individual Monitor objects, one for each enumerated display.  You can determine just about everything from individual height + width to the total desktop real estate available.

I did not include a referenced file, MonitorPickerForm, as it's a simple graphical display showing the orientation/position/size of each monitor object, similar to your screenshot but cheesier.  Since you're not planning to compile this I figured it's not important.

Wish it was more,
Ralf

Ralf Maximus

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 927
    • View Profile
    • Read more about this member.
    • Donate to Member
I think ultramon let's you set up different profiles like this and switch between them.

Aye, that it does.

Is there anything UltraMon doesn't do?  Oh yeah... get along with nVidia Desktop Manager. 

Liquidmantis

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 64
    • View Profile
    • Donate to Member
Yeah, Ultramon will let you do it as easily as double-clicking on the systray icon (if you configure it for that action).  Plus you get a lot of other really nice multimonitor functions to boot.

My laptop actually handles this automatically when I plug/unplug the monitor signal cable.

tinjaw

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,927
    • View Profile
    • Donate to Member
Thanks Ralf, but I got the stuff I need to retrieve the info. I need the info to set it. But thanks to you guy mentioning UltraMon, I now have another place to look for help. UltraMon has a freely downloadable SDK with a help file and sample code. They require a licensing fee if you use their COM controls, but maybe I can find the few API calls I need in there somewhere.

If it is OK with you Mouser, maybe you can contact them and see if we can get a license that allows us to release Donationware (like Coding Snacks) at no cost.

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
You need to open display settings etc. just to extend to an external monitor? All the laptops I've seen have either had a nifty little hotkey for it, or it's been available through a right-click tray icon (intel GMA integrated graphics, at least).
- carpe noctem

tinjaw

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,927
    • View Profile
    • Donate to Member
Just FYI, at work they need this to handle laptops with a Matrox TripleHead2Go Analog setup. They can't trust students using the laptops to be able to properly configure them to use the Matrox and then back to standard use. They need a one-click solution.

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
You need to open display settings etc. just to extend to an external monitor? All the laptops I've seen have either had a nifty little hotkey for it, or it's been available through a right-click tray icon (intel GMA integrated graphics, at least).
Yep.The buton my laptop has, doesn't extend the screen, it clones the screen... And the ati drivers are so damn bad, that there's no option in the try menu for that (actually, there are no options at all, even though the icon is there taking space).

Maybe it's time to move to omega drivers or something like that.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
something similar to this was requested before but it would be great if you could get this to work sans UltraMon.. 8)

Liquidmantis

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 64
    • View Profile
    • Donate to Member
Yep.The buton my laptop has, doesn't extend the screen, it clones the screen...

That's strange.  Are you using the video drivers from the notebook manufacturer or ATI's drivers?  All the laptops I've done this on cycle from LCD only, external only, clone, extend with subsequent hotkey presses (maybe not that order).

Lashiec

  • Member
  • Joined in 2006
  • **
  • Posts: 2,374
    • View Profile
    • Donate to Member
Or try HydraVision. The Omega Drivers as far as I know are specially tailored to give an edge on gaming (or so they claim). And you can use ATI Tray Tools, for total control of ATI Catalyst from the system tray.

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
That's strange.  Are you using the video drivers from the notebook manufacturer or ATI's drivers?  All the laptops I've done this on cycle from LCD only, external only, clone, extend with subsequent hotkey presses (maybe not that order).
I'm running the video drivers supplied by acer, but as i have disabled most of acer's crap from starting with windows, maybe it's one of those that controls that button. Actually, i just found out that it isn't doing anything at all :P

Or try HydraVision. The Omega Drivers as far as I know are specially tailored to give an edge on gaming (or so they claim). And you can use ATI Tray Tools, for total control of ATI Catalyst from the system tray.
Thanks for the links, lashiec, but i tried ati tray tools, and while it has loads of options, the dual-monitor options don't seem to be working right for me :(