Results 1 to 3 of 3

Thread: GetCursorPos API problem

  1. #1

    Thread Starter
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Angry

    I just write the following code in the Treeview_MouseDown event:

    Code:
    Dim Px As Long
    Dim Py As Long
    If Button = vbRightButton Then
        GetCursorPos pt
        Px = ScaleX(pt.x, vbPixels, vbTwips)
        Py = ScaleY(pt.y, vbPixels, vbTwips) - 250
    
        PopupMenu mnuOPTION, vbPopupMenuLeftAlign, Px, Py
    End If
    When my form in Maximized mode, everything is fine, PopUpmenu just beside my mouse pointer. But if I resize my form then the problem come out and I can not set the PopUpmenu right beside my mouse pointer.

    It is something wrong with my code? Does anyone have a better solution for the PopUpMenu?

    Thanks,
    Chris.C

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    You don't have to specify any options for the PopupMenu:
    Code:
    Private Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
        If Button = vbRightButton Then
            PopupMenu mnuOPTION
        End If
    End Sub
    vbPopupMenuLeftAlign is a default option, so you don't have to specify it. Also, if you ommit coordinates, then it will use mouse coordinates by default.

  3. #3

    Thread Starter
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Thumbs up

    Wow, that great. Serge, thanks for you tips.

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