3 state btnbmp

3 state btnbmp

Postby Silvio.Falconi » Thu Mar 24, 2022 9:27 am

I need to do a 3 state btnbmp but I can't do it
in the beginning the state is free (3 no pressed)
state n. 1 taken
state n. 2 fixes
state 3 free
when a user presses the first time the status is 1, if they press the second time the status is 2, if they click for the third time the status returns to 3
how can I do ?

I try to make a test but not run ok , someone can help me pls ?


Code: Select all  Expand view


#include "fivewin.ch"
#define DARKORANGE2  nRGB( 247, 192, 91 )
#define LIGHTBLUE    nRGB(  89, 135, 214 )


Function test()
local   nTotCol := 2
local   nTotRow := 2
local   oBtnNum := Array( nTotRow * nTotCol )
local   oSay
local   xRow:=25
local   xCol:=40
local   xWidth:=  40
local   xHeight:= 30
local   xSpace := 2
local k,t,nMaxVal:=4

DEFINE DIALOG oDlg SIZE 200,100  PIXEL TRUEPIXEL RESIZABLE
 @ 10,10 SAY oSay PROMPT "0 selezionati" SIZE 100,20 PIXEL OF oDlg TRANSPARENT

 For t=1 to nTotRow
       For k=1 to nTotCol
         nPos := nTotCol * ( t - 1 ) + k
           @  xRow, xCol BTNBMP oBtnNum[ nPos ] PROMPT alltrim(str( nPos, 2)) ;
                         SIZE xWidth,xHeight PIXEL FLAT OF oDlg

           oBtnNum[nPos]:cargo:={.f.,.f.,.f.}
           oBtnNum[nPos]:bAction := BtnAction( k, t, nTotCol, nTotRow, oBtnNum, nMaxVal,oSay )


             xCol += xWidth + xSpace
             next
          xRow += xHeight + xSpace
      xCol := 40
   next


 ACTIVATE DIALOG oDLG
 return nil
 //----------------------------------------------------------------------//
Function BtnAction( x, y, nTotCol, nTotRow, aBtn, aSay, nMaxVal,oSay)
   return { | oSelf | CheckStatus( oSelf, x, y, nTotCol, nTotRow, aBtn, aSay, nMaxVal,oSay ) }
//-------------------------------------------------------------------------//
Function CheckStatus( oSelf, x, y, nTotCol, nTotRow, aBtn, aSay, nMaxVal,oSay )
   local nCount := 0
   local j



    ?  oSelf:lpressed

      if oSelf:lpressed
         oSelf:lpressed := .f.
         oSelf:cargo[1]:=.t.
         oSelf:bClrGrad = { | lInvert | If( ! lInvert,;
                    { { 1, RGB( 255, 255, 255 ), RGB( 229, 233, 238 ) } },;
                    { { 1/2, RGB( 242, 244, 246 ), RGB( 145, 201, 247 ) },;
                      { 1/2, RGB( 145, 201, 247 ), RGB( 242, 244, 246 ) } } ) }
      else
        * oSelf:lpressed := .t.
         oSelf:cargo[2]:=.t.
         oSelf:bClrGrad = { | lInvert | If( ! lInvert,;
                    { { 1, DARKORANGE2, DARKORANGE2 } },;
                    { { 1, DARKORANGE2, DARKORANGE2 } } ) }


       *  oSelf:cargo[3]:=.t.

      endif

      oSelf:refresh()

      ?  oSelf:lpressed
       xbrowser oSelf:cargo
return nil
//------------------------------------------------------------------------------//



 
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: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: 3 state btnbmp

Postby karinha » Thu Mar 24, 2022 11:55 am

Algo asi?

Code: Select all  Expand view


// \samples\BTNPRES3.PRG

#Include "Fivewin.ch"

#Define DARKORANGE2  nRGB( 247, 192, 91 )
#Define LIGHTBLUE    nRGB(  89, 135, 214 )

MEMVAR  nVeces

FUNCTION test()

   LOCAL nPos, oDlg, oFnt, oFont, K, T, oSay, cPrompt, oExit
   LOCAL nTotCol := 2
   LOCAL nTotRow := 2
   LOCAL nMaxVal := 4
   LOCAL oBtnNum := Array( nTotRow * nTotCol )
   LOCAL xRow    := 25
   LOCAL xCol    := 40
   LOCAL xWidth  := 40
   LOCAL xHeight := 30
   LOCAL xSpace  := 2

   nVeces        := 1
   cPrompt       := "Selezionati        "

   DEFINE FONT oFnt    NAME "Ms Sans Serif" SIZE 0, -12 BOLD
   DEFINE FONT oFont   NAME "Ms Sans Serif" SIZE 0, -14 BOLD

   DEFINE DIALOG oDlg SIZE 200, 100 PIXEL TRUEPIXEL RESIZABLE   ;
      COLORS LIGHTBLUE, CLR_WHITE TRANSPARENT

   oDlg:lHelpIcon := .F.

   @ 9.0, 10 SAY oSay PROMPT cPrompt SIZE 120, 20 PIXEL OF oDlg ;
      COLORS DARKORANGE2, CLR_WHITE TRANSPARENT FONT oFont

   FOR T = 1 TO nTotRow

      FOR K = 1 TO nTotCol

         nPos := nTotCol * ( t - 1 ) + k

         @ xRow, xCol BTNBMP oBtnNum[ nPos ] SIZE xWidth, xHeight    ;
            PIXEL FLAT OF oDlg PROMPT AllTrim( Str( nPos, 2 ) )      ;
            ACTION( VERIFY_NUMBERX_BTN( oBtnNum, oDlg, oSay ) )

         oBtnNum[ nPos ]:bClrGrad = {| lInvert | If( ! lInvert,      ;
            { { 1, RGB( 255, 255, 255 ), RGB( 229, 233, 238 ) } },   ;
            { { 1 / 2, RGB( 242, 244, 246 ), RGB( 145, 201, 247 ) }, ;
            { 1 / 2, RGB( 145, 201, 247 ), RGB( 242, 244, 246 ) } } ) }

         oBtnNum[ nPos ]:Cargo := { .F., .F., .F. }

         xCol += xWidth + xSpace

      NEXT

      xRow += xHeight + xSpace

      xCol := 40

   NEXT

   @ 44, 150 BUTTON oExit PROMPT "&Ok" SIZE 40, 20 PIXEL OF oDlg ;
      ACTION( oDlg:End() ) CANCEL

   // SET FONT OF oBtnNum[ nPos ] TO oFnt
   SET FONT OF oExit              TO oFont

   ACTIVATE DIALOG oDlg CENTERED

   oFnt:End()
   oFont:End()

RETURN NIL

FUNCTION VERIFY_NUMBERX_BTN( oBtnNum, oDlg, oSay )

   LOCAL cTextSay := SPACE(20) // cPrompt

   IF nVeces = 1

      nVeces := nVeces + 1

      oBtnNum[ 1 ]:Disable()
      oBtnNum[ 1 ]:Refresh()

      cTextSay := "I am Taken"

      oSay:VARPUT( cTextSay )
      oSay:Refresh()

      Taken()

   ELSEIF nVeces = 2

      nVeces := nVeces + 1

      oBtnNum[ 2 ]:Disable()
      oBtnNum[ 2 ]:Refresh()

      cTextSay := "I am Fixes"

      oSay:VARPUT( cTextSay )
      oSay:Refresh()

      Fixes()

   ELSEIF nVeces = 3

      nVeces := nVeces + 1

      oBtnNum[ 3 ]:Disable()
      oBtnNum[ 3 ]:Refresh()

      cTextSay := "I am Free."

      oSay:VARPUT( cTextSay )
      oSay:Refresh()

      Free()

   ELSEIF nVeces = 4

      nVeces = 1

      // oDlg:End()

      cTextSay := "Yo Soy Silvio"

      oSay:VARPUT( cTextSay )
      oSay:Refresh()

      oBtnNum[ 1 ]:Enable()
      oBtnNum[ 1 ]:Refresh()

      oBtnNum[ 2 ]:Enable()
      oBtnNum[ 2 ]:Refresh()

      oBtnNum[ 3 ]:Enable()
      oBtnNum[ 3 ]:Refresh()

   ENDIF

RETURN( .T. )

FUNCTION Taken() // tomada

   ? "Taken?"

RETURN NIL

FUNCTION Fixes() // correções

   ? "Fixes?"

RETURN NIL

FUNCTION Free()  // Grátis/Livre

   ? "Free?"

RETURN NIL

// END / FIN
 
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7808
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: 3 state btnbmp

Postby Silvio.Falconi » Thu Mar 24, 2022 12:39 pm

karinha wrote:Algo asi?

Code: Select all  Expand view


