Xbrowse Check/uncheck all

Xbrowse Check/uncheck all

Postby Silvio.Falconi » Fri May 20, 2022 7:43 am

I made on a dialog some xbrowses as you can see here

Image

on Xbrowse I used :SetMultiSelectCol()

with the buttons ( red box) I wish select all items or unselect all

wich is the command ?

I save the months in the ini file with an example string

111111111111

how do i load the configuration against the string?

that is, if I have 111111111101 I must see all active checkboxes except the penultimate (November)

I load the string with and save an array

For n=1 to 12
aadd(aInfo,IIF(val(SubStr(cMese, n, 1))= 1,.t.,.f.)
next

then how insert it on xbrowse ?
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: 6849
Joined: Thu Oct 18, 2012 7:17 pm

Re: Xbrowse Check/uncheck all

Postby nageswaragunupudi » Sat May 21, 2022 2:41 am

oBrw:SelectRow( 0 ) // clear all i.e., select none
oBrw:SelectRow( 4 ) // Select all

After oBrw:CreateFromCode()
For n=1 to 12
oBrw:aSelected[ n ] := ( SubStr(cMese, n, 1)) == "1" )
next
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10308
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Xbrowse Check/uncheck all

Postby Silvio.Falconi » Sat May 21, 2022 7:55 am

nageswaragunupudi wrote:oBrw:SelectRow( 0 ) // clear all i.e., select none
oBrw:SelectRow( 4 ) // Select all

After oBrw:CreateFromCode()
For n=1 to 12
oBrw:aSelected[ n ] := ( SubStr(cMese, n, 1)) == "1" )
next


Thanks Rao

I tring to create a custom Class from Txbrowse can you help me
give me error on custom class
Code: Select all  Expand view

Error description: Error BASE/1133  Bound error: array assign
   Args:
     [   1] = N   1
 



my custom class

Code: Select all  Expand view

#include "fivewin.ch"
#include 'xbrowse.ch'
#include "constant.ch"
Function test()
local oDlg

local cSection:="ARCHIVIO"
local cIniFile  :=  cFilePath( GetModuleFileName( GetInstance() ) ) + "test.ini"
local cMese    := GetIni( cInifile, cSection,"Mesi", "111111111101" )
local oLbxMesi
local aMesi  := {"Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto",;
                                                    "Settembre", "Ottobre", "Novembre", "Dicembre"}
local cTitle:="test Custom xbrowse"
local oBtnOk,oBtnClose,oBtnHelp

     local nBottom   := 35
     local nRight    := 90
     local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
     local nHeight := nBottom * DLG_CHARPIX_H
     local oBtnLbx:=array(2)
     local nRow,nCol
     local oGrp:=array(1)
     local aTitleLbx:={"Mesi"}
     local n,oFont,oBold

    DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0, 12
    DEFINE FONT oBold NAME "MS Sans Serif" SIZE 0, 12 BOLD



DEFINE DIALOG  oDlg ;
SIZE nWidth, nHeight  PIXEL  ;
TITLE cTitle //STYLE WS_POPUP

    nRow:=121
     nCol:=5

           @ nrow-6, nCol   GROUP oGrp[1] TO nRow+11,nCol+79  PIXEL of oDlg TRANSPARENT
           @ nRow,nCol+2 Say aTitleLbx[1] Size 40,10 PIXEL of oDlg Font oBold
           nCol+=60
           @ nRow ,nCol  BTNBMP oBtnLbx[1] FILENAME".\bitmaps\ok.png" ;
           of oDlg FLAT SIZE 9,8 ACTION Select_all(oLbxMesi,.t.) NOBORDER
           nCol+=10
           @ nRow ,nCol BTNBMP oBtnLbx[2]  FILENAME".\bitmaps\no.png";
           of oDlg FLAT SIZE 9,8 ACTION Select_all(oLbxMesi,.f.) NOBORDER


           oLbxMesi:=TXbrCheck():New(132, 5, 80, 110, oDlg)
           oLbxMesi:HasBorder(.f.)  // nStyle(WS_NOBORDER)
           oLbxMesi:setarray(aMesi)
           oLbxMesi:aCols[1]:cHeader    := i18n("Mesi")
           oLbxMesi:aCols[1]:nWidth     := 100
            setcheckbrw(oLbxMesi)
           *oLbxMesi:CreateFromCode()
           For n=1 to len(aMesi)
            *  oLbxMesi:aSelected[n]:= IIF( SubStr(cMese, n, 1)== "1",.t.,.f.)
           next




 oDlg:bResized  := <||
        local oRect        := oDlg:GetCliRect()
                oBtnOk:nTop   := oRect:nBottom - 40
                oBtnOK:nLeft  := oRect:nRight - 310
                oBtnClose:nTop     := oRect:nBottom - 40
                oBtnClose:nLeft    := oRect:nRight - 210
                oBtnHelp:nTop     := oRect:nBottom - 40
                oBtnHelp:nLeft    := oRect:nRight - 110

        return nil
        >

      @ 100,10 BUTTON oBtnok PROMPT "OK" of oDlg SIZE 45,15 DEFAULT ACTION ( oDlg:end( IDOK  ) )
      @ 100,10 BUTTON oBtnClose PROMPT "EXIT" of oDlg  SIZE 45,15 CANCEL ACTION ( oDlg:end( IDCANCEL ) )
      @ 100,10 BUTTON oBtnHelp PROMPT "HELP" of oDlg  SIZE 45,15 CANCEL ACTION NIL


