FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Know a state of checkbox
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Know a state of checkbox
Posted: Mon Nov 21, 2022 04: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 (fw): Select all Collapse
#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 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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Know a state of checkbox
Posted: Mon Nov 21, 2022 07:10 PM
Dear Silvio,

Fixed:
Code (fw): Select all Collapse
#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
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Know a state of checkbox
Posted: Tue Nov 22, 2022 08:49 AM

thanks Antonio

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