Window Messages Help

Windows specific forum
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Window Messages Help

Post 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
I may not help with your coding
Just ask about mental issues!

http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Window Messages Help

Post 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.
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Re: Window Messages Help

Post by Nico »

There is a bug, on window x64 i have one message, on window x86 i have two (same) messages!
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Window Messages Help

Post by IdeasVacuum »

You might consider using shared memory (File Mapping):
http://www.purebasic.fr/english/viewtop ... 12&t=51527
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Window Messages Help

Post by netmaestro »

The WM_COPYDATA message is ideal for this.
BERESHEIT
Post Reply