1. Re[2]: getSelf() doesn't work in onOpen

> that happens because Win32lib calls the onOpen routine in createEx,
> rather than in createWindow after it's created it.

The onOpen event is triggered when the window is opened, not
created...

> Thomas Parslow (PatRat) wrote:
>> Hi,
>> Got a problem with a program using win32lib, in the onOpen event when
>> i call getSelf() it always seems to return 0, is there a way this can be
>> fixed?
>> 
>> Thomas Parslow (PatRat) ICQ #:26359483
>> Rat Software
>> http://www.rat-software.com/
>> Please leave quoted text in place when replying


Thomas Parslow (PatRat) ICQ #:26359483
Rat Software
http://www.rat-software.com/
Please leave quoted text in place when replying

new topic     » topic index » view message » categorize

2. Re[2]: getSelf() doesn't work in onOpen

> you have found a bug.
> 
> There are two workarounds.
> 
> a) Instead of using onOpen[xx] use setHandler().
> 
>    setHandler( mywin, w32HOpen, routine_id("mywin_open"))
> 
> if you do this the parameters of the handler procedure must be...
>   procedure mywin_open(integer self, integer event, sequence parms)
> 
> and you don't have to call getSelf() as the 'self' parameter is supplied.
> 
> b) Change win32lib.ew.
>    Find the line ...
>          mainWindow = id
>    in the WinMain() procedure and insert after that ...
>          pushSelf(id)
> 
> Now getSelf() should work.
> 
> The reason is that getSelf() was designed to be used by handlers that got
> invoked as a response to a Windows message. But at the time of opening the
> very first window, which is done in WinMain, there has been no Windows
> messages yet so the internal stack of control ids is empty. The fix to
> win32lib.ew just preloads the stack with the initial window's id.
> 
> The setHandler() function doesn't use the internal id stack, so that's why
> it works.
> 
> ------
> Derek Parnell
> Melbourne, Australia
> "To finish a job quickly, go slower."

Hi,
This didn't fix the problem, it was happening when I was opening
windows using openWindow(). I followed the win32lib code through a bit
and I think I've found the correct place to put the pushSelf() in:

In openWindow() find the lines:
    -- action?
    invokeHandler(id, w32HOpen, {})

Then put the pushSelf() before those lines:
    pushSelf(id)
    -- action?
    invokeHandler(id, w32HOpen, {})

Seems to work fine now :)

Thomas Parslow (PatRat) ICQ #:26359483
Rat Software
http://www.rat-software.com/
Please leave quoted text in place when replying

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

Search



Quick Links

User menu

Not signed in.

Misc Menu