Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Windows messages between a C++ program, and a Rebol Pro program

 [1/3] from: charles:mougel:spinodo at: 11-Mar-2004 17:20


Hi! (I'm french, sorry for poor english) I have to send messages between 2 programs. One is written in C++ (I'm not the author, but I work with him) And the other in Rebol (It's my program, I can do what I want). I have the SDK, and I call windows API. Here is the C++ code that I have to write in rebol. ---------------------------------------------------- #1###### On loading: MSG_AA_Send_P = RegisterWindowMessage("AA_Send_P"); MSG_AA_P_Ok = RegisterWindowMessage("AA_P_OK"); #2###### A button execute : hAA = FindWindow(NULL, "AA"); SendMessage(hAA, MSG_AA_Send_P, 0, Code); #3###### The Rebol program continue. ####### And, somewhere in a wait-event loop (I don't know where) : switch(uMsg) { case MSG_AA_P_Ok: { ... } break; ... } .... ------------------------------------- I've declare routines : ------------------------------------- user32.dll: load/library %user32.dll aa: to-string to-local-file clean-path %../AA/aa.exe RegisterWindowMessage: make routine! [name [string!] return: [long]] user32.dll "RegisterWindowMessageA" findwindow: make routine! [class [int] name [string!] return: [int]] user32.dll "FindWindowA" sendmessage: make routine! [hWnd [integer!] Msg [integer!] wParam [integer!] lParam [integer!] return: [integer!]] user32.dll SendMessageA free-libs: does [free user32.dll] ------------------------------------- And I try to write a rebol code which works... ------------------------------------- #1###### On loading: msg-aa_send-p: RegisterWindowMessage "AA_SEND_P" msg-aa_p_ok: RegisterWindowMessage "AA_P_OK" I have to integer. #2###### A button execute : h-aa: FindWindow 0 "AA" SendMessage h-aa msg-aa_send-p 0 20040001 If the prog AA is lauch, I have a integer, else 0. #3###### The Rebol program continue. ####### And, somewhere in a wait-event loop (I don't know where) : ####### A test button for now: either msg-aa_p_ok [ print "1" ][ print "2" ] ------------------------------------- I've search in the web for exemple, but Rebol with API isn't so used... And I feel that, there is type problems, but I don't find. Thanks for helping. I'm lost in few lines :-( Charles.

 [2/3] from: greggirwin::mindspring::com at: 11-Mar-2004 10:26


Hi Charles, Your declares all look OK to me, based on a quick scan. If you're trying to *receive* a Windows message--that's my guess, based on the 'switch statement in the C++ example--you'll need to use the system port in REBOL. It doesn't work with View windows yet, only the console unfortunately. I'll be offline for a few days, but maybe this will help get you started: http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=sys-port-drag-accept.r -- Gregg

 [3/3] from: brett:codeconscious at: 12-Mar-2004 11:15


Hi,
> I've search in the web for exemple, but Rebol with API isn't so used... > And I feel that, there is type problems, but I don't find.
I have a sample of a REBOL program that broadcasts a message to prevent multiple instances running. It is only an example, I haven't used it in a REBOL application. I originally used the technique with Delphi 1 after reading it in the Borland Delphi Developer's Guide. I don't do much windows API work so I'm not sure how much help it will be to you. http://www.codeconscious.com/rebol/mlscripts/prevent-multiple-instances.r Brett.