Results 1 to 6 of 6

Thread: Menu

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Location
    I'm right here!
    Posts
    849
    How can I make a right click menu?
    please add a code...

  2. #2
    Guest
    Ok, you need two forms (Form1 and Form2). Form1 will be your main form, Form2 will be the menu form. On Form2, create a menu (using the MenuEditor) with whatever name. mnuFile we will call it.
    And put whatever you want through there:

    File (mnuFile)
    ....About (mnuAbout)
    ....Minimize (mnuMini)
    ....Exit (mnuExit)

    And on form1, put this code where you want the menu to popup (command button).

    Code:
    Private Sub Command1_Click()
    PopupMenu Form2.mnuFile
    End Sub

  3. #3
    Guest
    Why use 2 Forms? Instead, you should place them in the same Form and make them invisible.

  4. #4
    Guest
    You could do that, but what if the form is borderless? Than the title bar will still show up and the form won't be borderless anymore.

  5. #5
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    Or ... seeing wonderful new user potential ... you could ask me to e-mail you a sample project for creating Pop-up menus that will show on borderless forms without the nedd for a second form

    Also, you can easily add icons, bitmaps different selected colours/patterns.

    Just say the word or e-mail me, and I'll be more than happy to gove my project to another innocent victim/user.
    Courgettes.

  6. #6
    Guest
    Originally posted by Matthew Gates
    You could do that, but what if the form is borderless? Than the title bar will still show up and the form won't be borderless anymore.
    Then use CreatePopupMenu
    Code:
    Private Declare Function AppendMenu Lib "user32" Alias "AppendMenuA" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
    Private Declare Function CreatePopupMenu Lib "user32" () As Long
    Private Declare Function DestroyMenu Lib "user32" (ByVal hMenu As Long) As Long
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    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
    Const MF_STRING = &H0&
    Private Type POINTAPI
        x As Long
        y As Long
    End Type
    Private hMenu As Long
    Private PT As POINTAPI
    
    Private Sub Form_Load()
        hMenu = CreatePopupMenu()
        AppendMenu hMenu, MF_STRING, 0, "New Menu"
    End Sub
    
    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
        Call GetCursorPos(PT)
        If Button = 2 Then
            TrackPopupMenu hMenu, 0, PT.x, PT.y, 0, hwnd, 0&
        End If
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        DestroyMenu hMenu
    End Sub

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