Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Needed: A replacement ImageMap Control

5 views
Skip to first unread message

Patrick Pirtle <PPirtle mka <dot> <com>>

unread,
Jan 28, 2009, 6:03:04 PM1/28/09
to
For the last few years, I've maintained a simple app that uses a
terrific imagemap control (licensed from Silverband software).
However, the control OCX doesn't want to run under Vista, nor has the
control been released for Vista. This control is NOT for creating
image maps. Instead, it displays an image and reads an HTML file
defining hot-spot coordinates. When the user clicks on the image, it
passes the name of the hot-spot to my vba for further processing.

Ideally, I'd like to just keep using the control I purchased, but it
doesn't appear likely that it'll be updated.

So, my questions are:

1. Any suggestions on how to get my control to work in Vista?

2. Does anyone know of any code that might get me on the track to
create my own image map control?

3. I've never created a control, but would like to learn how. Any
suggestions for tutorials or for an example on creating controls?

Thanks, in advance, for any help and suggestions.

Bill McCarthy

unread,
Jan 28, 2009, 6:38:26 PM1/28/09
to
Hi Patrick,

This doesn't sound too hard.

> 1. Any suggestions on how to get my control to work in Vista?

First make sure you run everything as administrator. If that still fails
try setting the compatibility on the exe to XP SP2 (right click and select
properties)

> 2. Does anyone know of any code that might get me on the track to
> create my own image map control?

Not off hand, but as long as the area is small such that you can ignore
curvature it's very straight forward applying of scale. If you're doing
this from scratch, and the system is live/web based, then maybe using Live
Maps or Google Maps might provide even more detail.

> 3. I've never created a control, but would like to learn how. Any
> suggestions for tutorials or for an example on creating controls?

Start with a UserControl. A control is really that plus support modules
etc, all packed into on dll.

"Patrick Pirtle mka >" <PPirtle <atdotcom> wrote in message
news:guo1o45fqjd1vdvp7...@4ax.com...

Larry Serflaten

unread,
Jan 28, 2009, 9:41:58 PM1/28/09
to

"Patrick Pirtle mka >" <PPirtle <atdotcom> wrote

> 2. Does anyone know of any code that might get me on the track to


> create my own image map control?

You can define a hidden PictureBox to be the same size as the Image,
and when the hotspots are defined, you color the picturebox and keep
an assoication of the colors with their defined names. Then when the
user clicks on the Image, you translate that point to the picturebox and
note what color is stored there. From that you can return the defined
name.

For an example, paste the following code into a new form. I used
the form to display both the Image and hidden Picturebox so you
could see it in action. Click on the Image to see the form's Caption
change.

HTH
LFS


Option Explicit
Private Spots As Collection

Private Sub Form_Load()
' Draw Images
Set Spots = New Collection
Me.AutoRedraw = True
Me.ScaleMode = vbPixels
Me.Line (0, 0)-Step(180, 180), vbWhite, BF
Me.Line (200, 0)-Step(180, 180), vbBlack, BF
Me.PSet (70, 200), Me.BackColor
Me.Print "IMAGE"
Me.PSet (230, 200), Me.BackColor
Me.Print "HIDDEN PICTURE BOX"
' Define hot spots
HotSpot "Apple", vbGreen, 20, 20, 30, 14
HotSpot "Banana", vbYellow, 20, 40, 40, 14
HotSpot "Cherry", vbRed, 120, 120, 30, 14
HotSpot "Orange", &HB0FF&, 120, 140, 35, 14
' Lock image, add undefined area (association)
Me.AutoRedraw = False
Spots.Add "UnDefined", "K0"

End Sub

Sub HotSpot(Name As String, C, X, Y, W, H)
' Add to Image
Me.PSet (X, Y), vbWhite
Me.Print Name
' Add to Picture
Me.Line (X + 200, Y)-Step(W, H), C, BF
' Associate
Spots.Add Name, "K" & CStr(C)
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim C
' Get color, change Caption
C = "K" & CStr(Me.Point(X + 200, Y))
Me.Caption = Spots(C)
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Track mouse for demo...
If (X < 180) And (Y < 180) Then
Cls
Me.Circle (X + 200, Y), 3, vbWhite
Me.Circle (X + 200, Y), 2, vbBlack
Me.Line (0, 200)-Step(10, 10), Me.Point(X + 200, Y), BF
End If
End Sub