// \samples\BTNPRES3.PRG

#Include "Fivewin.ch"

#Define DARKORANGE2  nRGB( 247, 192, 91 )
#Define LIGHTBLUE    nRGB(  89, 135, 214 )

MEMVAR  nVeces

FUNCTION test()

   LOCAL nPos, oDlg, oFnt, oFont, K, T, oSay, cPrompt, oExit
   LOCAL nTotCol := 2
   LOCAL nTotRow := 2
   LOCAL nMaxVal := 4
   LOCAL oBtnNum := Array( nTotRow * nTotCol )
   LOCAL xRow    := 25
   LOCAL xCol    := 40
   LOCAL xWidth  := 40
   LOCAL xHeight := 30
   LOCAL xSpace  := 2

   nVeces        := 1
   cPrompt       := "Selezionati        "

   DEFINE FONT oFnt    NAME "Ms Sans Serif" SIZE 0, -12 BOLD
   DEFINE FONT oFont   NAME "Ms Sans Serif" SIZE 0, -14 BOLD

   DEFINE DIALOG oDlg SIZE 200, 100 PIXEL TRUEPIXEL RESIZABLE   ;
      COLORS LIGHTBLUE, CLR_WHITE TRANSPARENT

   oDlg:lHelpIcon := .F.

   @ 9.0, 10 SAY oSay PROMPT cPrompt SIZE 120, 20 PIXEL OF oDlg ;
      COLORS DARKORANGE2, CLR_WHITE TRANSPARENT FONT oFont

   FOR T = 1 TO nTotRow

      FOR K = 1 TO nTotCol

         nPos := nTotCol * ( t - 1 ) + k

         @ xRow, xCol BTNBMP oBtnNum[ nPos ] SIZE xWidth, xHeight    ;
            PIXEL FLAT OF oDlg PROMPT AllTrim( Str( nPos, 2 ) )      ;
            ACTION( VERIFY_NUMBERX_BTN( oBtnNum, oDlg, oSay ) )

         oBtnNum[ nPos ]:bClrGrad = {| lInvert | If( ! lInvert,      ;
            { { 1, RGB( 255, 255, 255 ), RGB( 229, 233, 238 ) } },   ;
            { { 1 / 2, RGB( 242, 244, 246 ), RGB( 145, 201, 247 ) }, ;
            { 1 / 2, RGB( 145, 201, 247 ), RGB( 242, 244, 246 ) } } ) }

         oBtnNum[ nPos ]:Cargo := { .F., .F., .F. }

         xCol += xWidth + xSpace

      NEXT

      xRow += xHeight + xSpace

      xCol := 40

   NEXT

   @ 44, 150 BUTTON oExit PROMPT "&Ok" SIZE 40, 20 PIXEL OF oDlg ;
      ACTION( oDlg:End() ) CANCEL

   // SET FONT OF oBtnNum[ nPos ] TO oFnt
   SET FONT OF oExit              TO oFont

   ACTIVATE DIALOG oDlg CENTERED

   oFnt:End()
   oFont:End()

RETURN NIL

FUNCTION VERIFY_NUMBERX_BTN( oBtnNum, oDlg, oSay )

   LOCAL cTextSay := SPACE(20) // cPrompt

   IF nVeces = 1

      nVeces := nVeces + 1

      oBtnNum[ 1 ]:Disable()
      oBtnNum[ 1 ]:Refresh()

      cTextSay := "I am Taken"

      oSay:VARPUT( cTextSay )
      oSay:Refresh()

      Taken()

   ELSEIF nVeces = 2

      nVeces := nVeces + 1

      oBtnNum[ 2 ]:Disable()
      oBtnNum[ 2 ]:Refresh()

      cTextSay := "I am Fixes"

      oSay:VARPUT( cTextSay )
      oSay:Refresh()

      Fixes()

   ELSEIF nVeces = 3

      nVeces := nVeces + 1

      oBtnNum[ 3 ]:Disable()
      oBtnNum[ 3 ]:Refresh()

      cTextSay := "I am Free."

      oSay:VARPUT( cTextSay )
      oSay:Refresh()

      Free()

   ELSEIF nVeces = 4

      nVeces = 1

      // oDlg:End()

      cTextSay := "Yo Soy Silvio"

      oSay:VARPUT( cTextSay )
      oSay:Refresh()

      oBtnNum[ 1 ]:Enable()
      oBtnNum[ 1 ]:Refresh()

      oBtnNum[ 2 ]:Enable()
      oBtnNum[ 2 ]:Refresh()

      oBtnNum[ 3 ]:Enable()
      oBtnNum[ 3 ]:Refresh()

   ENDIF

