1. Message passing.

I'm trying to pass messages from 1 program to another...
The sending procedure needs to return as soon as it's sent the message.
The receiving function needs to be waiting until message A, or B or C
is sent to it, then return with the message that was received (if
another type of message is received, it'll be dispatched).

This is what I thought would work, but nothing seems to be getting to
the receiving program:

include dll.e
include machine.e
constant user32 = open_dll("user32")
constant xRegisterWindowMessage = define_c_func(user32,
"RegisterWindowMessageA", { C_LONG }, C_INT )
constant xGetMessage			= define_c_func(user32, "GetMessageA",
{C_POINTER,C_POINTER,C_UINT,C_UINT}, C_INT)
constant xTranslateMessage		= define_c_proc(user32, "TranslateMessage", {C_INT})
constant xDispatchMessage		= define_c_proc(user32, "DispatchMessageA",
{C_POINTER})
constant xPostMessage 			= define_c_proc(user32, "PostMessageA",
{C_POINTER, C_UINT, C_LONG, C_LONG})
constant SIZEOF_MSG = 28

--Message communication:
constant mem_msg = allocate(SIZEOF_MSG)
global function waitForMessage( object types)
	atom ret, message_type
	if atom(types) then types = {types} end if
	while 1 do
	-- Get a message...
		ret = c_func( xGetMessage, { mem_msg, 0, 0, 0 } ) <----- It stops here...
		message_type = peek4u(mem_msg+4)
		--A quit message was received...
		if ret = 0 or ret = -1 then
			return -1
		--One of the specified messages was received...
		elsif find(message_type, types) then
			return message_type
		--A different message was received.
		else
			c_proc( xTranslateMessage, { mem_msg } )
			c_proc( xDispatchMessage,  { mem_msg } )
		end if
	end while
end function

global procedure PostMessage(atom hwnd, atom message)
--Send a message to the hwnd process.
--Returns immediately.
	c_proc( xPostMessage, {hwnd, message, 0, 0} )
end procedure


(the two routines are in different programs, just shown together here)


Any ideas?
-- 
MrTrick

new topic     » topic index » view message » categorize

2. Re: Message passing.

The code looks right, perhaps you're sending the message to the wrong
handle. How do you find the right hWnd?

--
The Internet combines the excitement of typing 
with the reliability of anonymous hearsay.
tommy online: http://users.telenet.be/tommycarlier
tommy.blog: http://tommycarlier.blogspot.com

new topic     » goto parent     » topic index » view message » categorize

3. Re: Message passing.

The hwnd is right, I'm sure (i've checked with trace and ? statements)
I pass hwndA to program B via the command line...when program B has
started up, it puts its own hwnd into some shared memory and signals a
semaphore that program A waits for.


On Sat, 27 Nov 2004 02:53:03 -0800, Tommy Carlier
<guest at rapideuphoria.com> wrote:
> 
> posted by: Tommy Carlier <tommy.carlier at telenet.be>
> 
> The code looks right, perhaps you're sending the message to the wrong
> handle. How do you find the right hWnd?
> 
> --
> The Internet combines the excitement of typing
> with the reliability of anonymous hearsay.
> tommy online: http://users.telenet.be/tommycarlier
> tommy.blog: http://tommycarlier.blogspot.com
> 
> 
> 
> 


-- 
MrTrick

new topic     » goto parent     » topic index » view message » categorize

4. Re: Message passing.

Pat:
  Try using the constant HWND_BROADCAST as the handle to postmessage.
  This broadcasts to all top level windows.

  Also have you tried using my w32engin.ew to write your programs
  it will save you having to write all them defines.
  You can use it to try things out and then change the final code
  to use the defines if thats what you like. You can also mix in
  simple windows code to save time.
   

Bernie

My files in archive:
w32engin.ew mixedlib.e eu_engin.e win32eru.ew

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

new topic     » goto parent     » topic index » view message » categorize

5. Re: Message passing.

Interesting, I guess I should look into that later...


*ALMOST* finished the engine..... something'll be updated online soon.


On Sat, 27 Nov 2004 08:27:58 -0800, Bernie Ryan <guest at rapideuphoria.com>
wrote:
> 
> posted by: Bernie Ryan <xotron at bluefrog.com>
> 
> Pat:
>   Try using the constant HWND_BROADCAST as the handle to postmessage.
>   This broadcasts to all top level windows.
> 
>   Also have you tried using my w32engin.ew to write your programs
>   it will save you having to write all them defines.
>   You can use it to try things out and then change the final code
>   to use the defines if thats what you like. You can also mix in
>   simple windows code to save time.
> 
> Bernie
> 
> My files in archive:
> w32engin.ew mixedlib.e eu_engin.e win32eru.ew
> 
> Can be downloaded here:
>
> http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
> 
> 
> This email was sent to: mrtrick at gmail.com
> 
> 
> 


-- 
MrTrick

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu