|
-
Sep 6th, 2000, 04:19 PM
#1
Thread Starter
Fanatic Member
How can I make a right click menu?
please add a code...
-
Sep 6th, 2000, 04:28 PM
#2
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
-
Sep 6th, 2000, 04:35 PM
#3
Why use 2 Forms? Instead, you should place them in the same Form and make them invisible.
-
Sep 6th, 2000, 04:45 PM
#4
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.
-
Sep 7th, 2000, 01:32 PM
#5
Fanatic Member
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.
-
Sep 7th, 2000, 04:08 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|