Newbie - Marking where user clicked on transparent label boxes 
Author Message
 Newbie - Marking where user clicked on transparent label boxes
Hi,
    I have several images of the human body, and the user clicks on a
specific part and it displays information such as body part name, etc. in a
list box.  I have used transparent label boxes to differentiate between body
parts, and now I want to add another feature: drawing a small circle or 'X'
exactly where the user clicks on the body part (in the transparent label
box).
    I tried drawing a circle on a mousedown event of a picture box, but the
circles don't show up because of the transparent label boxes.  Any ideas on
how to draw something inside a label box?
    Thanks in advance.

Rishi



Thu, 04 Nov 2004 09:23:09 GMT  
 Newbie - Marking where user clicked on transparent label boxes
The "failure to display the circle" is not because the circle is "hidden"
beneath anything. Rather, it is because the "mouse down" event for the
Picture Box does not occur at all if the mouse is clicked down over a Label
that "lives in" the Picture Box.

I do have some suggestions that might help you, but first of all, in
response to your use of transparent labels in this respect, I must express
my surprise at the fact that all of your "body parts" are rectangular!

If I were you, I would have a look at the various "region" API stuff, which
will allow you to create regions of any shape and determine whether the
mouse was clicked in any of them. Alternatively (and more simply) you could
draw your "body" in two separate identically sized Picture Boxes (one
visible to the user and the other set to Visible = False, Autoredraw =
True).

Load your "body picture" into a painting program (Windows Paint will do, at
a push) and draw and fill the "real" outline of your various body parts
(each in a different colour). When you have drawn all of the "body parts"
then fill the rest of the picture with white (so that you end up with a
picture that shows just the body parts (not the body itself) on a white
background. Save the result as a bitmap, so that you end up with two
bitmaps - one showing the original "body" and the other showing numerous
little differently coloured shapes that represent the various body parts.
Take care to choose colours that are "solid" in all Windows colour depths.

Then you can display the original "body" picture in your display Picture
Box, and in its MouseDown event you could write code that "has a look" at
the equivalent x and y coordinates in the hidden "body parts" picture box to
determine what colour is there. If it is white then the user has not clicked
on a represented "body part", and if it is any other colour then the user
has clicked on the "body part" that was drawn in that colour.

This will allow you to represent the various body parts in their exact shape
(rather than using rectangles) and it will allow you to draw whatever you
want to over the displayed picture.

I would offer my own body as a "testbed" for your program, but, despite it
being almost sixty years old, there is a specific "body part" that might be
too large for your Picture Box ;-)

Mike


Quote:
> Hi,
>     I have several images of the human body, and the user clicks on a
> specific part and it displays information such as body part name, etc. in
a
> list box.  I have used transparent label boxes to differentiate between
body
> parts, and now I want to add another feature: drawing a small circle or
'X'
> exactly where the user clicks on the body part (in the transparent label
> box).
>     I tried drawing a circle on a mousedown event of a picture box, but
the
> circles don't show up because of the transparent label boxes.  Any ideas
on
> how to draw something inside a label box?
>     Thanks in advance.

> Rishi



Thu, 04 Nov 2004 11:42:41 GMT  
 Newbie - Marking where user clicked on transparent label boxes
Hi,
    Thanks for your suggestion.  I had tried to do that, but I have over 400
body parts to represent, and I didn't think I would find a solid color for
each one.  Even if I did, I didn't want to write 400 If...Else statements
for each color.  So what I did was user transparent label boxes, and not
necessarily just one for each body part.  I made tiny ones to catch the
corners, and even though it isn't exact, its good enough.
    I didn't know that the mousedown event doesn't happen when a label box
is on top of a picture box.  Still, unfortunately, it doesn't solve the
problem.  Any other suggestions?

Rishi


Quote:
> The "failure to display the circle" is not because the circle is "hidden"
> beneath anything. Rather, it is because the "mouse down" event for the
> Picture Box does not occur at all if the mouse is clicked down over a
Label
> that "lives in" the Picture Box.

> I do have some suggestions that might help you, but first of all, in
> response to your use of transparent labels in this respect, I must express
> my surprise at the fact that all of your "body parts" are rectangular!

> If I were you, I would have a look at the various "region" API stuff,
which
> will allow you to create regions of any shape and determine whether the
> mouse was clicked in any of them. Alternatively (and more simply) you
could
> draw your "body" in two separate identically sized Picture Boxes (one
> visible to the user and the other set to Visible = False, Autoredraw =
> True).

> Load your "body picture" into a painting program (Windows Paint will do,
at
> a push) and draw and fill the "real" outline of your various body parts
> (each in a different colour). When you have drawn all of the "body parts"
> then fill the rest of the picture with white (so that you end up with a
> picture that shows just the body parts (not the body itself) on a white
> background. Save the result as a bitmap, so that you end up with two
> bitmaps - one showing the original "body" and the other showing numerous
> little differently coloured shapes that represent the various body parts.
> Take care to choose colours that are "solid" in all Windows colour depths.

> Then you can display the original "body" picture in your display Picture
> Box, and in its MouseDown event you could write code that "has a look" at
> the equivalent x and y coordinates in the hidden "body parts" picture box
to
> determine what colour is there. If it is white then the user has not
clicked
> on a represented "body part", and if it is any other colour then the user
> has clicked on the "body part" that was drawn in that colour.

> This will allow you to represent the various body parts in their exact
shape
> (rather than using rectangles) and it will allow you to draw whatever you
> want to over the displayed picture.

> I would offer my own body as a "testbed" for your program, but, despite it
> being almost sixty years old, there is a specific "body part" that might
be
> too large for your Picture Box ;-)

> Mike



> > Hi,
> >     I have several images of the human body, and the user clicks on a
> > specific part and it displays information such as body part name, etc.
in
> a
> > list box.  I have used transparent label boxes to differentiate between
> body
> > parts, and now I want to add another feature: drawing a small circle or
> 'X'
> > exactly where the user clicks on the body part (in the transparent label
> > box).
> >     I tried drawing a circle on a mousedown event of a picture box, but
> the
> > circles don't show up because of the transparent label boxes.  Any ideas
> on
> > how to draw something inside a label box?
> >     Thanks in advance.

> > Rishi



Thu, 04 Nov 2004 12:28:15 GMT  
 Newbie - Marking where user clicked on transparent label boxes
Mike's suggestion is pretty good for detecting whether or not somebody
has clicked on the body or not - perhaps this will give you some
ideas.

You have a load of labels that are 'little rectangles' - you know the
Top, Left, Height and Width of each rectangle.

If you now write a routine that reads these into a UDT array on
startup you will have an array of Vectors.

Type TPART
       Top As Integer
       Left As Integer
       Bottom As Integer
       Right As Integer
End Type

ReDim Part( MaxPart ) As TPART

Simply make all the Labels invisible and the Picturebox will trap any
Click in the MouseDown Event

Pick up the coordinates and scamper through your Array to see which
label would have been clicked - it it were visible.

This sounds like a lot of work - but scampering through 400 odd
elements of an array does not take long - you can always speed it up
by setting up a sorted index if you feel like it.

Of course you could get rid of the Labels altogether - but they are
probably useful as a 'design time' utility for identifying the parts.

BTW - work in Pixels - not Twips

HTH

Quote:

>Hi,
>    Thanks for your suggestion.  I had tried to do that, but I have over 400
>body parts to represent, and I didn't think I would find a solid color for
>each one.  Even if I did, I didn't want to write 400 If...Else statements
>for each color.  So what I did was user transparent label boxes, and not
>necessarily just one for each body part.  I made tiny ones to catch the
>corners, and even though it isn't exact, its good enough.
>    I didn't know that the mousedown event doesn't happen when a label box
>is on top of a picture box.  Still, unfortunately, it doesn't solve the
>problem.  Any other suggestions?

>Rishi



>> The "failure to display the circle" is not because the circle is "hidden"
>> beneath anything. Rather, it is because the "mouse down" event for the
>> Picture Box does not occur at all if the mouse is clicked down over a
>Label
>> that "lives in" the Picture Box.

>> I do have some suggestions that might help you, but first of all, in
>> response to your use of transparent labels in this respect, I must express
>> my surprise at the fact that all of your "body parts" are rectangular!

