[program-l] VB6: Trying to Get an Application to Adapt to When a User is Docked With his Desktop Spread Across Multiple Monitors Versus When He's Operating Undocked

  • From: gerald.g.weichbrodt@xxxxxx
  • To: program-l@xxxxxxxxxxxxx
  • Date: Fri, 13 Mar 2009 11:08:55 -0400

Hi all,

I have a VB 6 application that remembers its left, top, height, width, and 
maximized properties from one execution to the next.  These values get 
stored to the registry.  One of my users has his laptop set up so that, 
when he's docked, his desktop spreads out across both his laptop's 
built-in monitor and his external monitor.  Of course, this means he has 
less real estate when he's operating undocked.  Recently he ran into a 
situation where, running undocked, my application started up completely 
off his laptop screen.  I tried to deal with this by writing some code 
that would try to force the application to fall within the screen 
boundaries so he'd have something to drag and manipulate at the very 
least.  I seem not to have cured the problem, though.  Here's a snippet of 
the code I use in my main form, and I'm wondering what I'm failing to do 
here:

    Me.Left = GetSetting(App.Title, "Settings", "MainLeft", 1000)
    Me.Top = GetSetting(App.Title, "Settings", "MainTop", 1000)
    Me.Width = GetSetting(App.Title, "Settings", "MainWidth", 6500)
    Me.Height = GetSetting(App.Title, "Settings", "MainHeight", 6500)
    Me.WindowState = GetSetting(App.Title, "Settings", "MainWindowState", 
0)
    If Me.Left + Me.Width > Screen.Width Then Me.Left = 1000
    If Me.Top + Me.Height > Screen.Height Then Me.Top = 1000

I suspect this is a bit of overkill in that I'm basically forcing the 
left-top corner of my form to be pulled to within 1000 twips of a boundary 
if the far right of the form hangs over the right of the screen.  I'm 
doing similarly in the vertical direction.  I was just sure this would 
work.  I can't see how my application can "escape" the screen boundaries.

Thanks for any wisdom,
Jerry

Other related posts:

  • » [program-l] VB6: Trying to Get an Application to Adapt to When a User is Docked With his Desktop Spread Across Multiple Monitors Versus When He's Operating Undocked - gerald . g . weichbrodt