1. Win32lib question - can I tell the calling control?
Let's say I set the onClick event for a dozen different controls to the same
procedure.
Is there a way that this procedure can find out the handle for the calling
control?
2. Re: Win32lib question - can I tell the calling control?
John Coonrod wrote:
> Is there a way that this procedure can find out
> the handle for the calling control?
The getSelf() routine should work.
-- David Cuny
3. Re: Win32lib question - can I tell the calling control?
> From: John Coonrod
> Let's say I set the onClick event for a dozen different
> controls to the same
> procedure.
> Is there a way that this procedure can find out the handle
> for the calling
> control?
No, since onClick (a la win32lib) doesn't pass any parameters. I'd suggest
changing the routine you have to accept the id, and creating other
procedures to 'wrap' it:
procedure all_onClick( integer id )
if id = Control1 then
...
elsif ...
...
end if
...
end procedure
procedure Control1_onClick()
all_onClick( Control1 )
end procedure
onClick[Control1] = routine_id("Control1_onClick")
etc...
Matt Lewis
4. Re: Win32lib question - can I tell the calling control?
> -----Original Message-----
> From: David Cuny
>
> The getSelf() routine should work.
Aha. That would explain the use of push/popSelf [in WndProc/SubProc]. I've
often wondered about that. Also, getSelf isn't in the docs, which explains
why I never found it. 3 lines of code in 17,000, sheesh. :)
Matt
5. Re: Win32lib question - can I tell the calling control?
Matthew Lewis wrote:
> Aha. That would explain the use of push/popSelf
> [in WndProc/SubProc]. I've often wondered about that.
That was one fun weekend, getting that worked out. My initial cut just used
a single variable to keep track of self. I found out the hard way that a
callback (such as an onPaint) can trigger at any time, and when you return,
self has been mangled. Using a stack to keep track of the state takes care
of that problem.
> Also, getSelf isn't in the docs, which explains
> why I never found it. 3 lines of code in 17,000,
> sheesh. :)
*blush*
Yet another minor detail to add to the list...
-- David Cuny