|
-
Mar 27th, 2001, 05:49 AM
#1
Thread Starter
Member
I need to capture the wm_paint event from a window other than a visual basic window, anyone got any idea's how to do it???
-
Mar 27th, 2001, 06:12 AM
#2
Hyperactive Member
I've wondered to.
I've wondered that to, and I know it's definatley possible, but maybe not with VB as such, cause all them Spy Utilities do it.
Anyway, anyone with info please share
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Mar 27th, 2001, 04:48 PM
#3
SubClass your window.
Add to a Module
Code:
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
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_PAINT = &HF
Global WndProcOld As Long
Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If wMsg = WM_PAINT Then Debug.Print "PRINT MESSAGE SENT"
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
Add to a Form
Code:
Private Sub Form_Load()
SubClassWnd hwnd
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnSubclassWnd hwnd
End Sub
-
Mar 27th, 2001, 11:29 PM
#4
Good Ol' Platypus
Subclassing works with everything right, as long as you have the hWnd?
That is cool, I could subclass games to stop redrawing, that would be creepy
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Mar 28th, 2001, 04:23 PM
#5
Yes, Subclassingworks as long as you have the hWnd, and as long as it has it's in the same thread as yours.
To subclass windows that are not in your thread, you need to place you routine in a standard DLL.
-
Mar 29th, 2001, 05:58 AM
#6
Thread Starter
Member
yeah cheers for all your help, I found out it can only be placed in a dll, but I also found out you can't wrtie the dll in vb, you have to do it in c++. Oh well better get me C++ manual out...lol
-
Mar 29th, 2001, 03:33 PM
#7
Well, it doesn't really have to be written in C++. C++ is just the idle language to do it in. The DLL can be written in any environment that can create standard DLLs, e.g: Delphi.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|