1. Coding shortcut under Win32lib wanted - routine_id

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?

new topic     » topic index » view message » categorize

2. Re: Coding shortcut under Win32lib wanted - routine_id

Possibly by looking at the program I wrote that
George Henry sent to the list you could come up
with a possible method.

Note the X in the upper right corner is tracked
to onClick & if event = WM_LBUTTONDOWN then

You'll probably find that by, learning how sequences work
anything's possible.

euman at bellsouth.net

----- Original Message -----
From: "SR Williamson" <sr.williamson at OSHA.GOV>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Tuesday, January 23, 2001 15:22
Subject: Coding shortcut under Win32lib wanted - routine_id


> 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?
>

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

3. Re: Coding shortcut under Win32lib wanted - routine_id

> 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 message » categorize

4. Re: Coding shortcut under Win32lib wanted - routine_id

Hi,
using v0.55 or higher you could do something like this...

-----
constant nBtns = 100, btnId = 1, btnTag = 2, btnPic = 3
sequence btns
btns = {repeat(0, nBtns), repeat(0, nBtns), repeat({}, nBtns)}

-- Create all the picture buttons.
for i = 1 to nBtns do
    -- Create a button
    btns[btnId][i] = create(PictureButton, ...)

    -- Set its initial picture
    initialpic = ...
    setBitMap(btns[btnId][i], initialpic)

    -- Record this picture in the button's list of pictures.
    btns[btnPic][i] &= initialpic
end for

-- Handler for all picture buttons.
procedure clicktest(integer self, integer event, sequence parms)
   integer indx, picfnd
   atom newpic

   -- determine what is the next picture to show on this button.
   newpic = ...

   -- set the new picture
   setBitmap(self, newpic)

   ---------------------------------------------------------------
   -- If this picture has never been used on this button before,
   -- add the picture to the button's picture list
   -- otherwise coount the number of times duplicate pics have been used
   -- for this button.
   ---------------------------------------------------------------
   -- locate this button in the list of picture buttons.
   indx = find(self, btns[btnId])

   -- see if this picture has been used in this button before.
   picfnd = find(newpic, btns[btnPic][indx])


   if picfnd = 0 then
      -- newpic hasn't been set yet, so add it to the button's list.
      btns[btnPic][indx] &= newpic
   else
      -- newpic has been set at least once, so count it.
      btns[btnTag][indx] += 1
   end if

end procedure
setHandler(w32HClick, btns[btnId], routine_id("clicktest"))

------
Derek Parnell
Melbourne, Australia
(Vote [1] The Cheshire Cat for Internet Mascot)

----- Original Message -----
From: "SR Williamson" <sr.williamson at OSHA.GOV>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Wednesday, January 24, 2001 7:22 AM
Subject: Coding shortcut under Win32lib wanted - routine_id


> 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?
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu