Re: Coding shortcut under Win32lib wanted - routine_id
- Posted by Derek Parnell <dparnell at BIGPOND.NET.AU> Jan 24, 2001
- 421 views
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? >