solution to speed up the selection of a btnbmp

solution to speed up the selection of a btnbmp

Postby Silvio.Falconi » Tue Mar 24, 2020 11:52 am

I have 10 buttons, the end user can only press one and must remain pressed by assigning a value (from 1 to 10)

Code: Select all  Expand view  RUN
local aBtnCalc:=array(10)
local j,n:= 1
local nRow:=60

  for j= 1 to 10
        @  nRow,2 BTNBMP aBtnCalc[j] ;
            PROMPT ltrim(str(j)) SIZE 20,20 PIXEL of oDlg FLAT NOBERDER
             WITH OBJECT aBtnCalc[j]
                  :Cargo      := {j }
                  :bAction    := { |oBtn| oBtn:Toggle(),If( oBtn:lPressed,Givenumber(oBtn,@n,aBtnCalc),)  }
                  :bClrGrad   := { |l,oBtn| If( oBtn:lPressed, CLR_HRED, CLR_GREEN ) }
                  :oCursor    := oHand
               End
            nRow+=nSpace
         next j
 

...


in the Givenumber function (oBtn, n, aCalc) I return the numeric value(n) and change the lPressed variable on all the buttons
by assigning lPressed: =. t. only when the button is pressed

the procedure only works that sometimes it is slow as if you were thinking about it, there is probably another way to solve it
but I haven't found it




Code: Select all  Expand view  RUN
Static Function Givenumber(oBtn,n,aCalc)
   For n=1 to 10
      aCalc[n]:lpressed:=.f.
      aCalc[n]:refresh()
   next
       oBtn:lpressed:=.t.
  return n=oBtn:cargo[1]


any solution to speed up the selection?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 62 guests