Re: What does WinMain do?
- Posted by Derek Parnell <ddparnell at bigpond.com> Nov 13, 2004
- 494 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