Lost Password?

Go Back   CodeCall Programming Forum > Software Development > Tutorials

Tutorials Programming Tutorials - Post your tutorials here!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-15-2006, 07:15 AM
RobSoftware RobSoftware is offline
Programmer
 
Join Date: Nov 2005
Posts: 143
Rep Power: 11
RobSoftware is on a distinguished road
Default Dual Monitors and the window position

I ran into this problem recently as I just got dual monitors. If you save the location of your program and then load it once the user restarts you need to have code to keep it inside the visible window if they remove the dual monitor. Without this code the user will load your program and never be able to see it.

I took it from a C# sample originially and converted it to C++. It is easy to convert back to C#. Here is the code:

Code:
// Make sure the form is visible		
System::Windows::Forms::Screen^ currentScreen  = System::Windows::Forms::Screen::FromHandle(this->Handle);
						
// Ensure top visible
if((this->Top < currentScreen->Bounds.Top) || ((this->Top + this->Height) > (currentScreen->Bounds.Top + currentScreen->Bounds.Height)))	
{
    this->Top = currentScreen->Bounds.Top;
}

// Ensure at least 60 px of Title Bar visible
if(((this->Left + this->Width - 60) < currentScreen->Bounds.Left) || ((this->Left + 60) > (currentScreen->Bounds.Left + currentScreen->Bounds.Width))) 
{
    this->Left = currentScreen->Bounds.Left;
}
Add this just under where the location is restored.

Having a laptop and moving from dual monitor to single monitor often I've noticed several programs have this flaw. It makes the program ...... bad (for lack of a better term). If you save the location you should use this code to restore it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 06-15-2006, 11:02 AM
NeedHelp NeedHelp is offline
Programming God
 
Join Date: May 2006
Posts: 527
Rep Power: 12
NeedHelp is on a distinguished road
Default

Yeah, it is kind of cheesy when you load a program and can't see it. I would suggest that anyone using window positions (saving and reloading) use code to protect against dual-monitor.
__________________
I Need Help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -5. The time now is 01:39 PM.

Contest Stats

John ........ 223.00000
dargueta ........ 168.00000
Xav ........ 164.00000
gaylo565 ........ 18.00000
WingedPanther ........ 15.00000
|pH| ........ 15.00000
Johnnyboy ........ 3.00000
navghost ........ 1.00000

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 65%

Ads