ACTIVATE DIALOG oDlg center ;
        ON INIT  (eval(oDlg:bResized) )
      IF  oDlg:nresult == IDOK
              cMese:=""
              for n=1 to 12
                cmese+= IIf(oBrwMesi:aselected[n]=.t.,"1","0")
               Next
                   //saving
                  WritePProString(cSection,"Mesi",cMese,cInifile)
    ENDIF


RETURN NIL

//-----------------------------------------------------------------------//
Static Function Select_all(oLbx,lValue)
   If lvalue
      oLbx:SelectRow( 4 ) // Select all
   else
      oLbx:SelectRow( 0 ) // clear all i.e., select none
   Endif
 return nil
//--------------------------------------------------------------------------//

//------------------------ CLASS CustomBrowse ...........................//
CLASS TXbrCheck  FROM TXBrowse
   CLASSDATA lRegistered AS LOGICAL
   DATA aItems
   METHOD New (nRow, nCol, nWidth, nHeight, oWnd)
   METHOD Adjust()
   METHOD aInfo()
ENDCLASS

METHOD New(nRow, nCol, nWidth, nHeight, oWnd)  CLASS TXbrCheck

   ::nTop       := nRow
   ::nLeft      := nCol
   ::nBottom    := ::nTop  + nHeight - 1
   ::nRight     := ::nLeft + nWidth - 1
   ::aItems     := {}

return ::SuPer:New()


METHOD Adjust() CLASS TXbrCheck
  *   local oBrw  := Self
         ::nMarqueeStyle       := MARQSTYLE_NOMARQUEE
         ::nColDividerStyle    := LINESTYLE_LIGHTGRAY
         ::lColDividerComplete := .t.
         ::lRecordSelector     := .f.
         ::lHScroll            := .f.
         ::lVScroll            := .f.
         ::nHeaderHeight       := 20
         ::nRowHeight          := 17
         ::l2007               := .f.
         ::nStretchCol         := -1
         ::lDrawBorder         := .t.
         ::lHeader             := .f.
         ::nRecSelColor        := nRgb( 245,244,234)
         ::SetMultiSelectCol()


  return ::Super:Adjust()


METHOD aInfo() CLASS TXbrCheck

         local aInfo := {}
         local n
         local nLen:= Len( ::aSelected )

        for n := 1 to nLen
          aadd( aInfo, ::aselected[n] )
        next

return aInfo

 function GetIni( cIni, cSection, cEntry, xDefault )

   local oIni
   local xVar := xDefault


   INI oIni FILE cIni
   get xVar            ;
      SECTION cSection ;
      ENTRY cEntry     ;
      default xDefault ;
      OF oIni
   ENDINI

   return xVar

Function setcheckbrw(oLbx)

         WITH OBJECT oLbx
         :nMarqueeStyle       := MARQSTYLE_NOMARQUEE
         :nColDividerStyle    := LINESTYLE_LIGHTGRAY
         :lColDividerComplete := .t.
         :lRecordSelector     := .f.
         :lHScroll            := .f.
         :lVScroll            := .f.
         :nHeaderHeight       := 20
         :nRowHeight          := 17
         :l2007               := .f.
         :nStretchCol           := -1
         :lDrawBorder := .t.
         :lHeader     := .f.
         :nRecSelColor     :=   nRgb( 245,244,234)
         :SetMultiSelectCol()
         :CreateFromCode()
       END
  return nil



 
Last edited by Silvio.Falconi on Sat May 21, 2022 9:24 am, edited 3 times in total.
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: 6849
Joined: Thu Oct 18, 2012 7:17 pm

Re: Xbrowse Check/uncheck all

Postby nageswaragunupudi » Sat May 21, 2022 8:39 am

yes
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10308
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Xbrowse Check/uncheck all

Postby Silvio.Falconi » Sat May 21, 2022 9:12 am

nageswaragunupudi wrote:yes




sorry I change the message look above pls
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: 6849
Joined: Thu Oct 18, 2012 7:17 pm

Re: Xbrowse Check/uncheck all

Postby Silvio.Falconi » Sat May 21, 2022 9:41 am

New test

run but the xbrowse take all the dialog

oLbxMesi:=TXbrCheck():New(132, 5, 80, 110, oDlg) // ????????????? not create the xbrowse on my ccordinates
oLbxMesi:HasBorder(.f.) // nStyle(WS_NOBORDER)
oLbxMesi:setarray(aMesi)
oLbxMesi:SetMultiSelectCol()
oLbxMesi:aCols[1]:cHeader := i18n("Mesi")
oLbxMesi:aCols[1]:nWidth := 100
oLbxMesi:CreateFromCode()





Code: Select all  Expand view


#include "fivewin.ch"
#include 'xbrowse.ch'
#include "constant.ch"
Function test()
local oDlg

local cSection:="ARCHIVIO"
local cIniFile  :=  cFilePath( GetModuleFileName( GetInstance() ) ) + "test.ini"
local cMese    := GetIni( cInifile, cSection,"Mesi", "111111111101" )
local oLbxMesi
local aMesi  := {"Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto",;
                                                    "Settembre", "Ottobre", "Novembre", "Dicembre"}
local cTitle:="test Custom xbrowse"
local oBtnOk,oBtnClose,oBtnHelp

     local nBottom   := 35
     local nRight    := 90
     local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
     local nHeight := nBottom * DLG_CHARPIX_H
     local oBtnLbx:=array(2)
     local nRow,nCol
     local oGrp:=array(1)
     local aTitleLbx:={"Mesi"}
     local n,oFont,oBold

    DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0, 12
    DEFINE FONT oBold NAME "MS Sans Serif" SIZE 0, 12 BOLD



DEFINE DIALOG  oDlg ;
SIZE nWidth, nHeight  PIXEL  ;
TITLE cTitle //STYLE WS_POPUP

    nRow:=121
     nCol:=5

           @ nrow-6, nCol   GROUP oGrp[1] TO nRow+11,nCol+79  PIXEL of oDlg TRANSPARENT
           @ nRow,nCol+2 Say aTitleLbx[1] Size 40,10 PIXEL of oDlg Font oBold
           nCol+=60
           @ nRow ,nCol  BTNBMP oBtnLbx[1] FILENAME".\bitmaps\ok.png" ;
           of oDlg FLAT SIZE 9,8 ACTION Select_all(oLbxMesi,.t.) NOBORDER
           nCol+=10
           @ nRow ,nCol BTNBMP oBtnLbx[2]  FILENAME".\bitmaps\no.png";
           of oDlg FLAT SIZE 9,8 ACTION Select_all(oLbxMesi,.f.) NOBORDER


           oLbxMesi:=TXbrCheck():New(132, 5, 80, 110, oDlg)
           oLbxMesi:HasBorder(.f.)  // nStyle(WS_NOBORDER)
           oLbxMesi:setarray(aMesi)
           oLbxMesi:SetMultiSelectCol()
           oLbxMesi:aCols[1]:cHeader    := i18n("Mesi")
           oLbxMesi:aCols[1]:nWidth     := 100
           oLbxMesi:CreateFromCode()

           For n=1 to len(aMesi)
            *  oLbxMesi:aSelected[n]:= IIF( SubStr(cMese, n, 1)== "1",.t.,.f.)
           next




 oDlg:bResized  := <||
        local oRect        := oDlg:GetCliRect()
                oBtnOk:nTop   := oRect:nBottom - 40
                oBtnOK:nLeft  := oRect:nRight - 310
                oBtnClose:nTop     := oRect:nBottom - 40
                oBtnClose:nLeft    := oRect:nRight - 210
                oBtnHelp:nTop     := oRect:nBottom - 40
                oBtnHelp:nLeft    := oRect:nRight - 110

        return nil
        >

      @ 100,10 BUTTON oBtnok PROMPT "OK" of oDlg SIZE 45,15 DEFAULT ACTION ( oDlg:end( IDOK  ) )
      @ 100,10 BUTTON oBtnClose PROMPT "EXIT" of oDlg  SIZE 45,15 CANCEL ACTION ( oDlg:end( IDCANCEL ) )
      @ 100,10 BUTTON oBtnHelp PROMPT "HELP" of oDlg  SIZE 45,15 CANCEL ACTION NIL


