Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is a given point visible?

Status
Not open for further replies.

skiflyer

Programmer
Sep 24, 2002
2,213
US
My application opens a child window.

I always want this application to open just to the right of my main window, unless that puts it off screen, in which case I'll go left unless that puts it off screen in which case I'll change the whole thing to default position.

So I have the start
Code:
_childForm = new childForm();

Point childstart = new Point(this.Location.X + this.Width + 2, this.Location.Y);

Point rightTop = new Point(childstart.X + _childForm.Width, childstart.Y);

_childForm.Location = childstart;
_childForm.Show();

But how do I go about verifying that rightTop is visible, or childstart is visible, or neither are visible so I can apply the proper logic?

Thanks.
 
Well, after digging a little I'm sure there are a dozen approaches... what I decided to do is a bit convoluted and may well get refactored... but here it is for the curious

Define the topright point as above
use Screen.GetScreen on that point
Compare screen.WorkingArea.Right to the topright
If passed done, if not define a new childstart
useScreen.GetScreen on the new start point
Compare screen.WorkingArea.X to the new start point
If passed done, if not change childForm.StartPosition to default

Hope that might help someone else someday
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top