RETURN( .T. )

FUNCTION Taken() // tomada

   ? "Taken?"

RETURN NIL

FUNCTION Fixes() // correções

   ? "Fixes?"

RETURN NIL

FUNCTION Free()  // Grátis/Livre

   ? "Free?"

RETURN NIL

// END / FIN
 



No sorry.....I have many numbers

Please see this test

I made two states Orange and Blue
I have two array one for numbers (alista) and one for numbers fix (afissi)

I select and the procedure change the color in DARKORANGE2 and the status cargo

Image
If you press the button "go" you can see two array one with the number 1 and one empty

Now I Press the number btnbmp it change on LIGHTBLUE and change the status cargo

Image

If you press the button "go" you can see two array one with the number 1 and one with the same number 1


Now I wish return to Initial state the color must be DARKCYAN and the cargo .f., .f.
how I can do ?











Code: Select all  Expand view

#include "fivewin.ch"
#define DARKORANGE2  nRGB( 247, 192, 91 )
#define LIGHTBLUE    nRGB(  89, 135, 214 )
#define DARKCYAN     nRGB( 125, 165, 224 )
static alista,aFissi


Function test()
local odlg,oBtnNum:=array(1)
local nPos:= 1
DEFINE DIALOG oDlg SIZE 600,600  PIXEL TRUEPIXEL RESIZABLE

@  10, 10 BTNBMP oBtnNum[ nPos ] PROMPT alltrim(str( nPos, 2)) ;
                         SIZE 40,30 PIXEL FLAT OF oDlg
                    oBtnNum[nPos]:bClrGrad = { | lInvert | If( ! lInvert,;
                    { { 1, DARKCYAN, DARKCYAN } },;
                    { { 1, DARKCYAN, DARKCYAN } } ) }
oBtnNum[nPos]:cargo:={.f.,.f.}
oBtnNum[nPos]:bAction := BtnAction(oBtnNum,nPos)
  @ 400,10 BUTTON oBtnConfirm PROMPT "GO" of oDlg  SIZE 80,22 PIXEL ACTION vedilista(alista)

ACTIVATE DIALOG  oDlg  center ;
on init testinit(nPos,oBtnNum)
//-----------------------------------------------------------------------//
Function BtnAction(oBtnNum,nPos)
   return { || CheckStatus( oBtnNum,nPos) }
//-----------------------------------------------------------------------//
Function CheckStatus( oBtnNum,nPos)

 if !oBtnNum[nPos]:lPressed
                   oBtnNum[nPos]:cargo[1]:=.t.
                   oBtnNum[nPos]:cargo[2]:=.t.
                   oBtnNum[nPos]:bClrGrad = { | lInvert | If( ! lInvert,;
                    { { 1, LIGHTBLUE, LIGHTBLUE } },;
                    { { 1, LIGHTBLUE, LIGHTBLUE } } ) }
                else
                   oBtnNum[nPos]:cargo[1]:=.f.
                    oBtnNum[nPos]:cargo[2]:=.f.
                   oBtnNum[nPos]:bClrGrad = { | lInvert | If( ! lInvert,;
                    { { 1, DARKCYAN, DARKCYAN } },;
                    { { 1, DARKCYAN, DARKCYAN } } ) }
                Endif

             UpdateSay(oBtnNum)
              return nil
 //------------------------------------------------//
  Function testinit(nPos,oCmb)
   local atemp:={}
   local lSelect,idcheck,n
   atemp:={1}
   For n= 1 to Len(atemp)
        idcheck:= atemp[n]
        lSelect:=.t.
        oCmb[idcheck]:lPressed:=lSelect
        oCmb[idcheck]:cargo[1]:=lSelect
        oCmb[idcheck]:cargo[2]:=.f.

        oCmb[idcheck]:bClrGrad = { | lInvert | If( ! lInvert,;
                    { { 1, DARKORANGE2, DARKORANGE2 } },;
                    { { 1, DARKORANGE2, DARKORANGE2 } } ) }
        oCmb[idcheck]:refresh()
     next
      UpdateSay(oCmb)
      return nil

proc UpdateSay(aBtn)
   local i
       aLista:={}
       aFissi:={}

        for i:=1 to 1
        if aBtn[i]:cargo[1] =.t.
          aadd(aLista,ltrim(str(i)))
          endif
          if aBtn[i]:cargo[2]= .t.
             aadd(aFissi,ltrim(str(i)))
           Endif
   Next
   return nil

 Function vedilista(alista)
    xbrowser alista
    xbrowser afissi
   return nil

 
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: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: 3 state btnbmp

Postby Jimmy » Thu Mar 24, 2022 6:44 pm

hi Silvio,

i have search in Fivewin and found just 1 Sample x:\fwh\samples\fiveres.prg using BS_3STATE
also in HMG and MiniGUI Extended Version i did not found any Sample :shock:

BS_3STATE is a "Radio-Button" Style and it is "normal" Setup at Create.
not sure if you can change Style after Create.
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: 3 state btnbmp

Postby Detlef » Thu Mar 24, 2022 10:34 pm

Silvio,
here is a much more simple code to realize a tri-state-button.
Hope it helps ...

Code: Select all  Expand view
#include "fivewin.ch"

FUNCTION Main()
//-------------
LOCAL oDlg
LOCAL nTotCol := 2
LOCAL nTotRow := 2
LOCAL oBtnNum := Array( nTotRow * nTotCol )
LOCAL xRow    := 25
LOCAL xCol    := 40
LOCAL xWidth  :=  40
LOCAL xHeight := 30
LOCAL xSpace  := 2
LOCAL k, t, oSay, nPos


   DEFINE DIALOG oDlg SIZE 800,600
   @ 10,10 SAY oSay PROMPT "0 selezionati" SIZE 100,20 PIXEL OF oDlg TRANSPARENT

   for t := 1 to nTotRow
      for k := 1 to nTotCol
         nPos := nTotCol * ( t - 1 ) + k
         @ xRow, xCol BTNBMP oBtnNum[ nPos ] PROMPT alltrim( str( nPos, 2 ) ) ;
                      SIZE xWidth, xHeight OF oDlg

         oBtnNum[ nPos ]:cargo   :=  1
         oBtnNum[ nPos ]:bAction := { | o | SetStatus( o ) }
         oBtnNum[ nPos ]:SetColor( CLR_BLACK, CLR_HGREEN )

         xCol += xWidth + xSpace
      next

      xRow += xHeight + xSpace
      xCol := 40
   next

    ACTIVATE DIALOG oDLG

RETURN NIL

PROCEDURE SetStatus( oBtn )
//-------------------------

    switch oBtn:cargo
       case 1
         oBtn:cargo := 2
         oBtn:SetColor( CLR_BLACK, CLR_YELLOW )
         EXIT

       case 2
         oBtn:cargo := 3
         oBtn:SetColor( CLR_BLACK, CLR_HRED )
         EXIT

       case 3
         oBtn:cargo := 1
         oBtn:SetColor( CLR_BLACK, CLR_HGREEN )

    end

   oBtn:refresh()
RETURN
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: 3 state btnbmp

Postby Silvio.Falconi » Sun Mar 27, 2022 4:51 pm

Detlef wrote:Silvio,
here is a much more simple code to realize a tri-state-button.
Hope it helps ...

Code: Select all  Expand view
#include "fivewin.ch"

FUNCTION Main()
//-------------
LOCAL oDlg
LOCAL nTotCol := 2
LOCAL nTotRow := 2
LOCAL oBtnNum := Array( nTotRow * nTotCol )
LOCAL xRow    := 25
LOCAL xCol    := 40
LOCAL xWidth  :=  40
LOCAL xHeight := 30
LOCAL xSpace  := 2
LOCAL k, t, oSay, nPos


   DEFINE DIALOG oDlg SIZE 800,600
   @ 10,10 SAY oSay PROMPT "0 selezionati" SIZE 100,20 PIXEL OF oDlg TRANSPARENT

   for t := 1 to nTotRow
      for k := 1 to nTotCol
         nPos := nTotCol * ( t - 1 ) + k
         @ xRow, xCol BTNBMP oBtnNum[ nPos ] PROMPT alltrim( str( nPos, 2 ) ) ;
                      SIZE xWidth, xHeight OF oDlg

         oBtnNum[ nPos ]:cargo   :=  1
         oBtnNum[ nPos ]:bAction := { | o | SetStatus( o ) }
         oBtnNum[ nPos ]:SetColor( CLR_BLACK, CLR_HGREEN )

         xCol += xWidth + xSpace
      next

      xRow += xHeight + xSpace
      xCol := 40
   next

    ACTIVATE DIALOG oDLG

