Co-ords over a picture?
Co-ords over a picture?
Co-ords over a picture?
Co-ords over a picture?
Co-ords over a picture?
Co-ords over a picture? Co-ords over a picture? Co-ords over a picture? Co-ords over a picture? Co-ords over a picture? Co-ords over a picture? Co-ords over a picture? Co-ords over a picture?
Co-ords over a picture? Co-ords over a picture?
Co-ords over a picture?
Go Back  Xtreme Visual Basic Talk > > > Co-ords over a picture?


Reply
 
Thread Tools Display Modes
  #1  
Old 01-05-2004, 11:29 AM
Carlip Carlip is offline
Freshman
 
Join Date: Dec 2003
Posts: 26
Question Co-ords over a picture?


I have a map of an area.
I want, so when the mouse is moved over the picture, the x and y co-ords are displayed in a seperate label.

Any help will be much appreciated. thanks in advance.
Reply With Quote
  #2  
Old 01-05-2004, 11:50 AM
OnErr0r's Avatar
OnErr0rCo-ords over a picture? OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,774
Default

Code:
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove Label1.Text = "X: " & e.X.ToString & " Y: " & e.Y.ToString End Sub
Reply With Quote
  #3  
Old 01-05-2004, 01:18 PM
Carlip Carlip is offline
Freshman
 
Join Date: Dec 2003
Posts: 26
Default

Thanx!
That helps a lot!
Reply With Quote
  #4  
Old 01-05-2004, 01:23 PM
Carlip Carlip is offline
Freshman
 
Join Date: Dec 2003
Posts: 26
Default

i get a error highlighting "handles".....?

any ideas?
Reply With Quote
  #5  
Old 01-05-2004, 04:21 PM
OnErr0r's Avatar
OnErr0rCo-ords over a picture? OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,774
Default

You posted in the VB.NET section. Did you mean to use legacy vb5/6?
Reply With Quote
  #6  
Old 01-05-2004, 05:53 PM
Carlip Carlip is offline
Freshman
 
Join Date: Dec 2003
Posts: 26
Default

ah yes, i am using vb6....sorry, there were 2 sections...oops!
Reply With Quote
  #7  
Old 01-05-2004, 07:49 PM
OnErr0r's Avatar
OnErr0rCo-ords over a picture? OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,774
Default

The code is very similar. Use the mousemove event and the X/Y parameters.
Reply With Quote
  #8  
Old 01-06-2004, 04:20 AM
Carlip Carlip is offline
Freshman
 
Join Date: Dec 2003
Posts: 26
Default

I'm so sorry, i'm new to all this visual basic malarky....lol.
I'm stuck...
Reply With Quote
  #9  
Old 01-06-2004, 10:01 AM
OnErr0r's Avatar
OnErr0rCo-ords over a picture? OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,774
Default

Label1.Caption = "X: " & CStr(X) & " Y: " & CStr(Y)
Reply With Quote
  #10  
Old 01-06-2004, 10:14 AM
Carlip Carlip is offline
Freshman
 
Join Date: Dec 2003
Posts: 26
Default

i keep getting a compile error, "user-defined type not defined"
And it highlights my variables....!?

Last edited by Carlip; 01-07-2004 at 04:48 AM.
Reply With Quote
  #11  
Old 01-07-2004, 04:50 AM
Carlip Carlip is offline
Freshman
 
Join Date: Dec 2003
Posts: 26
Default

Any help?
Reply With Quote
  #12  
Old 01-08-2004, 04:32 AM
stevie52 stevie52 is offline
Newcomer
 
Join Date: Dec 2003
Posts: 13
Default

Make a mouseMove in your picturebox

and in the mousemove:

label1.caption = "X = " & X & " Y = " & Y

Hope it helps.


stevie
Reply With Quote
  #13  
Old 01-08-2004, 04:40 AM
Carlip Carlip is offline
Freshman
 
Join Date: Dec 2003
Posts: 26
Default

not being silly, but how do u create a mouse move in the picture box
Reply With Quote
  #14  
Old 01-08-2004, 08:13 AM
passel's Avatar
passelCo-ords over a picture? passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,024
Default

The Picture box already provides a MouseMove event handler. You just
need to add code to it. The parameters are already defined. Because
you originally posted in the .Net side, you got some .Net syntax, which
had a "Type" structure associated with it. Since you are not using .Net,
you just need to refer to the parameters X and Y that are passed.
If you manually typed in the Subroutine declaration, delete it.
Then select the picture box, and select the MouseMove sub from the
list of available event handlers. Add your code to it. It should be along
the lines of this (which is what people have been trying to convey to you).

Code:
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Label1.Caption = "X:" & Str$(X) & ", Y:" & Str$(Y) End Sub

You can use the Cstr function instead of the Str$ function (as OnErrOr
pointed out). I'm conditioned to the older Str$ function. The main
visible difference is that the Str$ function adds a space to the front of
the string (where the negative sign would go if the number was
negative), whereas the Cstr function does not add the space to the
begining of the string.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.

Last edited by passel; 01-08-2004 at 08:21 AM.
Reply With Quote
  #15  
Old 01-08-2004, 08:22 AM
Carlip Carlip is offline
Freshman
 
Join Date: Dec 2003
Posts: 26
Default

Thanks passel!

And the rest who helped, problem solved!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting grafics to a picture TheMole Interface and Graphics 5 12-30-2003 08:11 AM
Insert picture with VBA (in Word 97) vadnick Word, PowerPoint, Outlook, and Other Office Products 2 11-25-2003 08:02 AM
Picture Box to Picture Box Mediator Interface and Graphics 1 10-03-2003 09:58 PM
How to make sure correct Picture files reference hengkok General 5 05-22-2001 06:32 PM
Would Xtreme and Chris1232 Come Here Bunkey23 Game Programming 12 12-11-2000 02:25 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Co-ords over a picture?
Co-ords over a picture?
Co-ords over a picture? Co-ords over a picture?
Co-ords over a picture?
Co-ords over a picture?
Co-ords over a picture? Co-ords over a picture? Co-ords over a picture? Co-ords over a picture? Co-ords over a picture? Co-ords over a picture? Co-ords over a picture?
Co-ords over a picture?
Co-ords over a picture?
 
Co-ords over a picture?
Co-ords over a picture?
 
-->