есть окно (свойство BorderStyle=0) и естественно что системного меню для него нет.
как создать такое меню с такими пунктами: Закрыть, Свернуть, Востановить ?
Тебе что, лень было проверить? Кому оно надо? Мне?с помощью сабклассинга отловить момент, когда кликают правой кнопкой по проге в панели задач
WM_NCACTIVATE
WM_ACTIVATE
WM_ACTIVATEAPP
WM_KILLFOCUS
WM_WINDOWPOSCHANGING
WM_ACTIVATEAPP
WM_NCACTIVATE
WM_ACTIVATE
WM_SETFOCUS
4186
127
787
А вот тут по-любому в поиск. Ищи SetWindowLong и GWL_WNDPROCс помощью сабклассинга
Private Sub Form_Load()
OldWindowProc = GetWindowLong(Me.hwnd, GWL_WNDPROC)
Call SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf SubClass1_WndMessage)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call SetWindowLong(Me.hwnd, GWL_WNDPROC, OldWindowProc)
End Sub
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 OldWindowProc As Long
Public Function SubClass1_WndMessage(ByVal hwnd As Long, ByVal Msg As Long, ByVal wp As Long, ByVal lp As Long) As Long
Debug.Print EvntName(Msg)
SubClass1_WndMessage = CallWindowProc(OldWindowProc, hwnd, Msg, wp, lp)
End Function
Private Function EvntName(e As Long) As String
Select Case e
Case &H10
EvntName = "WM_CLOSE"
Case &H2
EvntName = "WM_DESTROY"
Case &HF
EvntName = "WM_PAINT"
Case &H1
EvntName = "WM_CREATE"
Case &H113
EvntName = "WM_TIMER"
Case &H8
EvntName = "WM_KILLFOCUS"
Case &H18
EvntName = "WM_SHOWWINDOW"
Case &H203
EvntName = "WM_LBUTTONDBLCLK"
Case &H202
EvntName = "WM_LBUTTONUP"
Case &H20
EvntName = "WM_SETCURSOR"
Case &H21
EvntName = "WM_MOUSEACTIVATE"
Case &H22
EvntName = "WM_CHILDACTIVATE"
Case 70
EvntName = "WM_WINDOWPOSCHANGING"
Case 71
EvntName = "WM_WINDOWPOSCHANGED"
Case 132
EvntName = "WM_NCHITTEST"
Case 3
EvntName = "WM_MOVE"
Case 7
EvntName = "WM_SETFOCUS"
Case 13
EvntName = "WM_GETTEXT"
Case 14
EvntName = "WM_GETTEXTLENGTH"
Case 20
EvntName = "WM_ERASEBKGND"
Case 512
EvntName = "WM_MOUSEFIRST"
Case 307
EvntName = "WM_CTLCOLOREDIT"
Case 309
EvntName = "WM_CTLCOLORBTN"
Case 133
EvntName = "WM_NCPAINT"
Case 5
EvntName = "WM_SIZE"
Case 6
EvntName = "WM_ACTIVATE"
Case 134
EvntName = "WM_NCACTIVATE"
Case 312
EvntName = "WM_CTLCOLORSTATIC"
Case 28
EvntName = "WM_ACTIVATEAPP"
Case 130
EvntName = "WM_NCDESTROY"
Case 36
EvntName = "WM_GETMINMAXINFO"
Case 129
EvntName = "WM_NCCREATE"
Case 160
EvntName = "WM_NCMOUSEMOVE"
Case 131
EvntName = "WM_NCCALCSIZE"
Case 161
EvntName = "WM_NCLBUTTONDOWN"
Case 123
EvntName = "WM_CONTEXTMENU"
Case 533
EvntName = "WM_CAPTURECHANGED"
Case &H4E
EvntName = "WM_NOTIFY"
Case Else
EvntName = e
End Select
End Function
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Const GWL_STYLE = (-16)
Const GWL_EXSTYLE = (-20)
Const WS_SYSMENU = &H80000
Const WS_EX_APPWINDOW = &H40000
Dim GWL As Long
Dim GWLEX As Long
Private Sub Form_Load()
GWLEX = GetWindowLong(hwnd, GWL_EXSTYLE)
Call SetWindowLong(hwnd, GWL_EXSTYLE, GWLEX Or WS_EX_APPWINDOW)
GWL = GetWindowLong(hwnd, GWL_STYLE)
Call SetWindowLong(hwnd, GWL_STYLE, GWL Or WS_SYSMENU)
End Sub
Сейчас этот форум просматривают: Google-бот, SemrushBot и гости: 184