On approximately 3/31/2003 3:07 AM, came the following characters from the keyboard of Stuart Arnold: > I have all that. I'm trying to use it (I am an old windows hack) to > get some uniquely passed in data. > > First, let me start with what I'm trying to do and maybe someone has > a hint. > > Given a "Button", I want to pass to it a single piece of data to get > back when its pressed. In the X11 world, this is done thru the > AddCallback method and a void arg is allowed for data. > > In the Windows world, I've used: SetWindowLong( hwndBtn, > GWL_USERDATA, (void*) &data ); int data = (int) GetWindowLong( > hwndBtn, GWL_USERDATA ); And GWL_USERDATA = (-21) > > For perl, I call $btn->SetWindowLong( -21, \$data ); -and I've tried- > $btn->SetWindowLong( -21, 0 ); When I do that, the button no longer > works at all. I checked the return from it, as in: my $data = > $win->SetWindowLong( -21, \$data ); And its empty. > > IF there is a better alternative to getting data from the button when > its pressed, let me know. Do not offer "global" vars as an answer. > It really must be data on the button. > > Any suggestions or working examples out there?
Doesn't Win32::GUI use GWL_USERDATA to point to its own data structures? I think so. So for Win32::GUI created windows, you cannot use that data for your own purposes.... but for non-Win32::GUI windows, you can.
Are you using the original, or "new event model" form of Win32::GUI ?
The original requires separate functions for each button click, and they could be closures with local variables, settable/gettable by other functions in the same closure. Alternately, you could have a lookup table from the name of the button, to the data of interest... but that approaching the "global" vars restriction.
You told us the problem, but not all the details about the "global" var constraint, or why it needs to exists.
-- Glenn ===== If the grass is greener on the other side of the fence, try taking better care of your own side. -- Unknown
_______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs