1. What does WinMain do?
- Posted by Patrick Barnes <mrtrick at gmail.com> Nov 12, 2004
- 517 views
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 -- MrTrick
2. Re: What does WinMain do?
- Posted by Derek Parnell <ddparnell at bigpond.com> Nov 12, 2004
- 504 views
- Last edited Nov 13, 2004
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 Use this ... WinMain(0,0) This starts the eventloop without having any main window. -- Derek Parnell Melbourne, Australia
3. Re: What does WinMain do?
- Posted by codepilot Gmail Account <codepilot at gmail.com> Nov 13, 2004
- 494 views
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 > > Use this ... > > WinMain(0,0) > > This starts the eventloop without having any main window. > > -- > Derek Parnell > Melbourne, Australia > > > >
4. Re: What does WinMain do?
- Posted by Derek Parnell <ddparnell at bigpond.com> Nov 13, 2004
- 514 views
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 > > > > Use this ... > > > > WinMain(0,0) > > > > This starts the eventloop without having any main window. > > > > -- > > Derek Parnell > > Melbourne, Australia > > > > -- Derek Parnell Melbourne, Australia
5. Re: What does WinMain do?
- Posted by Patrick Barnes <mrtrick at gmail.com> Nov 13, 2004
- 487 views
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
6. Re: What does WinMain do?
- Posted by Derek Parnell <ddparnell at bigpond.com> Nov 13, 2004
- 501 views
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
7. Re: What does WinMain do?
- Posted by Patrick Barnes <mrtrick at gmail.com> Nov 13, 2004
- 467 views
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
8. Re: What does WinMain do?
- Posted by Patrick Barnes <mrtrick at gmail.com> Nov 15, 2004
- 468 views
- Last edited Nov 16, 2004
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
9. Re: What does WinMain do?
- Posted by Patrick Barnes <mrtrick at gmail.com> Nov 16, 2004
- 475 views
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
10. Re: What does WinMain do?
- Posted by Derek Parnell <ddparnell at bigpond.com> Nov 16, 2004
- 493 views
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
11. Re: What does WinMain do?
- Posted by Patrick Barnes <mrtrick at gmail.com> Nov 16, 2004
- 477 views
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