[REBOL] Windows messages between a C++ program, and a Rebol Pro program
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.