FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour solution to speed up the selection of a btnbmp
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
solution to speed up the selection of a btnbmp
Posted: 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 (fw): Select all Collapse
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 (fw): Select all Collapse
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 March-April 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

Continue the discussion