codice:
'dichiarazioni API
Public Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function CreatePopupMenu Lib "user32" () 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 Any) As Long
Public Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (a As Any, B As Any, ByVal C As Long)
Public Declare Function SetMenuItemBitmaps Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal hBitmapUnchecked As Long, ByVal hBitmapChecked As Long) As Long
Public Declare Function RegisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
Public Declare Function UnregisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id 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 Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Public Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Public Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hwndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
Public Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Public Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook&, ByVal lpfn&, ByVal hmod&, ByVal dwThreadId&) As Long
Public Declare Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Public Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Public Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook&) As Long
Public Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long
'costanti
Public Const MF_POPUP = &H10& 'menù popup
Public Const MF_SEPARATOR = &H800& 'separatore
Public Const MF_BYCOMMAND = &H0&
Public Const MF_STRING = &H0&
Public Const MF_CHECKED = &H8&
Public Const MF_GRAYED = &H1&
Public Const MF_BYPOSITION = &H400&
Public Const MOD_ALT = &H1 'tasto ALT per shortcut
Public Const MOD_CONTROL = &H2 'tasto CTRL per shortcut
Public Const MOD_SHIFT = &H4 'tasto SHIFT per shortcut
Public Const GWL_WNDPROC = (-4)
Public Const WM_HOTKEY = &H312
Public Const WM_SYSCOMMAND = &H112
Public Const WM_COMMAND = &H111
Public Const WM_SETCURSOR = &H20
Public Const WM_NCPAINT = &H85
Public Const WM_MOVE = &H3
Public Const SWP_FRAMECHANGED = &H20
Public Const GWL_EXSTYLE = -20
'type - enum
Public Enum MenuFlags
checked = &H1
Hidden = &H2
Grayed = &H4
PopUp = &H8
WindowList = &H20
LastItem = &H100
End Enum
Public Type struct_mnu
handle As Long
End Type
Public Type MenuStruct
Reserved(0 To 54) As Long 'se usato con vb5 cambiare 54 in 48
dwFlags As MenuFlags
lpNextMenu As Long
lpFirstItem As Long
lpszName As Long
hMenu As Long
wID As Integer
wShortcut As Integer
End Type
Public Type MenuStruct_exe
Reserved(0 To 51) As Long 'la struttura è purtroppo diversa tra IDE e EXE
dwFlags As MenuFlags
lpNextMenu As Long
lpFirstItem As Long
lpszName As Long
hMenu As Long
wID As Integer
wShortcut As Integer
End Type
Public Type CWPSTRUCT
lParam As Long
wParam As Long
Message As Long
hWnd As Long
End Type
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
'dichiarazioni variabili e matrici
Public mnu() As struct_mnu
Public lPrevWndProc As Long 'per subclassing
Public totshortcut As Integer 'totale shortcut creati,
Public handle_menu As Long 'handle del menù della form
Public handle_button_end As Long 'handle bottone
'nella barra del titolo, mi serve per toglierlo
'all'uscita del programma
Public xl As Long
Public hook_title_bar As Long
'dichiarazioni per altezza barra del titolo
Public Type NMLOGFONT
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName(28) As Byte
End Type
Public Type NONCLIENTMETRICS
cbSize As Long
iBorderWidth As Long
iScrollWidth As Long
iScrollHeight As Long
iCaptionWidth As Long
iCaptionHeight As Long
lfCaptionFont As NMLOGFONT
iSMCaptionWidth As Long
iSMCaptionHeight As Long
lfSMCaptionFont As NMLOGFONT
iMenuWidth As Long
iMenuHeight As Long
lfMenuFont As NMLOGFONT
lfStatusFont As NMLOGFONT
lfMessageFont As NMLOGFONT
End Type
Public Const SPI_GETNONCLIENTMETRICS = 41
Public m_tNCM As NONCLIENTMETRICS
Comunque se sei ancora convinta...