Subclassing Application.hWndAccessApp catching WM_USER

S

stefan hoffmann

hi,

i am subclassing Application.hWndAccessApp to catch user messages
(WM_USER). It works, but it makes Access _very_ instable.

Is there a better way to catch messages sent to Access?


mfG
--> stefan <--

Public Function WndProc(ByVal hWnd As Long, _
ByVal Msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long _
) As Long
Select Case Msg
Case WM_USER:
MsgBox "WM_USER: " & Hex(lParam)
Case Else
WndProc = apiCallWindowProc(lpPrevWndProc, hWnd, Msg, _
wParam, lParam)
End Select
End Function

Public Sub Hook()
lpPrevWndProc = apiSetWindowLong(Application.hWndAccessApp, _
GWL_WNDPROC, AddressOf SubclassAccess.WndProc)
End Sub

Public Sub Unhook()
apiSetWindowLong Application.hWndAccessApp, GWL_WNDPROC, lpPrevWndProc
End Sub
 
S

Stephen Lebans

What exactly do you mean by your statement "It works, but it makes Access
_very_ instable".

There is a known subclassing bug that appears if the VB IDE window is
onpened at any time in the current session. Basically the Access window
message pump gets overloaded until you cover the Access App window
completely and force another window to be the current window.

If you are experiencing the above issue the only solution is to place your
subclassing code within an external DLL or distribute your project in mDE
format to ensure the VB IDE window will never be opened.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
S

stefan hoffmann

hi Stephen,

Stephen said:
What exactly do you mean by your statement "It works, but it makes Access
_very_ instable".
Access is crashing (the process is killed by OS) without any message or
Access will not react any more (the process stays active).
There is a known subclassing bug that appears if the VB IDE window is
onpened at any time in the current session. Basically the Access window
message pump gets overloaded until you cover the Access App window
completely and force another window to be the current window.
This seems to be the case.
If you are experiencing the above issue the only solution is to place your
subclassing code within an external DLL or distribute your project in mDE
format to ensure the VB IDE window will never be opened.
Thanks.

I wasn't sure about the method of subclassing Access using the
Application.hWndAccessApp handle, but it seems to be right way.


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top