Page 1 of 1
Window Messages Help
Posted: Thu Feb 28, 2013 3:53 pm
by kinglestat
How is it possible to register user created messages for the window message system so that 2 applications can communicate together? And how to capture them in PB? Can't find any examples to help me out
Re: Window Messages Help
Posted: Thu Feb 28, 2013 8:21 pm
by Danilo
kinglestat wrote:How is it possible to register user created messages for the window message system so that 2 applications can communicate together? And how to capture them in PB? Can't find any examples to help me out
Just use
msg = RegisterWindowMessage_(@"MyUniqueString")
and
PostMessage_(#HWND_BROADCAST,msg, ...)
Code: Select all
If OpenWindow(1, 0, 0, 800, 600, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListViewGadget(0,10,10,780,580)
myMessage = RegisterWindowMessage_(@"My.App.Message.1")
PostMessage_(#HWND_BROADCAST,myMessage,12,24)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow
Quit = #True
Case myMessage
msg$ = "STRING MESSAGE (RegisterWindowMessage): "
AddGadgetItem(0,-1,msg$+Str(Event)+" ($"+Hex(Event)+") - wParam: "+Str(EventwParam())+" ($"+Hex(EventwParam())+") - lParam: "+Str(EventlParam())+" ($"+Hex(EventlParam())+")")
EndSelect
Until Quit = #True
EndIf
Start this code multiple times, all of the windows get the message.
Re: Window Messages Help
Posted: Thu Mar 07, 2013 11:11 pm
by Nico
There is a bug, on window x64 i have one message, on window x86 i have two (same) messages!
Re: Window Messages Help
Posted: Thu Mar 07, 2013 11:55 pm
by IdeasVacuum
You might consider using shared memory (File Mapping):
http://www.purebasic.fr/english/viewtop ... 12&t=51527
Re: Window Messages Help
Posted: Fri Mar 08, 2013 1:48 am
by netmaestro
The WM_COPYDATA message is ideal for this.