Imagemaps in VB 
Author Message
 Imagemaps in VB

Is there a way to use some kind of imagemaps (like in web pages) in VB6. So
an area on an image (picturebox or image control) corresponds to some VB
code. These areas are not just simple rectangles or circles but must be
freehand selected.

Plz help !!!



Sat, 20 Nov 2004 06:05:17 GMT  
 Imagemaps in VB

Quote:
> Is there a way to use some kind of imagemaps (like in web pages) in VB6.
So
> an area on an image (picturebox or image control) corresponds to some VB
> code. These areas are not just simple rectangles or circles but must be
> freehand selected.

See the image hotspots demo on my page.
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/




Sat, 20 Nov 2004 07:22:39 GMT  
 Imagemaps in VB

Quote:
> well, yes, the Point() function, you can specify that if the mouse pointer
> was in: x, y point, then change the cursor to a Hand, for instance.

Why would you need the Point() function to check to see if the cursor is in
a certain position?
If you're trying to check the point is in an area then you'd need to convert
the area to a region and use the PtInRegion() API to check to see if it's in
the region.
If you're not using the MouseMove() event of the control then you can also
use the GetCursorPos() then the ScreenToClient() API to convert the
coordinates to local client space.
If you have multiple regions then I still favour the image map method
despite it being slightly more memory intensive.
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/




Sat, 20 Nov 2004 10:28:12 GMT  
 Imagemaps in VB
There is an Image map control at
http://www.merrioncomputing.com/Download/index.htm (with source code)
that accepts HTML and generates MouseOver and MouseClick events for
the resulting map regions - it uses CreatePolyRgn and PtInRgn and
subclassing...

Hope this helps,
  Duncan Jones
  Merrion Computing Ltd



Sat, 20 Nov 2004 16:17:45 GMT  
 Imagemaps in VB

Quote:
> Is there a way to use some kind of imagemaps (like in web pages) in VB6. So
> an area on an image (picturebox or image control) corresponds to some VB
> code. These areas are not just simple rectangles or circles but must be
> freehand selected.

> Plz help !!!

Yes there is, it involves using a second image to detect the various shapes.
Here is an example, add a PictureBox to a new form and paste in the following
code.  Moving your mouse over the shapes changes the Caption.  The caption,
and simple squares and circles were used for demo purposes, but you can use the
same principle for your irregular shapes.  To see the underlying mask, hold down
the mouse button....

HTH
LFS

Option Explicit
Private Mask As PictureBox
Private Detection As New Collection

Private Sub Form_Load()
  ' Form set up
  ScaleMode = vbPixels
  AutoRedraw = True
  Move Left, Top, 2200, 2640
  ' Mask setup
  Set Mask = Picture1
  With Mask
    .Visible = False
    .BorderStyle = vbBSNone
    .Move 0, 0, 200, 200
    .AutoRedraw = True
    .ScaleMode = vbPixels
  End With

  DrawShape1 False, Me, vbBlack
  DrawShape1 True, Me, vbWhite
  DrawShape1 True, Mask, vbBlue

  DrawShape2 False, Me, vbBlack
  DrawShape2 True, Me, vbWhite
  DrawShape2 True, Mask, vbRed

  Detection.Add "SHAPE 1", CStr(vbBlue)
  Detection.Add "SHAPE 2", CStr(vbRed)
End Sub

Private Sub DrawShape1(Fill As Boolean, Target, Color As Long)
  Target.FillStyle = vbFSTransparent
  Target.FillColor = Color
  If Fill Then
    Target.Line (11, 11)-(29, 29), Color, BF
    Target.Line (61, 11)-(79, 29), Color, BF
    Target.FillStyle = vbFSSolid
    Target.Circle (45, 40), 24, Color
  Else
    Target.Line (10, 10)-(30, 30), Color, B
    Target.Line (60, 10)-(80, 30), Color, B
    Target.Circle (45, 40), 25, Color
  End If
End Sub

Private Sub DrawShape2(Fill As Boolean, Target, Color As Long)
  Target.FillStyle = vbFSTransparent
  Target.FillColor = Color
  If Fill Then
    Target.Line (11, 91)-(79, 119), Color, BF
    Target.FillStyle = vbFSSolid
    Target.Circle (45, 80), 24, Color
  Else
    Target.Line (10, 90)-(80, 120), Color, B
    Target.Circle (45, 80), 25, Color
  End If
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  Mask.Visible = True
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Detect As String
  On Error Resume Next
  Detect = Detection(CStr(Mask.Point(X, Y)))
  If Caption <> Detect Then Caption = Detect
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  Mask.Visible = False
End Sub



