Hi,
If someone could guide me to a website, book, .. any resource
to find info about how to check for standard windows messages
WM_*, EM_* and so on. And how to declare the handlers (functions, subs)
Any help is greatly appreciated.
Thank You
Dennis
Printable View
Hi,
If someone could guide me to a website, book, .. any resource
to find info about how to check for standard windows messages
WM_*, EM_* and so on. And how to declare the handlers (functions, subs)
Any help is greatly appreciated.
Thank You
Dennis
You need to subclass you App.
Add to a Module
VB Code:
Public Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong 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 WndProcOld As Long Private Const WM_CLOSE = &H10 Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long If hwnd = WM_CLOSE Then MsgBox "App is closing" WindProc = CallWindowProc(WndProcOld&, hwnd&, wMsg&, wParam&, lParam&) End Function Sub SubClassWnd(hwnd As Long) WndProcOld& = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindProc) End Sub Sub UnSubclassWnd(hwnd As Long) SetWindowLong hwnd, GWL_WNDPROC, WndProcOld& WndProcOld& = 0 End Sub
Usage:
VB Code:
Private Sub Form_Load() SubClassWnd hwnd End Sub Private Sub Form_Unload(Cancel As Integer) UnSubclassWnd hwnd End Sub