Add the ABOUT to the window system menu

zhaozj2021-02-16  46

If you can put some information about the software (About Me), the system menu is very cool! In fact, this is a very simple operation, let's go!

1. Add a module (SUBCLASS) '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ''ENU LIB "USER32 "(ByVal hWnd As Long, ByVal bRevert As Long) As LongPublic 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 const mf_bycommand = & h0 & public const mf_byposition = & h400 & public const mf_string = & h0 & public const mf_separator = & h800 &

'APIPrivate Declare message about the window processing Function SetWindowLong Lib "user32" Alias ​​_ "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex _ As Long, ByVal dwNewLong As Long) As Long Private 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 Const GWL_WNDPROC = (-4 &) Const WM_SYSCOMMAND = & H112Const WM_DESTROY = & H2

DIM PrevwndProc &

Public Sub INIT (HWND As Long) prevwndproc = setwindowlong (hwnd, gwl_wndproc, addressof subwndproc) End Sub

Public Sub Terminate (hWnd As Long) Call SetWindowLong (hWnd, GWL_WNDPROC, PrevWndProc) End SubPrivate Function SubWndProc (ByVal hWnd As Long, ByVal Msg As Long, _ ByVal wParam As Long, ByVal lParam As Long) _ As Long If Msg = WM_DESTROY Then Terminate (Form1.hWnd) If Msg = WM_SYSCOMMAND Then If wParam = 2002 Then MsgBox "I'm 40Star", vbInformation, "hia..hia ..." End If End If SubWndProc = CallWindowProc (PrevWndProc, hWnd, Msg, wParam , LPARAM) End Function

2. Add '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ''. '' '' '' ' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ''NU GetSystemMenu (Me.hwnd, False) , 0, MF_BYPOSITION OR MF_SEPARATOR, 2001, "" Add a split line InsertMenu getSystemMenu (me.hwnd, false), 0, mf_byposition or mf_string, 2002, "About me (& a)" joins the About Me menu in the system menu Call init (me.hwnd) End Sub

3. Add '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '.' '' '' ' '' '' '' '' '' '' '' '' '' '' '' '' '' 'PRIVATE SUB FORM_UNLOAD (CANCEL AS INTEGER) CALL TERMINATE (ME. HWND) End Sub

OK! Run it, is it very fun :) In Win2000 VB6, debugging through Good Luck

转载请注明原文地址:https://www.9cbs.com/read-27516.html

New Post(0)