Sat, 20 Nov 2004 18:03:07 GMT  
 Imagemaps in VB

Quote:
> Here is an example, add a PictureBox to a new form and paste in the

following

Hey Larry -- I'm interested in this, but your example crashes with "Invalid
procedure call or argument" on this line:

Detect = Detection(CStr(Mask.Point(X, Y)))

in the Form_MouseMove event.

Its looking for a key in the collection with a number, and the collection
only has 2 members -- SHAPE 1 and SHAPE 2.

Is this an easy fix?  It looks like I'll need this soon, so that's why I'm
asking.

Matt



Sat, 20 Nov 2004 22:16:41 GMT  
 Imagemaps in VB

Quote:
> > Here is an example, add a PictureBox to a new form and paste in the
> following

> Hey Larry -- I'm interested in this, but your example crashes with "Invalid
> procedure call or argument" on this line:

> Detect = Detection(CStr(Mask.Point(X, Y)))

> in the Form_MouseMove event.

Here is the entire routine:

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Detect As String
  On Error Resume Next
  Detect = Detection(CStr(Mask.Point(X, Y)))
  If Caption <> Detect Then Caption = Detect
End Sub

When you pass the mouse over the form, it is going to pick up the color there,
but that color was not defined in the collection.  That is why I have the error trap
set, to exclude that situation.  When you pass the mouse over one of the shapes,
it should work fine.

If you are not getting the desired response, perhaps you have your configuration
set to break on all errors, when you need to break only on unhandled errors.

Have a look at your VB settings as Tools > Options > General

LFS



Sat, 20 Nov 2004 23:49:37 GMT  
 Imagemaps in VB

Quote:
> but that color was not defined in the collection.  That is why I have the
error trap
> set, to exclude that situation.

I'm a complete idiot.

I keep break on all errors turned on when coding so that it doesn't
automatically get passed to my error routine -- basically, I'd rather find
out WHY there's an error, and fix it, and leave the error handler there for
things that I don't think of or can't reproduce on my machine, but will
allow the user to continue and not crash.

Thanks.  That's 2 stupid questions I've asked in the past few weeks.  Back
to lurking.

Matt



Sun, 21 Nov 2004 22:53:49 GMT  
 Imagemaps in VB

   > Is there a way to use some kind of imagemaps
   > (like in web pages) in VB6. So an area on an
   > image (picturebox or image control) corresponds
   > to some VB code.
   > These areas are not just simple rectangles
   > or circles but must be freehand selected.

Our MetaDraw ActiveX control makes this easy.    MetaDraw allows you
to create images composed of multiple elements - lines, shapes,
polygons, other images, etc.   Each element of the image can be a
clickable hotspot.   You can even make invisible polygons as hotspots
overlayed on top of some other image.    You can use MetaDraw to
create your own drawing and hotspot creation utility or you can use
our HSEditor utility ( an EXE) to create hotspotted images which you
can load into your own application for end-users to click on hotspots.

Take a look at our web site at www.Bennet-Tec.Com for more information
and to download installation kit for trial use.

Drop me a note by e-mail to let me know if you receive this message
and if it seems like something you are interested in.
I'd be happy to send further information and/or answer any questions
you may have.

For detailed technical questions send e-mail to

demonstration mode or have presales questions).

* * Please include a copy of this note with your reply

        Jeff Bennett         President

        Bennet-Tec Information Systems, Inc  
        50 Jericho Tpk, Jericho, NY 11753
        Phone 516 997 5596,  Fax - 5597
        WWW.Bennet-Tec.Com  

        ActiveX Controls : TList/Pro  * ALLText HT/Pro * MetaDraw  
        and Custom Software Development Services

======================  ======================



Thu, 02 Dec 2004 05:44:06 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. ImageMaps in VB?

2. Imagemaps in VB

3. Imagemaps in VB

4. Imagemaps in VB

5. Detecting Mouse Click in Non-VB or VB app (in VB 6)

6. vb MSCOMM Control works in VB 5 and not VB 6

7. Debugging VB Usercontrols in VB without 2nd VB Test project

8. optimizing performance and data transfer vb->excel and vb->vb

9. optimizing performance and data transfer vb->excel and vb->vb

10. convert vb 3.1 to vb 6.0

11. ? Convert Macro to VB using VB

12. How can I convert this Excel VB code to Access VB

 

 
Powered by phpBB® Forum Software