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:
// 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.


Sign In
Create Account


Back to top









