Re: Coding shortcut under Win32lib wanted - routine_id

new topic     » goto parent     » topic index » view thread      » older message » newer message

> From: SR Williamson

> Is there a shortcut to do the following under Win32lib?

> I have 100 Picturebuttons in an app. I want to change the
> bitmap when the
> button is clicked, but each time the change is set to the
> same picture, and
> set a flag to let the program know which button has been clicked once.

> I could do 100 onClicks, but I don't want to. Is there an
> easier way to do
> this?

Here's what I typically do (if I understand what you're asking).  Create all
of your buttons consecutively.  Then you can set the routine_id's en masse:

constant
button1 = create( PushButton, ...),
button2 = create( PushButton, ...),
..
buttonn = create( PushButton, ...)

sequence button_flag
button_flag = {}

procedure buttons_click()
   integer id, ix

   id = getSelf() -- now you know who was clicked

   ix = find(id, button_flag)

   if not ix then
      return
   end if
   button_flag[ix] = 0
   -- do stuff to change the picture

end procedure

atom junk

junk = routine_id("buttons_click")
for i = button1 to buttonn do
   onClick[i] = junk
   button_flag &= i
end for

Matt Lewis

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu