An example of using the API to change the system menu and copy the system menu. (Need to note: If you want to respond to the menu item, you might want to use the hook function and more code)
Option expedition
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 LongPrivate Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As LongPrivate Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpString As Any) As LongPrivate Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As LongPrivate Declare Function InsertMenu Lib "user32" Alias "InsertMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long , BYVAL LPNEWITEM AS ANY) As longign = & h0 & private hsysmenu as longprivate type point Pointapi x ask Y ask TYPE
Function Num (I as integer) AS STRINGNUM = MID ("I hate the song Hanhuang heavy color thinking, Yusu has been doing you for many years. Yang family has a long-term long-term growth, raising it in the deep people. The natural beauty is difficult to discard, one selection On the Jun King side. Looking back and smile, the six flour powder is no color. The spring is a bath, the hot spring water is slipping. The waiter will help the prosthetic, and it is a new year. Yunxiao Hui Jin step shake, hibiscong account The warmth is spring. Spring is high, from this king is not early. ", 8 * i 1, 8) end function
Private Sub Form_Load () Dim i as integerHsysmenu = getSystemMenu (HWND, FALSE) 'System menu handle
INSERTMENU HSYSMENU, 0, & H800, & H0, "" Add Section for i = 0 to 5ModifyMenu Hsysmenu, I, & H4410, 0, Num (i 1) 'Change the menu entry next NEXT
For i = 6 to 15
INSERTMENU HSYSMENU, I, & H400, & H0, NUM (i 1) 'Insert Menu Entries Next' i = 6 Correspondence Entries To Off Button, this setting is to leave this entry
InsertMenu Hsysmenu, 0, & H800, & H0, "" Add Section Insertmenu Hsysmenu, 0, & H400, & H0, Num (0) Me.Move Screen.Width / 2 - 3000, Screen.Height / 2 - 2000, 6000, 4000 'Form hin me.caption = "Please use the mouse button to call out the system menu !!!" End Sub
Private Sub Form_MouseUp (Button As Integer, Shift As Integer, x As Single, y As Single) Dim Pts As POINTAPI GetCursorPos Pts' Get the mouse position If Button = 2 Then TrackPopupMenu hsysmenu, TPM_LEFTALIGN, Pts.x, Pts.y, 0, Me.hwnd, Byval 0 & 'pops up the changed system menu end subcaping in the mouse
The effect is as follows: