Know a state of checkbox

Know a state of checkbox

Postby Silvio.Falconi » Mon Nov 21, 2022 4:49 pm

?aChk[1]:lChecked()

why it is wrong ?

How I can Know if a checkbox is true or false ?



Please try this test , why I cannot change the state of checkboxes with select_All() )

Code: Select all  Expand view


#include "FiveWin.ch"
#include "Constant.ch"

Function test()
   local oDlg,oFont
   local aRuote  := {"Bari","Cagliari","Firenze","Genova",;
                   "Milano","Napoli","Palermo","Roma","Torino",;
                   "Venezia","Nazionale","Tutte"}
   local aValues := Array( 12 )
   local nRow:=30
   local nCol:= 5
   local nSize1:= 50
   local nSize2:= 10
local nBottom   := 44
   local nRight    := 110
   local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
   local nHeight := nBottom * DLG_CHARPIX_H


   AFill( aValues, .F. )

DEFINE FONT oFont NAME "Tahoma"  SIZE 0, -11
   DEFINE DIALOG oDlg        ;
   TITLE "test"   ;
   SIZE nWidth, nHeight   PIXEL ;
   COLOR CLR_BLACK,CLR_WHITE  RESIZABLE

 @ nRow,nCol CHECKBOX aValues[ 1 ] Prompt aRuote[1] SIZE nSize1, nSize2 PIXEL OF  oDlg
  nRow+=12
  @ nRow,nCol CHECKBOX aValues[ 2 ] Prompt aRuote[2] SIZE nSize1, nSize2 PIXEL OF  oDlg
  nRow+=12
  @ nRow,nCol CHECKBOX aValues[ 3 ] Prompt aRuote[3] SIZE nSize1, nSize2 PIXEL OF  oDlg
  nRow+=12
  @ nRow,nCol CHECKBOX aValues[ 4 ] Prompt aRuote[4] SIZE nSize1, nSize2 PIXEL OF  oDlg
  nRow+=12
  @ nRow,nCol CHECKBOX aValues[ 5 ] Prompt aRuote[5] SIZE nSize1, nSize2 PIXEL OF  oDlg
  nRow+=12
  @ nRow,nCol CHECKBOX aValues[ 6 ] Prompt aRuote[6] SIZE nSize1, nSize2 PIXEL OF  oDlg
    nRow:=30
    nCol:=60
  @ nRow,nCol CHECKBOX aValues[ 7 ] Prompt aRuote[7] SIZE nSize1, nSize2 PIXEL OF  oDlg
  nRow+=12
  @ nRow,nCol CHECKBOX aValues[ 8 ] Prompt aRuote[8] SIZE nSize1, nSize2 PIXEL OF  oDlg
  nRow+=12
  @ nRow,nCol CHECKBOX aValues[ 9 ] Prompt aRuote[9] SIZE nSize1, nSize2 PIXEL OF  oDlg
   nRow+=12
  @ nRow,nCol CHECKBOX aValues[ 10 ] Prompt aRuote[10] SIZE nSize1, nSize2 PIXEL OF  oDlg
  nRow+=12
  @ nRow,nCol CHECKBOX aValues[ 11 ] Prompt aRuote[11] SIZE nSize1, nSize2 PIXEL OF  oDlg
  nRow+=12
  @ nRow,nCol CHECKBOX aValues[ 12 ] Prompt aRuote[12] SIZE nSize1, nSize2 PIXEL OF  oDlg;
              ON CHANGE (Select_All(aValues,aValues[12]))



 oDlg:bResized := <||
                        local oRect := oDlg:GetCliRect()
                       
                 RETURN NIL
                       >

ACTIVATE DIALOG oDlg centered;  
       ON INIT (       Eval(oDlg:bResized)   )
RETURN  NIL
//--------------------------------------------------------------------------------//

Static Function Select_All(aChk,lValue)
     ?  lValue

    For n= 1 to len(aChk)
       aChk[n]:SetCheck(lValue)
   next
   return nil
//--------------------------------------------------------------------------------//

 



I tried also with

@ nRow,nCol CHECKBOX aValues[ 12 ] Prompt aRuote[12] SIZE nSize1, nSize2 PIXEL OF oDlg;
ON CHANGE (Select_All(aValues))

Static Function Select_All(aChk)
local lValue:=aChk[12]:lchecked()
For n= 1 to 11 //len(aChk)
aChk[n]:SetCheck(lValue)
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: 6832
Joined: Thu Oct 18, 2012 7:17 pm

Re: Know a state of checkbox

Postby Antonio Linares » Mon Nov 21, 2022 7:10 pm

Dear Silvio,

Fixed:
Code: Select all  Expand view


#include "FiveWin.ch"
#include "Constant.ch"

Function test()
   local oDlg,oFont
   local aRuote  := {"Bari","Cagliari","Firenze","Genova",;
                   "Milano","Napoli","Palermo","Roma","Torino",;
                   "Venezia","Nazionale","Tutte"}
   local aValues := Array( 12 )
   local oCbxs := Array( 12 )
   local nRow:=30
   local nCol:= 5
   local nSize1:= 50
   local nSize2:= 10
local nBottom   := 44
   local nRight    := 110
   local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
   local nHeight := nBottom * DLG_CHARPIX_H


   AFill( aValues, .F. )

DEFINE FONT oFont NAME "Tahoma"  SIZE 0, -11
   DEFINE DIALOG oDlg        ;
   TITLE "test"   ;
   SIZE nWidth, nHeight   PIXEL ;
   COLOR CLR_BLACK,CLR_WHITE  RESIZABLE

 @ nRow,nCol CHECKBOX oCbxs[ 1 ] VAR aValues[ 1 ] Prompt aRuote[1] SIZE nSize1, nSize2 PIXEL OF  oDlg
  nRow+=12
  @ nRow,nCol CHECKBOX oCbxs[ 2 ] VAR aValues[ 2 ] Prompt aRuote[2] SIZE nSize1, nSize2 PIXEL OF  oDlg
  nRow+=12
  @ nRow,nCol CHECKBOX oCbxs[ 3 ] VAR aValues[ 3 ] Prompt aRuote[3] SIZE nSize1, nSize2 PIXEL OF  oDlg
  nRow+=12
  @ nRow,nCol CHECKBOX oCbxs[ 4 ] VAR aValues[ 4 ] Prompt aRuote[4] SIZE nSize1, nSize2 PIXEL OF  oDlg
  nRow+=12
  @ nRow,nCol CHECKBOX oCbxs[ 5 ] VAR aValues[ 5 ] Prompt aRuote[5] SIZE nSize1, nSize2 PIXEL OF  oDlg
  nRow+=12
  @ nRow,nCol CHECKBOX oCbxs[ 6 ] VAR aValues[ 6 ] Prompt aRuote[6] SIZE nSize1, nSize2 PIXEL OF  oDlg
    nRow:=30
    nCol:=60
  @ nRow,nCol CHECKBOX oCbxs[ 7 ] VAR aValues[ 7 ] Prompt aRuote[7] SIZE nSize1, nSize2 PIXEL OF  oDlg
  nRow+=12
  @ nRow,nCol CHECKBOX oCbxs[ 8 ] VAR aValues[ 8 ] Prompt aRuote[8] SIZE nSize1, nSize2 PIXEL OF  oDlg
  nRow+=12
  @ nRow,nCol CHECKBOX oCbxs[ 9 ] VAR aValues[ 9 ] Prompt aRuote[9] SIZE nSize1, nSize2 PIXEL OF  oDlg
   nRow+=12
  @ nRow,nCol CHECKBOX oCbxs[ 10 ] VAR aValues[ 10 ] Prompt aRuote[10] SIZE nSize1, nSize2 PIXEL OF  oDlg
  nRow+=12
  @ nRow,nCol CHECKBOX oCbxs[ 11 ] VAR aValues[ 11 ] Prompt aRuote[11] SIZE nSize1, nSize2 PIXEL OF  oDlg
  nRow+=12
  @ nRow,nCol CHECKBOX oCbxs[ 12 ] VAR aValues[ 12 ] Prompt aRuote[12] SIZE nSize1, nSize2 PIXEL OF  oDlg;
              ON CHANGE (Select_All(oCbxs,aValues[12]))



 oDlg:bResized := <||
                        local oRect := oDlg:GetCliRect()
                       
                 RETURN NIL
                       >

ACTIVATE DIALOG oDlg centered;  
       ON INIT (       Eval(oDlg:bResized)   )
RETURN  NIL
//--------------------------------------------------------------------------------//

Static Function Select_All(aChk,lValue)
     local n
     ?  lValue

    For n= 1 to len(aChk)
       aChk[n]:SetCheck(lValue)
    next

   return nil
//--------------------------------------------------------------------------------//

 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41365
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Know a state of checkbox

Postby Silvio.Falconi » Tue Nov 22, 2022 8:49 am

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Antonio Linares and 19 guests