ACTIVATE DIALOG oDlg center ;
        ON INIT  (eval(oDlg:bResized) )
      IF  oDlg:nresult == IDOK
              cMese:=""
              for n=1 to 12
                cmese+= IIf(oBrwMesi:aselected[n]=.t.,"1","0")
               Next
                   //saving
                  WritePProString(cSection,"Mesi",cMese,cInifile)
    ENDIF


RETURN NIL

//-----------------------------------------------------------------------//
Static Function Select_all(oLbx,lValue)
   If lvalue
      oLbx:SelectRow( 4 ) // Select all
   else
      oLbx:SelectRow( 0 ) // clear all i.e., select none
   Endif
 return nil
//--------------------------------------------------------------------------//

//------------------------ CLASS CustomBrowse ...........................//
CLASS TXbrCheck  FROM TXBrowse
   CLASSDATA lRegistered AS LOGICAL
   METHOD New (nRow, nCol, nWidth, nHeight, oWnd)
   METHOD aInfo()
ENDCLASS

METHOD New(nRow, nCol, nWidth, nHeight, oWnd)  CLASS TXbrCheck
   local lPixel:=.t.

   ::nTop       :=  nRow * If( lPixel, 1, BRSE_CHARPIX_H ) // 14
   ::nLeft      :=  nCol * If( lPixel, 1, BRSE_CHARPIX_W )  //8
   ::oWnd       :=  oWnd

   if nWidth != nil
         if nWidth <= 0
            ::nRightMargin := -nWidth
            if ::oWnd:IsKindOf( "TDIALOG" ) .and. Empty( ::oWnd:hWnd ) .and. !::oWnd:lTruePixel
               ::nRightMargin *= 2
            endif
         else
            ::nRight     := ::nLeft + nWidth - 1
         endif
      endif

      if nHeight != nil
         if nHeight <= 0
            ::nBottomMargin    := -nHeight
            if ::oWnd:IsKindOf( "TDIALOG" ) .and. Empty( ::oWnd:hWnd ) .and. !::oWnd:lTruePixel
               ::nBottomMargin *= 2
            endif
         else
            ::nBottom    := ::nTop + nHeight - 1
         endif
      endif



         ::nMarqueeStyle       := MARQSTYLE_NOMARQUEE
         ::nColDividerStyle    := LINESTYLE_LIGHTGRAY
         ::lColDividerComplete := .t.
         ::lRecordSelector     := .f.
         ::lHScroll            := .f.
         ::lVScroll            := .f.
         ::nHeaderHeight       := 20
         ::nRowHeight          := 17
         ::l2007               := .f.
         ::nStretchCol           := -1
         ::lDrawBorder := .t.
         ::lHeader     := .f.
         ::nRecSelColor     :=   nRgb( 245,244,234)
       *  ::SetMultiSelectCol()


return ::SuPer:New()




METHOD aInfo() CLASS TXbrCheck

         local aInfo := {}
         local n
         local nLen:= Len( ::aSelected )

        for n := 1 to nLen
          aadd( aInfo, ::aselected[n] )
        next

return aInfo

 function GetIni( cIni, cSection, cEntry, xDefault )

   local oIni
   local xVar := xDefault


   INI oIni FILE cIni
   get xVar            ;
      SECTION cSection ;
      ENTRY cEntry     ;
      default xDefault ;
      OF oIni
   ENDINI

   return xVar

Function setcheckbrw(oLbx)

         WITH OBJECT oLbx
         :nMarqueeStyle       := MARQSTYLE_NOMARQUEE
         :nColDividerStyle    := LINESTYLE_LIGHTGRAY
         :lColDividerComplete := .t.
         :lRecordSelector     := .f.
         :lHScroll            := .f.
         :lVScroll            := .f.
         :nHeaderHeight       := 20
         :nRowHeight          := 17
         :l2007               := .f.
         :nStretchCol           := -1
         :lDrawBorder := .t.
         :lHeader     := .f.
         :nRecSelColor     :=   nRgb( 245,244,234)
         :SetMultiSelectCol()
         :CreateFromCode()
       END
  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: 6849
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 52 guests