` Printed Icetips Article

Icetips Article



Windows API: SendMessage and RegisterWindowMessage
2004-05-10 -- Richard Rogers
 
Newsgroups: softvelocity.clarion.language


You might wat to try this...

API PROTOTYPES

SendMessage(SIGNED,SIGNED,SIGNED,LONG),LONG,PASCAL,NAME('SendMessageA')

RegisterWindowMessage(LONG),UNSIGNED,PASCAL,RAW,PROC,NAME('RegisterWindowMessageA')

DATA DECLS
MessageRegister       CSTRING(255)
MOD:wHandle            LONG
MyDoSomethingSilly  LONG

CODE
MessageRegister = 'DoSomethingSilly'
MyDoSomethingSilly = RegisterWindowMessage(ADDRESS(MessageRegister))

RET# = SendMessage(MOD:wHandle,WM_COMMAND,MyDoSomethingSilly,0)

Subclass your procedure and watch for your registered messages.
Additional info can be passed with wParam and lParam.

I usually make wHandle the first parameter in the procedure prototype
and when an outside application (C++, VB, doesn't matter) wants to use
my procedure, all they have to do is pass me their window handle. The
first thing I do after that is send them a message containing MY
window handle. After that, the lines of communication are wide open.
MUCH faster than DDE. Much more reliable.

I have a Clarion Graphics module talking with a POS system written in
C++ this way. Very sweet and simple.

On 8 May 2004 10:35:22 -0400, "Charles Edmonds"
 wrote:

>Hello Everyone,
>
>I am looking for advice on how best to send a message to an external
>program.
>
>Normally I use NetTalk to communicate between programs (nothing is easier!),
>but in this case I need my Clarion program to be able to send a message
>"back" to the program that called it.
>
>In this case, the external program prepares a data file and RUNs the Clarion
>program with some command line parameters.
>
>The Clarion program uses the contents of the data file, does some work and
>deletes the file.
>
>I'd like to be able to notify the program that handed off the job that it is
>complete.
>
>I know I could create a results file and have the calling program poll for
>the file, but I'd prefer a more elegant solution.
>
>I've looked a bit at FindWindow and PostMessage in the API and this seems
>like it might be a good approach, but at this stage of the game I decided to
>ask for some opinions and ideas here.
>
>While my program will initially be used with other Clarion programs, it was
>designed to be used by non-Clarion programs too.
>
>So I'd like to use something that will be fairly easy to implement and would
>be easily accessed from other platforms too.
>
>Thanks for any and all ideas and suggestions!
>
>Charles



Printed May 6, 2024, 11:59 am
This article has been viewed/printed 35309 times.
Google search has resulted in 586 hits on this article since January 25, 2004.