Re[2]: getSelf() doesn't work in onOpen
- Posted by "Thomas Parslow (PatRat)" <patrat at rat-software.com> Apr 11, 2001
- 427 views
> 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