solution to speed up the selection of a btnbmp

Post Reply
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

solution to speed up the selection of a btnbmp

Post by Silvio.Falconi »

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

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

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?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Post Reply