Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Friends,

I am trying to come up with a custom position control (trackbar you can say :D). I have a background horizontal bar (picturebox) over which I have the slider(another picturebox). Essentially, the slider should move based on where the user clicks on the background bar. For that, I need to somehow find the coordinates where the user clicked on the back image. I tried the cursor object. However, it gives co-ordinates relative to the container control's dimensions. I would want it to be relative to the user control's dimensions, coz based on those (static) values, I need to move the slider.

Any ideas how this can be done?

Do let me know.

DNM

Posted
The MouseEventArgs (in MouseDown) work perfect. I am able to move the slider left n right. However, how do I simulate dragging? When the slider is held and dragged, it should move on the horizontal path. But how??
Posted

Try:


   Private _mouseDown As Boolean
   Private _oldX As Integer

   Private Sub PictureBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseDown

       _mouseDown = True
       _oldX = e.X

   End Sub

   Private Sub PictureBox2_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseUp
       _mouseDown = False
   End Sub

   Private Sub PictureBox2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseMove

       If _mouseDown Then

           PictureBox2.Left = e.X - (_oldX - PictureBox2.Left)

       End If
   End Sub

Here's what I'm up to.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...