1. What does WinMain do?

IPC won't receive messages unless WinMain is called. Fair enough.

I'm not using win32lib at all, how can I duplicate that small part of
WinMain so that IPC works? I tried to go through WinMain, but it's a
little beyond me smile
-- 
MrTrick

new topic     » topic index » view message » categorize

2. Re: What does WinMain do?

Patrick Barnes wrote:
> 
> IPC won't receive messages unless WinMain is called. Fair enough.
> 
> I'm not using win32lib at all, how can I duplicate that small part of
> WinMain so that IPC works? I tried to go through WinMain, but it's a
> little beyond me smile

Use this ...

  WinMain(0,0)

This starts the eventloop without having any main window.

-- 
Derek Parnell
Melbourne, Australia

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

3. Re: What does WinMain do?

Question, if you do WinMain(0,0) what is the handle to give
wsaAsyncSelect and the like, instead of get_handle(win), if there is
no win?
Daniel


On Fri, 12 Nov 2004 15:15:54 -0800, Derek Parnell
<guest at rapideuphoria.com> wrote:
> 
> posted by: Derek Parnell <ddparnell at bigpond.com>
> 
> 
> Patrick Barnes wrote:
> >
> > IPC won't receive messages unless WinMain is called. Fair enough.
> >
> > I'm not using win32lib at all, how can I duplicate that small part of
> > WinMain so that IPC works? I tried to go through WinMain, but it's a
> > little beyond me smile
> 
> Use this ...
> 
>  WinMain(0,0)
> 
> This starts the eventloop without having any main window.
> 
> --
> Derek Parnell
> Melbourne, Australia
> 
> 
> 
>

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

4. Re: What does WinMain do?

codepilot Gmail Account wrote:
> 
> Question, if you do WinMain(0,0) what is the handle to give
> wsaAsyncSelect and the like, instead of get_handle(win), if there is
> no win?

Did I misunderstand the orginal question? I didn't know it was talking
WSAAsyncSelect function. If you were using that funcrion you'd use
WinMain as normally done. 

I thought Patrick was wanting use Win32lib's event looping but without
having a main window under Win32lib's control.

As Patrick doesn't want to use Win32lib , then the code inside win32lib.ew
eventLoop() routine could be extracted and adjusted for his purposes.

> 
> On Fri, 12 Nov 2004 15:15:54 -0800, Derek Parnell
> <guest at rapideuphoria.com> wrote:
> > 
> > posted by: Derek Parnell <ddparnell at bigpond.com>
> > 
> > 
> > Patrick Barnes wrote:
> > >
> > > IPC won't receive messages unless WinMain is called. Fair enough.
> > >
> > > I'm not using win32lib at all, how can I duplicate that small part of
> > > WinMain so that IPC works? I tried to go through WinMain, but it's a
> > > little beyond me smile
> > 
> > Use this ...
> > 
> >  WinMain(0,0)
> > 
> > This starts the eventloop without having any main window.
> > 
> > --
> > Derek Parnell
> > Melbourne, Australia
> > 
> > 
-- 
Derek Parnell
Melbourne, Australia

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

5. Re: What does WinMain do?

On Fri, 12 Nov 2004 19:26:36 -0800, Derek Parnell <guest at rapideuphoria.com> 
> As Patrick doesn't want to use Win32lib , then the code inside win32lib.ew
> eventLoop() routine could be extracted and adjusted for his purposes.

Yes, that was my plan... but eventLoop() does a lot of things.
I don't know what the core is, I suspect it's a single call to a
blocking c function, wrapped inside a loop.

-- 
MrTrick

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

6. Re: What does WinMain do?

Patrick Barnes wrote:
> 
> On Fri, 12 Nov 2004 19:26:36 -0800, Derek Parnell <guest at rapideuphoria.com>
>
> > As Patrick doesn't want to use Win32lib , then the code inside win32lib.ew
> > eventLoop() routine could be extracted and adjusted for his purposes.
> 
> Yes, that was my plan... but eventLoop() does a lot of things.
> I don't know what the core is, I suspect it's a single call to a
> blocking c function, wrapped inside a loop.
> 

I guess this is the minimum code ...

include dll.e
include machine.e

constant SIZEOF_MSG = 28
constant user32 = open_dll("user32.dll")
constant GetMessage         = define_c_func(user32, "GetMessageA",
{C_POINTER,C_POINTER,C_UINT,C_UINT}, C_INT)
constant TranslateMessage   = define_c_proc(user32, "TranslateMessage", {C_INT})
constant DispatchMessage    = define_c_proc(user32, "DispatchMessageA",
{C_POINTER})

procedure eventLoop()
    atom msg
    atom getRC

    -- Allocate a message buffer
    msg = allocate(SIZEOF_MSG)
    while 1 do
    -- message loop
        getRC = c_func( GetMessage, { msg, 0, 0, 0 } )
        if  getRC = 0
         or getRC = -1 then
            exit -- User has sent a WM_QUIT message
        end if

        c_proc( TranslateMessage, { msg } )
        c_proc( DispatchMessage, { msg } )
    end while

    free(msg)

end procedure


-- 
Derek Parnell
Melbourne, Australia

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

7. Re: What does WinMain do?

Hey, cool! (Unfortunately, I can't try it til monday)

I'll give you a proper answer when I get to work on monday.


On Fri, 12 Nov 2004 23:56:24 -0800, Derek Parnell
<guest at rapideuphoria.com> wrote:
> 
> posted by: Derek Parnell <ddparnell at bigpond.com>
> 
> Patrick Barnes wrote:
> >
> > On Fri, 12 Nov 2004 19:26:36 -0800, Derek Parnell <guest at
> > rapideuphoria.com>
> > > As Patrick doesn't want to use Win32lib , then the code inside win32lib.ew
> > > eventLoop() routine could be extracted and adjusted for his purposes.
> >
> > Yes, that was my plan... but eventLoop() does a lot of things.
> > I don't know what the core is, I suspect it's a single call to a
> > blocking c function, wrapped inside a loop.
> >
> 
> I guess this is the minimum code ...
> 
> }}}
<eucode>
> include dll.e
> include machine.e
> 
> constant SIZEOF_MSG = 28
> constant user32 = open_dll("user32.dll")
> constant GetMessage         = define_c_func(user32, "GetMessageA",
> {C_POINTER,C_POINTER,C_UINT,C_UINT}, C_INT)
> constant TranslateMessage   = define_c_proc(user32, "TranslateMessage",
> {C_INT})
> constant DispatchMessage    = define_c_proc(user32, "DispatchMessageA",
> {C_POINTER})
> 
> procedure eventLoop()
>     atom msg
>     atom getRC
> 
>     -- Allocate a message buffer
>     msg = allocate(SIZEOF_MSG)
>     while 1 do
>     -- message loop
>         getRC = c_func( GetMessage, { msg, 0, 0, 0 } )
>         if  getRC = 0
>          or getRC = -1 then
>             exit -- User has sent a WM_QUIT message
>         end if
> 
>         c_proc( TranslateMessage, { msg } )
>         c_proc( DispatchMessage, { msg } )
>     end while
> 
>     free(msg)
> 
> end procedure
> </eucode>
{{{

> 
> 
> --
> Derek Parnell
> Melbourne, Australia
> 
> 
> 
> 


-- 
MrTrick

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

8. Re: What does WinMain do?

Excellent... it works perfectly. (Although I did add a flag to the
while loop so it can be shut down remotely)

OtterDad, if you're still working on that inter process library, this
function would be very useful...

Thanks Derek!

On Fri, 12 Nov 2004 23:56:24 -0800, Derek Parnell
<guest at rapideuphoria.com> wrote:
> 
> posted by: Derek Parnell <ddparnell at bigpond.com>
> 
> Patrick Barnes wrote:
> >
> > On Fri, 12 Nov 2004 19:26:36 -0800, Derek Parnell <guest at
> > rapideuphoria.com>
> > > As Patrick doesn't want to use Win32lib , then the code inside win32lib.ew
> > > eventLoop() routine could be extracted and adjusted for his purposes.
> >
> > Yes, that was my plan... but eventLoop() does a lot of things.
> > I don't know what the core is, I suspect it's a single call to a
> > blocking c function, wrapped inside a loop.
> >
> 
> I guess this is the minimum code ...
> 
> }}}
<eucode>
> include dll.e
> include machine.e
> 
> constant SIZEOF_MSG = 28
> constant user32 = open_dll("user32.dll")
> constant GetMessage         = define_c_func(user32, "GetMessageA",
> {C_POINTER,C_POINTER,C_UINT,C_UINT}, C_INT)
> constant TranslateMessage   = define_c_proc(user32, "TranslateMessage",
> {C_INT})
> constant DispatchMessage    = define_c_proc(user32, "DispatchMessageA",
> {C_POINTER})
> 
> procedure eventLoop()
>     atom msg
>     atom getRC
> 
>     -- Allocate a message buffer
>     msg = allocate(SIZEOF_MSG)
>     while 1 do
>     -- message loop
>         getRC = c_func( GetMessage, { msg, 0, 0, 0 } )
>         if  getRC = 0
>          or getRC = -1 then
>             exit -- User has sent a WM_QUIT message
>         end if
> 
>         c_proc( TranslateMessage, { msg } )
>         c_proc( DispatchMessage, { msg } )
>     end while
> 
>     free(msg)
> 
> end procedure
> </eucode>
{{{

> 
> 
> --
> Derek Parnell
> Melbourne, Australia
> 
> 
> 
> 


-- 
MrTrick

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

9. Re: What does WinMain do?

On Fri, 12 Nov 2004 23:56:24 -0800, Derek Parnell
<guest at rapideuphoria.com> wrote:

Hi Derek,

In your code below, it listens for a WM_QUIT message... how could a
program send that? And how would it send it to itself?


 
> }}}
<eucode>
> include dll.e
> include machine.e
> 
> constant SIZEOF_MSG = 28
> constant user32 = open_dll("user32.dll")
> constant GetMessage         = define_c_func(user32, "GetMessageA",
> {C_POINTER,C_POINTER,C_UINT,C_UINT}, C_INT)
> constant TranslateMessage   = define_c_proc(user32, "TranslateMessage",
> {C_INT})
> constant DispatchMessage    = define_c_proc(user32, "DispatchMessageA",
> {C_POINTER})
> 
> procedure eventLoop()
>     atom msg
>     atom getRC
> 
>     -- Allocate a message buffer
>     msg = allocate(SIZEOF_MSG)
>     while 1 do
>     -- message loop
>         getRC = c_func( GetMessage, { msg, 0, 0, 0 } )
>         if  getRC = 0
>          or getRC = -1 then
>             exit -- User has sent a WM_QUIT message
>         end if
> 
>         c_proc( TranslateMessage, { msg } )
>         c_proc( DispatchMessage, { msg } )
>     end while
> 
>     free(msg)
> 
> end procedure
> </eucode>
{{{

> 
> 
> --
> Derek Parnell
> Melbourne, Australia
> 
> 
> 
> 


-- 
MrTrick

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

10. Re: What does WinMain do?

Patrick Barnes wrote:
> 
> On Fri, 12 Nov 2004 23:56:24 -0800, Derek Parnell
> <guest at rapideuphoria.com> wrote:
> 
> Hi Derek,
> 
> In your code below, it listens for a WM_QUIT message... how could a
> program send that? And how would it send it to itself?
  
include dll.e
include machine.e

constant PostQuitMessage   = define_c_proc(user32, "PostQuitMessage", {C_INT})

integer exitcode exitcode = 0

c_proc( PostQuitMessage, { exitcode } )


The 'exitcode' value turns up as the wParam field in the WM_QUIT
message. This ought to be passed back to the operating system
when you end the program.

-- 
Derek Parnell
Melbourne, Australia

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

11. Re: What does WinMain do?

On Mon, 15 Nov 2004 19:45:49 -0800, Derek Parnell
<guest at rapideuphoria.com> wrote:
> > In your code below, it listens for a WM_QUIT message... how could a
> > program send that? And how would it send it to itself?
> 
> }}}
<eucode>
> include dll.e
> include machine.e
> 
> constant PostQuitMessage   = define_c_proc(user32, "PostQuitMessage", {C_INT})
> 
> integer exitcode exitcode = 0
> 
> c_proc( PostQuitMessage, { exitcode } )
> </eucode>
{{{

> 
> The 'exitcode' value turns up as the wParam field in the WM_QUIT
> message. This ought to be passed back to the operating system
> when you end the program.

Ah, thank you.
I'll add that to my code.

-- 
MrTrick

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

Search



Quick Links

User menu

Not signed in.

Misc Menu