469,568 Members | 1,723 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,568 developers. It's quick & easy.

Making Hot Spots on Windows form using transparent buttons??


The needed capability:
I guess there are two possibilities for making "hot
spots" on a Windows Form:

The Scenario:
I have a world map as the form background. I need
clickable hotspots over portions of the world map that
also have tool tip messages.

The Possibilities?:
Option 1:
Place invisible buttons on the area needing a hotspot.
Is this possible to make buttons invisible?

Option 2:
Put the buttons on a separate form of the same size as
the first and set the property of this form to 0%. Then
write code to overlay the form with buttons exactly on
top of the first form needing hotspots...so the world map
is viewable "under" the buttons. Is there sample code
that already does this? Seems a little messy for cases
when the user starts moving forms around. trying to keep
the two on top of one another.

Any other suggestions??

Nov 21 '05 #1
11 6611
"BobAchgill" <an*******@discussions.microsoft.com> schrieb:
The needed capability:
I guess there are two possibilities for making "hot
spots" on a Windows Form:

The Scenario:
I have a world map as the form background. I need
clickable hotspots over portions of the world map that
also have tool tip messages.


Option 3:

Add a handler to a form's (or control's) mouse events and store an
array/collection of regions that represent the hotspots. You can create
regions of arbitrary shape from a 'GraphicsPath' (see 'Region' constructor).
In the 'MouseUp' event, you loop through the regions and check 'IsVisible'
for the mouse position. In the mouse move event, you do the same and adjust
the tooltip's text accordingly. In addition to that, you'll have to provide
keyboard access to the regions.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
"BobAchgill" <an*******@discussions.microsoft.com> schrieb:
The needed capability:
I guess there are two possibilities for making "hot
spots" on a Windows Form:

The Scenario:
I have a world map as the form background. I need
clickable hotspots over portions of the world map that
also have tool tip messages.


Option 3:

Add a handler to a form's (or control's) mouse events and store an
array/collection of regions that represent the hotspots. You can create
regions of arbitrary shape from a 'GraphicsPath' (see 'Region' constructor).
In the 'MouseUp' event, you loop through the regions and check 'IsVisible'
for the mouse position. In the mouse move event, you do the same and adjust
the tooltip's text accordingly. In addition to that, you'll have to provide
keyboard access to the regions.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3

I lost you "on loop through the regions and
check 'IsVisible' for the mouse position.

Can you steer me to some example remotely like what you
are talking about?

I forgot I also need the feature AccessibleName that
would have come with using an invisible button approach.
I guess that will look something like:
Me.graphicspath.AccessibleName = "MyName"
I think I will be a better programmer after doing it the
way you are suggesting. If I can make it up that little
hill.

I have been wanting to do some thing with graphics so I
guess this is the beginning.

Thanks!
-----Original Message-----
"BobAchgill" <an*******@discussions.microsoft.com> schrieb:
The needed capability:
I guess there are two possibilities for making "hot
spots" on a Windows Form:

The Scenario:
I have a world map as the form background. I need
clickable hotspots over portions of the world map that
also have tool tip messages.


Option 3:

Add a handler to a form's (or control's) mouse events

and store anarray/collection of regions that represent the hotspots. You can createregions of arbitrary shape from a 'GraphicsPath' (see 'Region' constructor).In the 'MouseUp' event, you loop through the regions and check 'IsVisible'for the mouse position. In the mouse move event, you do the same and adjustthe tooltip's text accordingly. In addition to that, you'll have to providekeyboard access to the regions.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

.

Nov 21 '05 #4

I lost you "on loop through the regions and
check 'IsVisible' for the mouse position.

Can you steer me to some example remotely like what you
are talking about?

I forgot I also need the feature AccessibleName that
would have come with using an invisible button approach.
I guess that will look something like:
Me.graphicspath.AccessibleName = "MyName"
I think I will be a better programmer after doing it the
way you are suggesting. If I can make it up that little
hill.

I have been wanting to do some thing with graphics so I
guess this is the beginning.

Thanks!
-----Original Message-----
"BobAchgill" <an*******@discussions.microsoft.com> schrieb:
The needed capability:
I guess there are two possibilities for making "hot
spots" on a Windows Form:

The Scenario:
I have a world map as the form background. I need
clickable hotspots over portions of the world map that
also have tool tip messages.


Option 3:

Add a handler to a form's (or control's) mouse events

and store anarray/collection of regions that represent the hotspots. You can createregions of arbitrary shape from a 'GraphicsPath' (see 'Region' constructor).In the 'MouseUp' event, you loop through the regions and check 'IsVisible'for the mouse position. In the mouse move event, you do the same and adjustthe tooltip's text accordingly. In addition to that, you'll have to providekeyboard access to the regions.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

.

Nov 21 '05 #5

"BobAchgill" <an*******@discussions.microsoft.com> wrote
Option 2:
Put the buttons on a separate form of the same size as
the first and set the property of this form to 0%. Then
write code to overlay the form with buttons exactly on
top of the first form needing hotspots... Any other suggestions??


Option 4
Create a bitmap of the world map such that hotspots are
different colors that helps to index them in an array of
informative items. As the user moves over the world map,
use the X and Y coordinates to get the pixel color information
from the indexed bitmap, and use that index to get information
about the hotspot.

For example, hotspot1 could be colored RGB(0, 0, 1),
hotspot2 = RGB(0, 0, 2), etc... and converting those colors
to indexes, you could look up the needed info from an array.

LFS
Nov 21 '05 #6

"BobAchgill" <an*******@discussions.microsoft.com> wrote
Option 2:
Put the buttons on a separate form of the same size as
the first and set the property of this form to 0%. Then
write code to overlay the form with buttons exactly on
top of the first form needing hotspots... Any other suggestions??


Option 4
Create a bitmap of the world map such that hotspots are
different colors that helps to index them in an array of
informative items. As the user moves over the world map,
use the X and Y coordinates to get the pixel color information
from the indexed bitmap, and use that index to get information
about the hotspot.

For example, hotspot1 could be colored RGB(0, 0, 1),
hotspot2 = RGB(0, 0, 2), etc... and converting those colors
to indexes, you could look up the needed info from an array.

LFS
Nov 21 '05 #7
"BobAchgill" <an*******@discussions.microsoft.com> schrieb:
I lost you "on loop through the regions and
check 'IsVisible' for the mouse position.
\\\
Private m_Regions() As Region
..
..
..
m_Regions = ...
..
..
..
Private Sub Form_MouseMove( _
ByVal sender As Object, _
ByVal e As MouseEventArgs _
) Handles MyBase.MouseMove
For Each r As Region In m_Regions
If r.IsVisible(e.X, e.Y) Then
RegionClicked(r)
Return
End If
Next r
End Sub
///
I forgot I also need the feature AccessibleName that
would have come with using an invisible button approach.
I guess that will look something like:
Me.graphicspath.AccessibleName = "MyName"


Mhm... I currently don't have an idea because the approach described above
doesn't make use of controls.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #8
"BobAchgill" <an*******@discussions.microsoft.com> schrieb:
I lost you "on loop through the regions and
check 'IsVisible' for the mouse position.
\\\
Private m_Regions() As Region
..
..
..
m_Regions = ...
..
..
..
Private Sub Form_MouseMove( _
ByVal sender As Object, _
ByVal e As MouseEventArgs _
) Handles MyBase.MouseMove
For Each r As Region In m_Regions
If r.IsVisible(e.X, e.Y) Then
RegionClicked(r)
Return
End If
Next r
End Sub
///
I forgot I also need the feature AccessibleName that
would have come with using an invisible button approach.
I guess that will look something like:
Me.graphicspath.AccessibleName = "MyName"


Mhm... I currently don't have an idea because the approach described above
doesn't make use of controls.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #9
"Larry Serflaten" <se*******@usinternet.com> schrieb:
Create a bitmap of the world map such that hotspots are
different colors that helps to index them in an array of
informative items. As the user moves over the world map,
use the X and Y coordinates to get the pixel color information
from the indexed bitmap, and use that index to get information
about the hotspot.


Good idea. That works pretty well and is easy to implement. I once
implemented that in VB6 ;-). Still the developer has to care about
accessibility (texts, keyboard access, ...).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #10
"Larry Serflaten" <se*******@usinternet.com> schrieb:
Create a bitmap of the world map such that hotspots are
different colors that helps to index them in an array of
informative items. As the user moves over the world map,
use the X and Y coordinates to get the pixel color information
from the indexed bitmap, and use that index to get information
about the hotspot.


Good idea. That works pretty well and is easy to implement. I once
implemented that in VB6 ;-). Still the developer has to care about
accessibility (texts, keyboard access, ...).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #11
BobAchgill wrote:
(sniP)
Put the buttons on a separate form of the same size as
the first and set the property of this form to 0%.


I thought the lowest value for for transparency was 50%.

and I still haven't thought of a reason to use it!
Nov 21 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by mattaku | last post: by
reply views Thread by BobAchgill | last post: by
1 post views Thread by FredC | last post: by
9 posts views Thread by mohit.akl | last post: by
4 posts views Thread by tshad | last post: by
3 posts views Thread by ApexData | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.