RETURN NIL

PROCEDURE SetStatus( oBtn )
//-------------------------

    switch oBtn:cargo
       case 1
         oBtn:cargo := 2
         oBtn:SetColor( CLR_BLACK, CLR_YELLOW )
         EXIT

       case 2
         oBtn:cargo := 3
         oBtn:SetColor( CLR_BLACK, CLR_HRED )
         EXIT

       case 3
         oBtn:cargo := 1
         oBtn:SetColor( CLR_BLACK, CLR_HGREEN )

    end

   oBtn:refresh()
RETURN



Dear friend,
Thanks for the example, but I have a difficulty
I inserted a pattern by calling it from another dialog
when I return to the dialog where the btnbmp are they are not colored
if I insert a function to refresh all the btnbmp it tells me that it does not find the cargo variable, how can I do to save the status?

I try with
ACTIVATE DIALOG oDLG ON INIT RefreshBtns(oBtn)


Code: Select all  Expand view
Function RefreshBtns(oBtn)
local n
     For n= 1 to Len(obtn)
          If oBtn[n]:cargo= 1
                oBtn[n]:SetColor( CLR_BLACK, CLR_HGREEN )
         elseif oBtn[n]:cargo= 2
              oBtn[n]:SetColor( CLR_BLACK, CLR_YELLOW )
          elseif oBtn[n]:cargo= 3
          oBtn[n]:SetColor( CLR_BLACK, CLR_HRED )
       Endif
    oBtn[n]:refresh()
    Next
return nil



