Groups | Blog | Home
all groups > vb.net controls > july 2004 >

vb.net controls : Pops up another window when clicking on a graphics


Hugh
7/1/2004 8:24:41 AM
My application has a user interface with pictureBox shown
many rectangles. I want a window to pop up when user
clicks certain rectangles (not everyone) to show detailed
information. What is the best way to do this?

anonymous NO[at]SPAM discussions.microsoft.com
7/1/2004 9:47:43 AM
Hi Herfried,

Thanks for your reply. It seems to me that I did not make
the question clear in my post. I want to know a easy way
to tell which rectangles are clicked, not the way to pop
up a new window. I can do it by determining my mouse
position in the picturebox_click event if I know the
position of the rectangles. The problem is I do not know
the positions. I know there are labels for the rectangles
and wonder if there is way to tell the strings by mouse
clicking on it. These strings are generated by DrawString
method not VB lables or textboxes. Thanks.

Hugh

[quoted text, click to view]
Ken Tucker [MVP]
7/1/2004 10:36:08 AM
Hi,

I would use the drawstring version that accepts a rectangle. Add the
rectangle to an Arraylist or collection and check to see if the user
clicked inside on of them and open your form if needed.

Ken
-----------------

"anonymous@discussions.microsoft.com"
[quoted text, click to view]

--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.6 - Release Date: 6/25/2004

hirf-spam-me-here NO[at]SPAM gmx.at
7/1/2004 6:24:15 PM
* "Hugh" <anonymous@discussions.microsoft.com> scripsit:
[quoted text, click to view]

\\\
Dim f As New FooForm()
f.Show()
///

???

--
Herfried K. Wagner [MVP]
hirf-spam-me-here NO[at]SPAM gmx.at
7/1/2004 7:15:20 PM
* <anonymous@discussions.microsoft.com> scripsit:
[quoted text, click to view]

OK, I got it :-).

The easiest way would be to store the rectangles where strings are drawn
in, for example, an array or a collection. Then you determine the
position that has been clicked ('MouseUp' event or 'Cursor.Position' in
the 'Click' event handler) and check for each rectangle if the point is
contained in the rectangle. 'Rectangle' provides a 'Contains' method
that will return 'True' if the point passed to the method is contained
in the rectangle.

--
Herfried K. Wagner [MVP]
anonymous NO[at]SPAM discussions.microsoft.com
7/2/2004 12:12:44 PM
Thanks, Herfried, for your tip. I will take a look at your
suggestions.

Hugh


[quoted text, click to view]
AddThis Social Bookmark Button