>> If I were you, I would have a look at the various "region" API stuff,
>which
>> will allow you to create regions of any shape and determine whether the
>> mouse was clicked in any of them. Alternatively (and more simply) you
>could
>> draw your "body" in two separate identically sized Picture Boxes (one
>> visible to the user and the other set to Visible = False, Autoredraw =
>> True).

>> Load your "body picture" into a painting program (Windows Paint will do,
>at
>> a push) and draw and fill the "real" outline of your various body parts
>> (each in a different colour). When you have drawn all of the "body parts"
>> then fill the rest of the picture with white (so that you end up with a
>> picture that shows just the body parts (not the body itself) on a white
>> background. Save the result as a bitmap, so that you end up with two
>> bitmaps - one showing the original "body" and the other showing numerous
>> little differently coloured shapes that represent the various body parts.
>> Take care to choose colours that are "solid" in all Windows colour depths.

>> Then you can display the original "body" picture in your display Picture
>> Box, and in its MouseDown event you could write code that "has a look" at
>> the equivalent x and y coordinates in the hidden "body parts" picture box
>to
>> determine what colour is there. If it is white then the user has not
>clicked
>> on a represented "body part", and if it is any other colour then the user
>> has clicked on the "body part" that was drawn in that colour.

>> This will allow you to represent the various body parts in their exact
>shape
>> (rather than using rectangles) and it will allow you to draw whatever you
>> want to over the displayed picture.

>> I would offer my own body as a "testbed" for your program, but, despite it
>> being almost sixty years old, there is a specific "body part" that might
>be
>> too large for your Picture Box ;-)

>> Mike



>> > Hi,
>> >     I have several images of the human body, and the user clicks on a
>> > specific part and it displays information such as body part name, etc.
>in
>> a
>> > list box.  I have used transparent label boxes to differentiate between
>> body
>> > parts, and now I want to add another feature: drawing a small circle or
>> 'X'
>> > exactly where the user clicks on the body part (in the transparent label
>> > box).
>> >     I tried drawing a circle on a mousedown event of a picture box, but
>> the
>> > circles don't show up because of the transparent label boxes.  Any ideas
>> on
>> > how to draw something inside a label box?
>> >     Thanks in advance.

>> > Rishi



Thu, 04 Nov 2004 17:14:10 GMT  
 Newbie - Marking where user clicked on transparent label boxes


Quote:
>    Thanks for your suggestion.  I had tried to do that, but I have over 400
>body parts to represent, and I didn't think I would find a solid color for
>each one.  Even if I did, I didn't want to write 400 If...Else statements

A guess - not tested properly. Use Mike's hidden multi-coloured picture.
Use say blue (BRG = FF,0,0) for the first organ shape/position, FF,0,1
for the next and so on. The Point(x,y) function will, I think, return
the exact colour value there. Subtract (FF,0,0) from the value obtained
and you should have an index into wherever the details are stored. Just
ran a simple test program in 16-colour mode and it appeared to work OK
returning the exact colour values.

Regards.

--
Martin Trump



Thu, 04 Nov 2004 23:47:27 GMT  
 Newbie - Marking where user clicked on transparent label boxes


Quote:
>A guess - not tested properly. Use Mike's hidden multi-coloured picture.
>Use say blue (BRG = FF,0,0) for the first organ shape/position, FF,0,1

Whoops, another boo-boo from Trump Towers.

That should have been BGR = etc.

Regards.

--
Martin Trump



Fri, 05 Nov 2004 04:57:57 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Transparent Label on Transparent User Control Problem

2. How to have transparent text label on top of picture box

3. Wanted: Code to click a label and pop up user default e-mail program

4. transparent OCX with transparent label

5. BUG: Transparent Label on Transparent Control Does Not Display

6. Transparent UserControl with transparent label - Anyone?

7. Transparent UserControl with transparent label

8. BUG: Transparent Label on Transparent Control Does Not Display

9. Marking a text in label

10. Labels - Transparent labels flash whenever they get changed

11. Removeing Marking After Double-Click

12. label click event only works with right mouse click

 

 
Powered by phpBB® Forum Software