DPrometheus
Regular
Hey there
I'm trying to send some messages to another program.
Somehow they never arrive.
The sending application on button click:
The ' receiving' application
however the handles correspond to eachother, so I'm pretty sure it's the right handle. Also the CONSTANTS.MSG_PATIENTWISSEL constant matches on both applications. The Send messagebox shows up, but the receive messagebox doesn't.
Anybody has an idea of what I'm doing wrong?
thanks,
~ DP
EDIT:
If I put a System.Diagnostics.Debugger.Break() call between
Case CONSTANTS.MSG_PATIENTWISSEL
and
Me.Activate()
the program crashes. (As there is no debugger attached to the second application)
Weird thing is, that it does reach this code. Although the text variable of the form doesn't change, as well as the messagebox seem to be refusing to pop up.
The receiving application also takes focus when the message is actually sent.
I'm trying to send some messages to another program.
Somehow they never arrive.
The sending application on button click:
Code:
Dim info As New ProcessStartInfo("C:\Users\mso\Documents\Visual Studio 2005\Projects\SwitchApplication\MedicalRecords\bin\Debug\MedicalRecords.exe")
Dim process As Process
process = process.Start(info)
' Wait for process to be started
Threading.Thread.Sleep(1500)
hWnd = process.MainWindowHandle
Dim Buffer As New StringBuilder(128)
Buffer.Append(ComboBox1.SelectedValue.ToString)
MsgBox(Buffer.ToString & "Sent to " & hWnd.ToString)
SendMessage(hWnd, MSG_PATIENTWISSEL, Nothing, Buffer)
The ' receiving' application
Code:
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case CONSTANTS.MSG_PATIENTWISSEL
Me.Activate()
_patNr.Append(m.GetLParam( GetType(System.Text.StringBuilder)))
System.Threading.Thread.Sleep(1500)
Me.Text += ":" & _patNr.ToString
MsgBox(_patNr.ToString & " received!")
Case Else
MyBase.WndProc(m)
End Select
End Sub
Private Sub MedicalRecord_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Shows right handle
Me.Text = Me.Handle
End Sub
however the handles correspond to eachother, so I'm pretty sure it's the right handle. Also the CONSTANTS.MSG_PATIENTWISSEL constant matches on both applications. The Send messagebox shows up, but the receive messagebox doesn't.
Anybody has an idea of what I'm doing wrong?
thanks,
~ DP
EDIT:
If I put a System.Diagnostics.Debugger.Break() call between
Case CONSTANTS.MSG_PATIENTWISSEL
and
Me.Activate()
the program crashes. (As there is no debugger attached to the second application)
Weird thing is, that it does reach this code. Although the text variable of the form doesn't change, as well as the messagebox seem to be refusing to pop up.
The receiving application also takes focus when the message is actually sent.
Last edited: