HDMI TV connection breaking when TV goes to standby

Bikonja

Reputable
Jun 16, 2014
20
0
4,510
Hi,

I have a PC running Windows 7 with an ATI graphics card. My primary monitor is a Dell (1920x1200) connected via DVI. I've had an LG TV (1920x1080) connected via HDMI as a second monitor (first desktop extended to it). When the TV was off, Windows didn't do anything, just like it behaves with DVI monitors. But now I bought a newer LG TV and whenever I turn the TV on or off, Windows detects the change and "adapts". This wouldn't be that much of a problem, but my icons and gadgets are moved around and all my maximized windows look like they are restored down to monitor size, but they're actually maximized and I have to restore them down and then maximize again to get them to maximize again.

I haven't changed any software or hardware, I just disconnected the HDMI cable from the old TV and connected it to the new one... After I discovered this problem and saw that a restart and playing around didn't help the situation, I updated my ATI drivers, but to no avail.

Does anyone know how can I get back the previous behaviour of the TV being always connected, even if it's in standby? Or at least make the gadget and windows (don't care about icons) behave correctly?
It's probably worth mentioning that when I turn the TV on or off I hear the same sound as when plugging in or out a USB device.
As I'm a programmer I'm even open to the option of making a program to "handle" this (be it intercepting the signal or detecting the change and reverting the problematic stuff, anything except writing a new driver :)). Of course, if it comes to programming a tool, I would put it up on my website so if someone else has the same problem can help themselves. Open source of course :) If it comes to programming something, I'd ask for ideas on what would be the best way to implement and specifics like how to detect a change - is there a Windows event fired or should I use a timer and call a WinApi method for enumerating displays and stuff like that.

EDIT: I forgot to add that when turning the PC on with the TV on results in both the TV and monitor showing the BIOS boot sequence and when Windows starts to boot (the black screen with Windows logo) the TV goes black right up until Windows logs the user in when it extends the primary desktop to the TV.
 

Bikonja

Reputable
Jun 16, 2014
20
0
4,510
Since no one provided any information or anything I went with my strong suit - programming. I made an app that detects monitor connect/disconnect and upon that action it searches for windows that are maximized, restores them and maximizes them again which works nicely. It does have some quirks, but generally, it's a good solution for the "maximized, but not maximized upon monitor connect/disconnect" problem. It was a quick and dirty solution so it's not ready to post on the internet yet, but eventually I might make it more of a standalone app ready for distribution and put it up on my website. If noone asks for this, I might, but also might not post this type of app on my website (www.bikonja.com). If I get requests I'll move it up my priority queue.

As for the gadget moving around, I haven't yet gotten to it, but I think it could be done on the same event, but a little trickier since the position actually changes unlike the window state which stays maximized even though it doesn't look maximized so the position would need to be defined somewhere. To get/set the gadget I suspect one could use Process.GetByName and then use the WinAPI EnumChildWindows function to enumerate gadgets and use the title to distinguish between gadgets (which is not exactly safe, but should still do in most cases), but I haven't tried this yet.

For the maximize solution I used the message loop to listen for WM_DISPLAYCHANGE message and when it comes, I use EnumWindows to get all top-level windows and use GetWindowPlacement and SetWindowPlacement to see if the window is maximized and restore and maximize it (this info is in case someone wants to implement him/herself either because you can't wait for me or I'm too busy or something).

UPDATE: Apparently, changing gadget position is not as straightforward as I thought... I've tried using SetPlacement and SetWindowPos on the gadget window handle, but something's not right. If I figure out, I'll update the answer. If anyone else knows how to do it, please post the answer.