Patrick Pirtle <PPirtle mka <dot> <com>>

unread,
Jan 29, 2009, 11:58:27 AM1/29/09
to
Bill -
First off, many thanks for the reply. Your user name cracked me up
when I read it--Had some trouble with TPASoft, did you?

>> 1. Any suggestions on how to get my control to work in Vista?
>
>First make sure you run everything as administrator. If that still fails
>try setting the compatibility on the exe to XP SP2 (right click and select
>properties)

When I tried to register the 3rd-party OCX, it errored. Could it be
that "regsvr32" doesn't want to run in Vista, and not a problem with
the OCX itself? Or, could I set the compatibility of regsvr32 to XP
XP2? After reading your suggestion, I re-tried googling this, and
*may* have found some additional suggestions. Thanks for your help.

- Patrick

Patrick Pirtle <PPirtle mka <dot> <com>>

unread,
Jan 29, 2009, 12:59:08 PM1/29/09
to
Larry -
Whoa! This is very cool. Heck, I played with this little app all by
itself for about 20 minutes (yeah, I know...simple minds=simple
pleasures).

Is it possible to do the same thing in VBA? If not, then I'm guessing
I could create my own OCX(?)--if I can figure out how.

Thanks, again, for your help.
- Patrick

Karl E. Peterson

unread,
Jan 29, 2009, 2:19:14 PM1/29/09
to
> Bill -

> When I tried to register the 3rd-party OCX, it errored. Could it be
> that "regsvr32" doesn't want to run in Vista, and not a problem with
> the OCX itself?

You'll need to run regsvr32 "as administrator", even if your current account is a
member of the administrators group, yes.
--
.NET: It's About Trust!
http://vfred.mvps.org


Larry Serflaten

unread,
Jan 29, 2009, 2:45:54 PM1/29/09
to

"Patrick Pirtle mka >" <PPirtle <atdotcom> wrote
> Larry -
> Whoa! This is very cool. Heck, I played with this little app all by
> itself for about 20 minutes (yeah, I know...simple minds=simple
> pleasures).
>
> Is it possible to do the same thing in VBA? If not, then I'm guessing
> I could create my own OCX(?)--if I can figure out how.

I don't know, I loathed installing Office on my old system, but I would
have to guess it depends on where you are using VBA. You said you
had a little app with a control that passed data to your VBA....

Exactly what is the situation there, what language was the app written in,
where is the image being shown, where is your VBA running, etc...

LFS


Bill McCarthy

unread,
Feb 1, 2009, 8:49:38 PM2/1/09
to
Hi Patrick,

"Patrick Pirtle mka >" <PPirtle <atdotcom> wrote in message

news:bin3o4p2i686urjok...@4ax.com...


> Bill -
> First off, many thanks for the reply. Your user name cracked me up
> when I read it--Had some trouble with TPASoft, did you?
>

Just a troll/stalker/identity thief.

>>> 1. Any suggestions on how to get my control to work in Vista?
>>
>>First make sure you run everything as administrator. If that still fails
>>try setting the compatibility on the exe to XP SP2 (right click and select
>>properties)
>
> When I tried to register the 3rd-party OCX, it errored. Could it be
> that "regsvr32" doesn't want to run in Vista, and not a problem with
> the OCX itself? Or, could I set the compatibility of regsvr32 to XP
> XP2? After reading your suggestion, I re-tried googling this, and
> *may* have found some additional suggestions. Thanks for your help.
>

Regsvr32 does work in Vista (both 32 and 64 bit versions of Vista). It
needs to be run as administrator. I normally run cmd as administrator and
then use RegSvr32 from that command window.

.

C Kevin Provance

unread,
Feb 1, 2009, 9:32:33 PM2/1/09
to

"Bill McCarthy" <TPASoft.com Are Identity Thieves> wrote in message
news:%23gEpJtN...@TK2MSFTNGP04.phx.gbl...
| Just a troll/stalker/identity thief.

Yeah, that about sums you up in one sentance. I believe a quick Google of
your name will reveal a rather lenghty list of personal attacks and theft of
your own McCarthy. I guess you forgot about all the stalking you did/do to
Mike Willams, eh? Pretending to be innocent when you are not is borderline
insane.


C Kevin Provance

unread,
Feb 1, 2009, 9:35:58 PM2/1/09
to

"Patrick Pirtle mka >" <PPirtle <atdotcom> wrote in message
news:bin3o4p2i686urjok...@4ax.com...

| Bill -
| First off, many thanks for the reply. Your user name cracked me up
| when I read it--Had some trouble with TPASoft, did you?

Quite the other way around. Ask Bill how often he visits and quotes my old
blog and then ask who the stalker is. Filthy Aussie.


Patrick Pirtle <PPirtle mka <dot> <com>>

unread,
Feb 5, 2009, 2:27:44 PM2/5/09
to
Larry -
Well, the ACTUAL situation is this:

1. We're structural engineers, and use a CAD program called
MicroStation.

2. We have extensively modified the program using VBA.

3. Early on, I found that my VBA form needed many more than
the maximum number of controls. I reworked it to incorporate
image maps instead. I purchased the VBImageMap control
from Silverband Software.

This control displays an image and reads a series of hot spot
coordinates from an HTML file. The HTML also associates a
name with each hot spot. When the user clicks the image
map, the control sets a string variable to the hot spot name.
I, then, simply do a SELECT CASE on the name as part of the
imagemap_click sub.

4. I don't know what language was used by Silverband, but
assume it's C.

Thanks, again, for your help and suggestions.
- Patrick

Patrick Pirtle <PPirtle mka <dot> <com>>

unread,
Feb 5, 2009, 3:25:36 PM2/5/09
to
Thanks to everyone for their help and suggestions. I think everything
is working fine, now.

Patrick Pirtle <PPirtle mka <dot> <com>>

unread,
Feb 5, 2009, 3:24:28 PM2/5/09
to
Woops! Guess I stepped into an ongoing "discussion." Hope everything
works out for all parties.

Larry Serflaten

unread,
Feb 5, 2009, 7:32:53 PM2/5/09
to

"Patrick Pirtle mka >" <PPirtle <atdotcom> wrote

> 2. We have extensively modified the program using VBA.

Cool.

> 3. Early on, I found that my VBA form needed many more than
> the maximum number of controls.

There is a common misconception in VB circles that there is such
a thing as a maximum number of controls, somewhere around 254
tops. This may also apply to VBA....

That is a misconception. There is no imposed limit by the language,
rather the limit is based on available memory. What is limited is the
number of control NAMES on a form. That limit is 254 control
NAMES.

But be advised, that all controls in a control array count as just
one name. For example, if you place one Checkbox on a form,
and then copy and paste that checkbox to the form, a message
box will pop up asking if you want a control array. Saying Yes
to that prompt creates a "control array" such that you can paste
2000 more Checkboxes to the form, all having the "name"
Check1 (differentiated by Index numbers). The same is
probably true for VBA....

If you put all your controls (Buttons, Labels, Textboxes,
Option and Checkboxes, etc) in control arrays, you could have
up to 250 (or so) different *types* of controls, with any reasonable
number of actual controls (up to the limits of system memory).
That really should be way more than enough for even the most
vigorous application....


> I reworked it to incorporate
> image maps instead. I purchased the VBImageMap control
> from Silverband Software.
>
> This control displays an image and reads a series of hot spot
> coordinates from an HTML file. The HTML also associates a
> name with each hot spot. When the user clicks the image
> map, the control sets a string variable to the hot spot name.
> I, then, simply do a SELECT CASE on the name as part of the
> imagemap_click sub.

All you really want to know here is where on the form the user
has clicked so you can translate that to different actions. It
would seem to me that doing so would leave behind the 3D
effects and animations (depressing buttons, selecting options
etc) inherant in the native controls. But if clicking on an image
is working for you, there are other ways to do the translation
that does not require any special control.

For one such method, you can lay an imaginary grid over your
image such that the cells in the grid can accurately define the
hot spots. Then it becomes a simple matter of filling an array
with identifying values that you associate with the different
hotspots. That entire array can be saved to disk, and read from
disk if you want a means to create loadable images.

Add the following code to a new form, run the program and
see how clicking on the different shapes can be easily handled....

HTH
LFS


Option Explicit
Private Spots(0 To 60, 0 To 30) As Byte

Private Sub Form_Load()
Me.AutoRedraw = True
Me.Move 2000, 2000, 6000, 3000
BuildArray
ShowGrid
ShowImage
End Sub


Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

' Translate to grid coordinates
X = X / 100
Y = Y / 100
' Translate to action
If (X < 60) And (Y < 30) Then
DoClick Spots(X, Y)
End If
End Sub

Sub DoClick(ByVal Index)
Select Case Index
Case 1: MsgBox "You clicked on the square"
Case 2: MsgBox "You clicked on the circle"
Case 3: MsgBox "You clicked on the triangle"
Case 100: ShowImage
Case 101: ShowGrid
End Select
End Sub

Sub BuildArray()
Dim X, Y

' Buttons
For Y = 0 To 2
For X = 0 To 6
Spots(X, Y) = 100
Spots(X + 10, Y) = 101
Next X, Y
' Square (1)
For Y = 1 To 9
For X = 1 To 9
Spots(X, Y + 5) = 1
Next X, Y
' Circle (2)
For Y = 1 To 5
For X = 0 To 6.2 Step 0.065
Spots(19 + Int(Sin(X) * Y), 10 + Int(Cos(X) * Y)) = 2
Next X, Y
Spots(19, 15) = 0
' Triangle (3)
For Y = 0 To 12
For X = 0 To Y
Spots(40 + X, 3 + Y) = 3
Spots(40 - X, 3 + Y) = 3
Next X, Y
End Sub

Sub ShowGrid()
Dim X, Y
Cls
For Y = 0 To 30
For X = 0 To 60
If Spots(X, Y) > 0 Then
Line (X * 100, Y * 100)-Step(100, 100), vbWhite, BF
Else
Line (X * 100, Y * 100)-Step(100, 100), BackColor, BF
End If
Line (X * 100, Y * 100)-Step(100, 100), &HCCCCCC, B
Next X, Y
ShowCaptions
End Sub

Sub ShowImage()
Cls
Line (0, 0)-Step(700, 300), vbBlack, B
Line (1000, 0)-Step(700, 300), vbBlack, B
Line (100, 600)-Step(900, 900), vbBlack, B
Circle (1900, 1000), 500
Line (2800, 1600)-Step(1250, -1300)
Line -Step(1250, 1300)
Line -Step(-2500, 0)
ShowCaptions
End Sub

Sub ShowCaptions()
PSet (130, 30), Point(130, 30)
Print "Image"
PSet (1200, 30), Point(1200, 30)
Print "Grid"
End Sub


Karl E. Peterson

unread,
Feb 5, 2009, 7:38:45 PM2/5/09
to
Larry Serflaten wrote:
> "Patrick Pirtle mka >" <PPirtle <atdotcom> wrote
>
>> 2. We have extensively modified the program using VBA.
>
> Cool.
>
>> 3. Early on, I found that my VBA form needed many more than
>> the maximum number of controls.
>
> There is a common misconception in VB circles that there is such
> a thing as a maximum number of controls, somewhere around 254
> tops. This may also apply to VBA....

Nope.

> That is a misconception. There is no imposed limit by the language,
> rather the limit is based on available memory. What is limited is the
> number of control NAMES on a form. That limit is 254 control
> NAMES.
>
> But be advised, that all controls in a control array count as just
> one name.

VBA doesn't support Control arrays. :-(

0 new messages