when i move cursor on image in one location it should display some information, and moving cursor in another location ,and need to display some other information. help me with visual basic 6.0 code. thanks

What have you already tried? We don't usually provide detailed help if you don't show any effort first. However, I'm feeling charitable today, so I can point you in the right direction.

Depending on when you want to display information (as in "When the mouse gets there" or "When the user clicks a specific point") use either the MouseMove event or the MouseDown event. Here's some sample code to get you started:

Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Label1.Caption = "Mouse Position (X, Y): " & Str(X) & ", " & Str(Y)

End Sub

Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Label1.Caption = "Mouse Position (X, Y): " & Str(X) & ", " & Str(Y)

End Sub

Keep in mind that this will require an Image control named "Image1" and a Label control named "Label1" on a form. It helps if you pre-load a bitmap into your Image control so you can see where the "hotspots" are so you can figure out what your click zones are going to look like.

Hope this helps! Good luck!

'Add one image control on your form and then copy paste the following line 
'of code in code window

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Me.Caption = X & " , " & Y
End Sub

Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Me.Caption = X & " , " & Y
End Sub
 >  when i move cursor on image in one location it should display 
 >  some information, and moving cursor in another location ,
 >  and need to display some other information. 
 >  help me with visual basic 6.0 code. thanks

As other replies have indicated you can easily capture the X/Y location in the MouseMove. If that is enough for you to identify what data to show - great.

If you are looking for a way to create hotspots on an image, potentially of any shape, then you may want to look at the MetaDraw 3 OCX component. [ *Disclosure - I represent the company that created this component *]. MetaDraw is a picturebox type control you can use in VB 6 that allows you to set up multiple hotspots for any image, and assign hidden data to each hotspot. You can read this hidden data within MetaDraw events whenever the user moves into / over / out of a hotspot, or when he clicks or double clicks a hotspot. You can also tell MetaDraw to automatically change the mouse cursor when over a hotspot.

For example on an image of a map where each state is a hotspot, with hidden data for state name and population you might write:

        Sub MetaDraw_OnHotSpot(ByVal X As Long, _
        ByVal Y As Long, State As Integer)
            Select Case State
                Case EHS_ENTER
                     txtState.Text = MetaDraw.ObjTags("StateName")
                     txtPopulation.Text = MetaDraw.ObjTags("Population")
                Case EHS_LEAVE
                     txtState.Text = ""
                     txtPopulation.Text = ""
             End Select
        End Sub

To have a seperate application, or separate mode for an application
where the user can hotspots, simply set the MetaDraw.EditMode property
to allow the user to draw shapes ( rectangles, ellipses, polygons, freehand shape, ... )
MetaDraw will automatically take care of drawing and displaying the shape.
You can then capture the Change event upon completion of each drawn shape
and get the desired data for the shape and make it a hotspot to be hidden in
View mode

   Sub CmdCreateHotspot_Click()
        ' Allow user to draw polygon shapes
        MetaDraw1.EditMode = ED_Polygon
    End Sub

    Sub MetaDraw1_Change(ByVal ChangeType As Integer)
        With MetaDraw1
            If ChangeType = CHG_OBJECTADDED Then
                ' - user just drew some shape
                ' - make it a hotspot, 
                ' - have cursor automatically change on object,
                ' - and trigger event when user clicks on it
                .ObjHotSpot = OS_CURSOR Or OS_CLICK Or OS_HOTSPOT
                .ObjVisible = False
                ' - ask user to assign data for a couple of named tags 
                ' - for this hotspot.  You can use any tag names you like
                .ObjTags("HotspotName") _
                   =  InputBox("Please assign some Name for this hotspot")
                .ObjTags("SomeData") _
                   = InputBox("Please assign some Data for this hotspot")
            End If
        End With        
    End Sub

I hope this is helpful.

For more information about MetaDraw see:
www.Bennet-Tec.com/btproducts/MetaDraw

Also here are two samples showing use of Hotspots in MetaDraw within a Web

Create Hotspots - http://www.bennet-tec.com/btproducts/MetaDraw/WebSamples/Hotspots/md3_HotspotDemo.htm

Clickable Hotspot Map - http://www.bennet-tec.com/btproducts/MetaDraw/WebSamples/MD3Map/md3_map.htm

You can see the underlying code for either of these examples by right clicking in the web page
( outside the MetaDraw control ) and selecting "View Source" .

Jeff Bennett

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.