The test complete ( I try to out oBtnNum as statuc but not save o status

Code: Select all  Expand view
   
#include "fivewin.ch"

 STATIC oBtnNum


Function Test()
   local oDlg
   local oTable
   LOCAL nTotCol := 4
   LOCAL nTotRow := 2


    oBtnNum := Array( nTotRow * nTotCol )


       DEFINE DIALOG oDlg SIZE 800,600
       @ 10,10 Button "table" size 42,18 of oDlg action table(oBtnNum,nTotCol,nTotRow)

       ACTIVATE DIALOG oDLG
       return nil


    FUNCTION table(oBtnNum,nTotCol,nTotRow)
    //-------------
    LOCAL oDlg
   * LOCAL nTotCol := 2
   * LOCAL nTotRow := 2
   * LOCAL oBtnNum := Array( nTotRow * nTotCol )
    LOCAL xRow    := 25
    LOCAL xCol    := 40
    LOCAL xWidth  :=  40
    LOCAL xHeight := 30
    LOCAL xSpace  := 2
    LOCAL k, t, oSay, nPos


       DEFINE DIALOG oDlg SIZE 800,600
       @ 10,10 SAY oSay PROMPT "0 selezionati" SIZE 100,20 PIXEL OF oDlg TRANSPARENT

       for t := 1 to nTotRow
          for k := 1 to nTotCol
             nPos := nTotCol * ( t - 1 ) + k
             @ xRow, xCol BTNBMP oBtnNum[ nPos ] PROMPT alltrim( str( nPos, 2 ) ) ;
                          SIZE xWidth, xHeight FLAT OF oDlg NOROUND

             oBtnNum[ nPos ]:cargo   := { 1 ,npos }
             oBtnNum[ nPos ]:bAction := { | o | SetStatus( o ) }
             oBtnNum[ nPos ]:SetColor( CLR_BLACK, CLR_HGREEN )

             xCol += xWidth + xSpace
          next

          xRow += xHeight + xSpace
          xCol := 40
       next

        ACTIVATE DIALOG oDLG ;
                  ON INIT RefreshBtns(oBtnNum)

    RETURN NIL

    PROCEDURE SetStatus( oBtn )
    //-------------------------

        switch oBtn:cargo[1]
           case 1
             oBtn:cargo[1] := 2
             oBtn:SetColor( CLR_BLACK, CLR_YELLOW )
             EXIT

           case 2
             oBtn:cargo[1] := 3
             oBtn:SetColor( CLR_BLACK, CLR_HRED )
             EXIT

           case 3
             oBtn:cargo[1] := 1
             oBtn:SetColor( CLR_BLACK, CLR_HGREEN )

        end

       oBtn:refresh()
    RETURN



    Function RefreshBtns(oBtn)
    local n
         For n= 1 to Len(obtn)
              If oBtn[n]:cargo[1]= 1
                    oBtn[n]:SetColor( CLR_BLACK, CLR_HGREEN )
             elseif oBtn[n]:cargo[1]= 2
                  oBtn[n]:SetColor( CLR_BLACK, CLR_YELLOW )
              elseif oBtn[n]:cargo[1]= 3
              oBtn[n]:SetColor( CLR_BLACK, CLR_HRED )
           Endif
        oBtn[n]:refresh()
        Next
    return nil

 
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: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: 3 state btnbmp

Postby Detlef » Mon Mar 28, 2022 8:05 pm

Silvio,

I am not sure having understood your problem well.
But may be this could help you?

Code: Select all  Expand view
#include "fivewin.ch"

STATIC aBtnNum


FUNCTION Test()
//-------------
LOCAL oDlg, oTable
LOCAL nTotCol := 4
LOCAL nTotRow := 2


    aBtnNum := Array( nTotRow * nTotCol )


       DEFINE DIALOG oDlg SIZE 800,600
       @ 10,10 Button oTable PROMPT "table" SIZE 42, 18 of oDlg ACTION Table( nTotCol, nTotRow )

       ACTIVATE DIALOG oDLG
RETURN NIL


PROCEDURE Table( nTotCol, nTotRow )
//---------------------------------
LOCAL oDlg, oSay
LOCAL xRow    := 25
LOCAL xCol    := 40
LOCAL xWidth  := 40
LOCAL xHeight := 30
LOCAL xSpace  :=  2
LOCAL nRow, nCol, nBtn


       DEFINE DIALOG oDlg SIZE 800,600
       @ 10,10 SAY oSay PROMPT "0 selezionati" SIZE 100,20 PIXEL OF oDlg TRANSPARENT

       for nRow := 1 to nTotRow
          for nCol := 1 to nTotCol
             nBtn := nTotCol * ( nRow - 1 ) + nCol
             @ xRow, xCol BTNBMP aBtnNum[ nBtn ] PROMPT alltrim( str( nBtn, 2 ) ) ;
                          SIZE xWidth, xHeight FLAT OF oDlg NOROUND

             aBtnNum[ nBtn ]:cargo   := { 1, nBtn }
             aBtnNum[ nBtn ]:bAction := { | o | SetStatus( o ) }
             aBtnNum[ nBtn ]:SetColor( CLR_BLACK, CLR_HGREEN )

             xCol += xWidth + xSpace
          next

          xRow += xHeight + xSpace
          xCol := 40
       next

        ACTIVATE DIALOG oDLG
RETURN

PROCEDURE SetStatus( oBtn )
//-------------------------

    switch oBtn:cargo[1]
       case 1
         oBtn:cargo[1] := 2
         oBtn:SetColor( CLR_BLACK, CLR_YELLOW )
         EXIT

       case 2
         oBtn:cargo[1] := 3
         oBtn:SetColor( CLR_BLACK, CLR_HRED )
         EXIT

       case 3
         oBtn:cargo[1] := 1
         oBtn:SetColor( CLR_BLACK, CLR_HGREEN )

    end

   oBtn:refresh()
RETURN
 


Regards, Detlef
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: 3 state btnbmp

Postby Silvio.Falconi » Mon Mar 28, 2022 9:44 pm

I'm afraid I must make a new array type anumbers( toty,totx)
I made it for the prices (see the ticket ) and run ok

the problem is when i select fir a sample 5 numbers and then I return to main dialog and the return back i cannot change the cargo because it not found it

I had the same problem with the array if prices then I found the solution
Now I have alista with numbers, aruote with ruotes, and aprices with prices , so I can continue to make the print of the ticket do you Remember?
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: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: 3 state btnbmp

Postby Detlef » Tue Mar 29, 2022 5:30 am

Good morning Silvio.
I'm not very involved at your system. And so I don’t understand your problem completely.
If you send me a not working code I could have a look at it.

Regards, Detlef
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: 3 state btnbmp

Postby Silvio.Falconi » Tue Mar 29, 2022 7:13 am

Detlef wrote:Good morning Silvio.
I'm not very involved at your system. And so I don’t understand your problem completely.
If you send me a not working code I could have a look at it.

Regards, Detlef


I not have your mail
my is silvio(dot)falconi(at)gmail(dot)com
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: 7052
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 106 guests