Capturing windows messages

J

John

Hi

I am sending windows message from a vb.net app to an access application
using the PostMessage function which is defined as;

Private Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA"
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer,
ByVal lParam As Integer) As Integer

My question is, how can I capture the message in my access app? Basically I
am looking for access equivalent of following .net code;

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case &H400
' My message processing code here
Case Else
MyBase.WndProc(m)
End Select
End Sub

Thanks

Regards
 
S

Stefan Hoffmann

hi John,
My question is, how can I capture the message in my access app? Basically I
am looking for access equivalent of following .net code;
You need to subclass a form like this:

http://www.mvps.org/access/api/api0045.htm

You can process your messages in fWndProcTray().


Caveats:

Only subclass windows in runtime.
Never debug subclassed forms, invoking the VBA IDE will stop the message
loop thus halting the program.
Therefore use it only on form with complete error handling (VBA). Ensure
that every method has its error handler to avoid the call of the VBA
debugger.
Use only compiled databases (.mde) for production.


mfG
--> stefan <--
 
B

Brendan Reynolds

John said:
Hi

I am sending windows message from a vb.net app to an access application
using the PostMessage function which is defined as;

Private Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA"
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer,
ByVal lParam As Integer) As Integer

My question is, how can I capture the message in my access app? Basically
I am looking for access equivalent of following .net code;

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case &H400
' My message processing code here
Case Else
MyBase.WndProc(m)
End Select
End Sub

Thanks

Regards


If you're using Access 2003 or Access XP, my understanding is that the
supported way of automating these versions of Access from .NET is by using
the primary interop assemblies provided by Microsoft ...

http://msdn.microsoft.com/en-us/library/aa159923(office.11).aspx

I don't know whether Microsoft have released PIAs for Access 2007. If none
is provided, you can create your own interop assembly. There's an article on
the subject at the following URL ...

http://msdn.microsoft.com/en-us/library/ms973800.aspx
 
J

John

I am using Access 97. This is a very old app (> 11 years) and have not come
round to upgrading it to Access 2007 yet.

Thanks

Regards
 

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