Date: 02-16-2022
Return to Index
created by gbSnippets
'To send a message to other processes, you first need to agree
'on a message number that both parties will recognize. The use
'of the RegisterWindowMessage API allows you to do that.
'Primary Code:
'The API take a string and returns a unique system message number.
'Both application call the API with the same string.
gMsg = RegisterWindowMessage(MsgString)
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
'This app will talk to this app: http://gbl_00698
#Compile EXE
#Include "Win32API.inc"
Global hDlg, gMsg as Dword
Function PBMain() As Long
Local MsgStringA, MsgStringB As AsciiZ * 100
MsgStringA = "gb Custom MsgA"
gMsg = RegisterWindowMessage(MsgStringA) 'gets unique msg #
Dialog New Pixels, 0, "EXE #1 " + str$(gMsg),300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Send - not wait", 50,10,100,20
Control Add Button, hDlg, 101,"Send - wait", 50,40,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Command AND CB.Ctl = 100 AND CB.Ctlmsg = %BN_Clicked Then
PostMessage %Hwnd_Broadcast, gMsg, 4, 7
End If
If CB.Msg = %WM_Command AND CB.Ctl = 101 AND CB.Ctlmsg = %BN_Clicked Then
SendMessage %Hwnd_Broadcast, gMsg, 2, 3
? "Message sent and received"
End If
End Function
'gbs_00743
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm