Results 1 to 2 of 2

Thread: SendMessage: Move Object on X position only

  1. #1

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Question SendMessage: Move Object on X position only

    Hello,

    Trying to move an object inside Picturebox borders.

    I've tried a few methods, with get/setcapture etc.. the following works best only if I could limit the dragging to the X position of the mouse?

    Code:
    ReleaseCapture
    SendMessage picDraw.hwnd, &H112, &HF012&, 0
    Is there a way to intervene and set the x/y pos?
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: SendMessage: Move Object on X position only

    I don't think you can override that unless you also subclass the control. But there's a very easy solution.
    Code:
    Option Explicit
    
    Dim m_DragX As Single
    Dim m_Dragging As Boolean
    
    Private Sub picDraw_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbLeftButton Then
            m_Dragging = True
            m_DragX = X
        End If
    End Sub
    
    Private Sub picDraw_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If m_Dragging Then picDraw.Left = (picDraw.Left - m_DragX) + X
    End Sub
    
    Private Sub picDraw_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        m_Dragging = False
    End Sub
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width