Tuesday, August 26, 2025

 Multi-Monitor Smudge

MS-Windows lost my Window...?

Apparently, it's not MS-Windows. It's me, when saving the program's last locations in an .INI file.

If I close the program. It saves the Top/Left so when run again it comes back where I left it. But if I change primary monitors, or orientation, before I run it again, I have a problem - if it was closed on any non-primary monitor. My Left = -1700 might now be +1700 and is now WAY off screen. Or too high/low, if the monitors were stacked and now side-by-side.

My multi-monitor solution was to put the following code in my On Show event.

//-------------------------------------
//reset form if primary monitor changed
int drL, drT, drR, drB;
TRect drect;
drect = Screen->DesktopRect;
drL = drect.Left;
drT = drect.Top;
drR =drect.Right;
drB = drect.Bottom;
if(Top < drT)//too high
     {Top = 0;}
if(Top > drB)//too low
     {Top = 0;}
if(Left < drL)//too far left
     {Left = 0;}
if(Left > drR)//too far right
     {Left = 0;}
//-------------------------------------


This would also help if I disconnected the secondary monitor.


 

No comments:

Post a Comment