Option Explicit
Private Sub Form_Load()
Dim mnuString As MENUITEMINFO
Dim mnuSeparator As MENUITEMINFO
mnuString.cbSize = Len(mnuString)
mnuString.fMask = MIIM_STRING Or MIIM_ID
mnuString.fType = MFT_STRING
mnuString.dwTypeData = "&About"
mnuString.wID = UDC_ABOUTMNU
InsertMenuItem GetMenu(Me.hwnd), GetMenuItemCount(GetMenu(Me.hwnd)) + 1, True, mnuString
ChangeWindowProc
End Sub
Option Explicit
Public Declare Function GetMenu Lib "user32.dll" (ByVal hwnd As Long) As Long
Public Declare Function GetSystemMenu Lib "user32.dll" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Public Declare Function InsertMenuItem Lib "user32.dll" Alias "InsertMenuItemA" (ByVal hMenu As Long, ByVal un As Long, ByVal bool As Boolean, ByRef lpcMenuItemInfo As MENUITEMINFO) As Long
Public Declare Function GetMenuItemCount Lib "user32.dll" (ByVal hMenu As Long) As Long
Public Type MENUITEMINFO
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As String
cch As Long
End Type
Public Const MF_STRING As Long = &H0&
Public Const MIIM_ID As Long = &H2
Public Const MIIM_STRING As Long = &H40
Public Const MFT_SEPARATOR = &H800
Public Const MFT_STRING = &H0
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex 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 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 Const GWL_WNDPROC = (-4)
Public Const UDC_ABOUTMNU As Long = 1
Global OldWndProc As Long
Public Sub ChangeWindowProc()
OldWndProc = SetWindowLong(Form1.hwnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub
Function WindowProc(ByVal hw As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Debug.Print msg
WindowProc = CallWindowProc(OldWndProc, hw, msg, wParam, lParam)
End Function
Сейчас этот форум просматривают: Yandex-бот и гости: 116