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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with the picture box.

Status
Not open for further replies.

hujur

Programmer
Feb 14, 2003
20
0
0
US
Hello,

I have developed the project that allows the user to draw the diagrams like house outline , garagoutline etc.. on the picture box.
I save the co-ordinates of the house into the access database and while he is drawing it is saved into the collection and the mousedown event has allthe code to determine what x,y co-ordinate user has clicked on &so forth.

But now I want to do two things : a) After the first outline of the house is drawn the flag is set - HouseIsReady = true , now I don't want the user to be able to draw beyond the outlines of the house.
b) How do I calculate the area of the house outline and determine that user is trying to draw outside of the house outline. I have data stored in the x,y co-ordintes.

For example following is the house outline drawn on the
picture box , I don't want if the user cilcks on the out side of the outline anything should happen (It means i want to set some flag that will be checked inthe mouse down event and it will not execute the code in that event).
I don't know how to calculate the area of the house outline and code for it and how to determine in the mouse down event that user is clicking on the area beyond the outline.
___________________________
| |
| ------
| |
|_________________________________|

The above lines are actually line, these are not dash lines in the code.



Please help.
 
I don't think you actually have to calculate the area of the house outline. Have code in the MouseDown event check to see if the current x is less than the x coord. of the "left" wall or greater than the x coord. of the "right" wall, and do the same with the y coords. of the "top" and "bottom" walls.

Actually, it might be easier to determine if the xy coords fall within this range, instead of falling outside the range:

If x > LeftWallX And x < RightWallX And Y > TopWallY And Y < BottomWallY Then

'do some drawing

EndIf

Obviously this code example is only for a simple rectangle, but some clever coding (nested If statements, I think) should get you what you want. You will also need to do some checking to make sure that the user doesn't start a line inside the house outline and end it outside the outline.

Hope this helps. Good luck.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top