BBC BASIC for Windows
Programming >> Graphics and Games >> Force desktop configuration?
http://bb4w.conforums.com/index.cgi?board=graphics&action=display&num=1300971187

Force desktop configuration?
Post by Martin on Mar 24th, 2011, 12:53pm

Not sure whether this should be here, or under "OS".

I am a bit of a beginner with BB4W and very new to Windows programming, but having fun finding out.

We run a number of displays where I work which have Director AV software running. If you've met Director you will know that pretty much everything is "hard wired" by default.

The problem I have is that sometimes Windows (XP SP3) "forgets" the screen settings and then the AV won't run properly. These settings have to be manually restored and even then don't always "take" immediately. A particular problem at the moment is that if Windows isn't convinced there's a monitor attached to a video output (these are all DVI by the way) it will switch that output off. Sometimes changing the settings and then changing them back makes it reconsider, sometimes it doesn't.

Does anyone know of a way, presumably not directly from BB4W but via some system call (preferably a generic Windows one as we use several different types and brands of graphics card) to force Windows to a certain display configuration?

In particular I would like to force:

- one or both outputs on, whatever the apparent state of the attached display (this is the most pressing need)

- one or both outputs to DVI-D, whatever the apparent state of the attached display (possibly related to the above for some of the cards)

- a particular resolution on a particular output

- "clone" or "extended desktop"

Any clues?

Thanks

M.

-
Re: Force desktop configuration?
Post by admin on Mar 24th, 2011, 2:18pm

on Mar 24th, 2011, 12:53pm, Martin wrote:
Does anyone know of a way, presumably not directly from BB4W but via some system call (preferably a generic Windows one as we use several different types and brands of graphics card) to force Windows to a certain display configuration?

Check out the ChangeDisplaySettingsEx API:

http://msdn.microsoft.com/en-us/library/dd183413.aspx

There should be no reason why you cannot straightforwardly call this from BB4W.

Richard.
Re: Force desktop configuration?
Post by Martin on Mar 25th, 2011, 08:56am

Thanks for that. I'm still getting to grips with navigating MSDN so your pointer is brilliant.

While the specific call you highlight will help in one or two cases, my suspicion is that in the most pressing current case what is happening isn't that the wrong resolution is set but that the output in question is either turned off completely or is outputting analogue (DVI-A = VGA) rather than the DVI-D that the display (a projector in this instance) needs. I'm not sure that this call allows me to force that, but it's certainly a starting point, as is EnumDisplaySettings(Ex) which I am probably going to use in the first instance to record what the OS *thinks* is happening!

M.
Re: Force desktop configuration?
Post by admin on Mar 25th, 2011, 09:33am

on Mar 25th, 2011, 08:56am, Martin wrote:
what is happening isn't that the wrong resolution is set but that the output in question is either turned off completely or is outputting analogue (DVI-A = VGA) rather than the DVI-D

You talk about settings having to be "manually restored" and also "changing the settings and then changing them back" but where exactly do these manual changes take place? If they are accessed from an 'Advanced settings' button in 'Display Properties' then they are hardware/driver-specific and I doubt that a straightforward API-based solution will be possible.

You may have to resort to simulating the manual control, e.g. by faking keyboard/mouse input. Tricky, but can sometimes be made to work.

Ideally you should tackle the root cause of the problem, which is almost certainly nothing to do with Windows or indeed software at all. It sounds like a hardware incompatibility between the graphics adaptor and the display device, causing the auto-detection of analogue/digital interface etc. to be unreliable.

Have you contacted the manufacturers of the graphics adaptor and monitor(s)? Have you tried powering-up the monitor(s) and PC in a different sequence? Are there any BIOS settings or monitor configuration options that might be relevant?
Re: Force desktop configuration?
Post by Martin on Mar 25th, 2011, 1:55pm

Ok, some background.

I work at the National Waterfront Museum in Swansea which is part of the National Museum of Wales. Unlike the other museum sites, this one relies heavily on "technology" - we have as many projectors and monitors as we do actual objects in cases (well, maybe not, but it sometimes seems that way).

In the case of interactive AV systems, as originally installed 6 years ago all the computers are in racks in central control rooms and signals are fed to and from output and input devices in the galleries using extenders - PS/2, USB and serial go over Cat.5 cabling while DVI (all the computer-based displays are DVI) goes over fibre.

The computers run restricted desktops and are remotely started by Wake on Lan and shut down by one of two resident utilities. They auto-log in using a feature in TweakUI and auto-run the appropriate (locally stored) AV.

Thus, once a computer has been set up it *normally* just works. Yes, the "manual settings" I refer to are indeed from the Display Properties box which differs between graphics cards and I am sure that in at least one instance you are right that the reason the thing doesn't always work is because it hasn't detected the display device and defaults to "off" or analogue; the DVI extenders are eye-wateringly expensive but do occasionally fail.

However, in this particular case the thing that's interesting to me is that the simple act of logging out of the restricted desktop, logging in as administrator and changing the display resolution suddenly causes the recalcitrant display to spring back to life.

So in *this* case all I'm really looking for is a way to make the graphics card "look again" at its outputs. On the other hand, if I could over-ride the card's auto-detection and tell it "I don't care what you think is attached, I want you to output 1280x1024x24 digitally from this particular output" that would be even better.

We do have a couple of little boxes elsewhere that solve the problem. They are made by the same company as the extender and "pretend" to be a monitor. You plug one into the monitor in question, press a button so that it "records" the monitor's EDID information, then use the it between the output of the graphics card and the input of the extender. These boxes, too, are rather pricey.

The above problem has beset various computers during the last couple of years and the oddest thing is that you fight it for a while - three or four months perhaps - then it suddenly starts working again.

A different problem on another display might benefit from a similar solution. On this one, text displayed by the AV *sometimes* (about 1 in 3 days) is formatted incorrectly, slightly too large, kerning all wrong, that sort of thing. This causes letter spacings to be a bit odd and causes text to flow onto following lines making it all look a bit messy.

I really have no idea at all what is going on here. It is one of three machines running identical software to identical I/O (though it is a rebuild machine with a different graphics card) and it is the only one with this issue. And before you say it, it spent some months after the rebuild without this issue, though during that time it did exhibit the "lost monitor" problem (this one has both an LCD screen and a projector attached - it was the projector that used to disappear, but the font problem is present on both).

I'm not convinced it's a hardware problem in either case, and I'm not convinced it's a Windows problem either, though I have to say that we do have other niggling problems that I cannot put down to anything except Windows.

I've been using BB4W to write little utilities for the year or so (?) I've had it and it has been invaluable. After trying all sorts of other things I just wondered if anyone had any clues where to look for controls that would let me force display parameters because that would be another quick utility I could write that would solve an ongoing problem.

M.
Re: Force desktop configuration?
Post by admin on Mar 25th, 2011, 3:45pm

on Mar 25th, 2011, 1:55pm, Martin wrote:
I really have no idea at all what is going on here. It is one of three machines running identical software to identical I/O (though it is a rebuild machine with a different graphics card) and it is the only one with this issue.

You could hardly have more convincing evidence that it's a hardware or device incompatibility problem - the machine with the problem is the one with a different graphics card!

I appreciate that you've exhausted the hardware options available to you to fix the problem, which is why you are looking for a software solution, but it does no harm to realise that at best it will be a workaround, not a cure.

Richard.