[Originally posted by tango]

Hi!

I want to display the form's menu say 'mnuFile' with some subitems say 'new', 'open' and 'save' in the form's system menu.
I have added items to the form's system menu through the following code, but i am unable to add a form's menu (mnuFile) to the system menu.

Please have a look and suggest, how can i do this.

Thanks in advance
Tango

'''''''''''''''
'FORMS CODE
Option Explicit

Private Sub Form_Activate()
Dim SYSMENU1 As Long
Dim x As Long
x = CreatePopupMenu()
SYSMENU1 = GetSystemMenu(hWnd, False)
ModifyMenu SYSMENU1, 0, MF_BYPOSITION + MF_POPUP, x, "MYMENU"
InsertMenu x, 0, MF_BYPOSITION, 1, "1"
InsertMenu x, 1, MF_BYPOSITION, 2, "2"
OldWinProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf NWP)
End Sub
'''''''''''

'BAS MODULE CODE
Option Explicit
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
(ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public 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 Long
Public Declare Function AppendMenu Lib "user32" Alias "AppendMenuA" (ByVal hMenu As Long, _
ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As String) As Long
Public Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Public 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 String) As Long
Public Declare Function CreatePopupMenu Lib "user32" () As Long

Public Const MF_APPEND = &H100&
Public Const MF_BYCOMMAND = &H0&
Public Const MF_BYPOSITION = &H400&
Public Const MF_DISABLED = &H2&
Public Const MF_ENABLED = &H0&
Public Const MF_INSERT = &H0&
Public Const MF_MENUBARBREAK = &H20&
Public Const MF_POPUP = &H10&
Public Const MF_SEPARATOR = &H800&
Public Const MF_STRING = &H0&
Public Const MF_SYSMENU = &H2000&
Public Const WM_COMMAND = &H111
Public Const WM_SYSCOMMAND = &H112
Public Const GWL_WNDPROC = (-4)
Public OldWinProc As Long
Dim mresult

Public Function NWP(ByVal inHWND As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Error GoTo err
If Msg = WM_SYSCOMMAND Then
If wParam >= 1 And wParam <= 50 Then
If wParam = 1 Then
MsgBox &quot;1&quot;
Exit Function
ElseIf wParam = 2 Then
MsgBox &quot;2&quot;
Exit Function
End If
Exit Function
End If
If wParam = 0 Then
MsgBox &quot;u clicked me!&quot;
Exit Function
End If
End If
NWP = CallWindowProc(OldWinProc, inHWND, Msg, wParam, lParam)
err:
Exit Function
End Function
'''''''''''''''''''''''''''''''''