Results 1 to 3 of 3

Thread: Yet another question

  1. #1

    Thread Starter
    Registered User Olly's Avatar
    Join Date
    Apr 2001
    Location
    Switzerland
    Posts
    252

    Smile Yet another question

    Does anyone of you guys know how to popup the titlebar menu (the menu that pops up when you click onto the program icon or rightclick onto the taskbar) anywhere on the form, for example under a button when you press it?

    thx in advance
    Last edited by Olly; Apr 26th, 2001 at 10:51 AM.

  2. #2
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    Code:
    Const TPM_LEFTALIGN = &H0&
    Const TPM_RETURNCMD = &H100&
    Const WM_SYSCOMMAND = &H112
    
    
    Private Type POINTAPI
        x As Long
        y As Long
    End Type
    
    Private Declare Function TrackPopupMenu Lib "user32" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal x As Long, ByVal y As Long, ByVal nReserved As Long, ByVal hwnd As Long, ByVal lprc As Any) As Long
    Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
    
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    
    
    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
        Dim Pt As POINTAPI
        Dim retval As Long
        'Get the position of the mouse cursor
        GetCursorPos Pt
        
        retval = TrackPopupMenu(GetSystemMenu(Me.hwnd, False), TPM_LEFTALIGN Or TPM_RETURNCMD, Pt.x, Pt.y, 0, Me.hwnd, ByVal 0&)
        PostMessage Me.hwnd, WM_SYSCOMMAND, retval, 0&
        
    End Sub
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  3. #3

    Thread Starter
    Registered User Olly's Avatar
    Join Date
    Apr 2001
    Location
    Switzerland
    Posts
    252

    Thumbs up

    excellent! Although I use the api-viewer and know some of these api calls I still need more praxis using them thx

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