Trigger an event on another .NET App

  • Thread starter Thread starter Dragon
  • Start date Start date
D

Dragon

Hi,
What is the simplest way to implement that ?

Send WM_USER message to main window of second application, and catch it in
it.

The simplest way I can imagine. 8=]

Roman
 
Hi

I have two .NET applications that run together on the same local PC.

I have a situation, that when I click a button on the first application, I
need to trigger an event for the second Application.

What is the simplest way to implement that ?
 
Dragon said:
Hi,
What is the simplest way to implement that ?

Send WM_USER message to main window of second application, and catch it in
it.

The simplest way I can imagine. 8=]

A lot of people do it that way including me, so I've not actually learned
the 'proper' way to do it :)

If one application calls the other, make the second an ActiveX .EXE and call
that (This is how Microsoft Office products interact).

I'm led to believe by one of my co-workers that the ActiveX EXE can call
each other in .NET without using COM. In other words - one will not have to
be dependant on the stub of the other - but I haven't looked into it. Please
let me know if you find a modern solution to this problem!

BTW: Will "Remoting" solve your problem?

--
Mike Wilson*
Evolved Software Studios Ltd
www.evolvedsoftwarestudios.com

*Ask me about getting YOU a VIDEO of your software being tested in Windows
Vista for ONLY $25
 
What's WM_USER message?. can you elaborate ?
Dragon said:
Hi,
What is the simplest way to implement that ?

Send WM_USER message to main window of second application, and catch it in
it.

The simplest way I can imagine. 8=]

Roman
 
In addition to Armin:

http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface
/windowing/messagesandmessagequeues/messagesandmessagequeuesreference/me
ssagesandmessagequeuesfunctions/sendmessage.asp

http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface
/windowing/messagesandmessagequeues/messagesandmessagequeuesreference/me
ssagesandmessagequeuesfunctions/postmessage.asp

http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface
/windowing/messagesandmessagequeues/messagesandmessagequeuesreference/me
ssagesandmessagequeuesfunctions/sendmessagetimeout.asp

A bit of code:

~
Friend Declare Auto Function SendMessage Lib "user32.dll" ( _
ByVal hwnd As IntPtr, _
ByVal Msg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32 _
) As Int32

Private Const WM_USER As Int32 = &H400

....

' First app
SendMessage(SecondAppProcess.MainWindowHandle, WM_USER, 1, 0)

....

' Second app
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_USER AndAlso m.WParam.ToInt32 = 1 Then
' Do whatever you want
End If
End Sub
~

HTH

Roman

romy said:
What's WM_USER message?. can you elaborate ?
Dragon said:
Hi,


Send WM_USER message to main window of second application, and catch
it
in
it.

The simplest way I can imagine. 8=]

Roman
 

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

Back
Top