Xbrowse Menu with checkbox

Xbrowse Menu with checkbox

Postby Silvio.Falconi » Tue Nov 15, 2022 11:56 am

is it possible to create a menu through an xbrowse and having the items with checkboxes?

for example i have this adatamenu array

Code: Select all  Expand view
local aDataMenu:={;
    {.f., "Cadenza 0" ,{|| Cadenza(0,oCmb,oSay)} } ,;
    {.f., "Cadenza 1" ,{|| Cadenza(1,oCmb,oSay)} } ,;
    {.f., "Cadenza 2" ,{|| Cadenza(2,oCmb,oSay)} } ,;
    {.f., "Cadenza 3" ,{|| Cadenza(3,oCmb,oSay)} } ,;
    {.f., "Cadenza 4" ,{|| Cadenza(4,oCmb,oSay)} } ,;
    {.f., "Cadenza 5" ,{|| Cadenza(5,oCmb,oSay)} } ,;
    {.f., "Cadenza 6" ,{|| Cadenza(6,oCmb,oSay)} } ,;
    {.f., "Cadenza 7" ,{|| Cadenza(7,oCmb,oSay)} } ,;
    {.f., "Cadenza 8" ,{|| Cadenza(8,oCmb,oSay)} } ,;
    {.f., "Cadenza 9" ,{|| Cadenza(9,oCmb,oSay)} } ,;
     }


if the user presses a checkbox and the procedure performs the related operation (which I put inside a codeblock)

in xbrowse you have to display only the first r field and the second ie the checkbox and the menu text

I made a small test but not run

Code: Select all  Expand view

#include "fivewin.ch"

Function testLbx()
     local oDlg, oBrw, oFont,oBold
     local aBmp:= {".\bitmaps\CHECK_box.bmp", ".\bitmaps\NOCHECK_box.bmp"}
     local oCmb,oSay

   local aDataMenu:={;
    {.f., "Cadenza 0" ,{|| Cadenza(0,oCmb,oSay)} } ,;
    {.f., "Cadenza 1" ,{|| Cadenza(1,oCmb,oSay)} } ,;
    {.f., "Cadenza 2" ,{|| Cadenza(2,oCmb,oSay)} } ,;
    {.f., "Cadenza 3" ,{|| Cadenza(3,oCmb,oSay)} } ,;
    {.f., "Cadenza 4" ,{|| Cadenza(4,oCmb,oSay)} } ,;
    {.f., "Cadenza 5" ,{|| Cadenza(5,oCmb,oSay)} } ,;
    {.f., "Cadenza 6" ,{|| Cadenza(6,oCmb,oSay)} } ,;
    {.f., "Cadenza 7" ,{|| Cadenza(7,oCmb,oSay)} } ,;
    {.f., "Cadenza 8" ,{|| Cadenza(8,oCmb,oSay)} } ,;
    {.f., "Cadenza 9" ,{|| Cadenza(9,oCmb,oSay)} } ,;
     }



       DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -16
       DEFINE FONT oBold  NAME 'Tahoma' SIZE 0, -14 BOLD

       DEFINE DIALOG oDlg SIZE 400,400 PIXEL TRUEPIXEL ;
       TITLE "test menu";
       COLOR CLR_BLACK,nRgb(245,244,234)  ;
       STYLE nOr( DS_MODALFRAME, WS_POPUP, WS_CAPTION,  4 )

       @ 10,20 XBROWSE oBrw SIZE -10,-90 PIXEL OF oDlg ;
          DATASOURCE aDataMenu ;
          COLUMNS 2,1 ;
          HEADERS "Colonne","" ;
          COLSIZES 100, 40 ;
           NOBORDER  FONT oFONT

        WITH OBJECT oBrw
          :l2007:=.f.
          :nStretchCol   := STRETCHCOL_WIDEST
          :lDrawBorder := .t.
          :bClrHeader       := {|| { ,nRgb(233,229,206) } }
          :bClrFooter       := {|| { ,nRgb( 245,244,234) } }
          :nColDividerStyle := LINESTYLE_LIGHTGRAY
          :lRecordSelector     := .f.
          :lHScroll            := .f.

          WITH OBJECT :aCols[ 3]
             :SetCheck(aBmp, .t. )
             :nHeadBmpNo    := 2
          END
          :CreateFromCode()
       END

     ACTIVATE DIALOG oDlg CENTERED ;
                 ON INIT (oDlg:resize())
       RELEASE oFont,oBold
       oBrowse:refresh()
    return nil


Function Cadenza(k,oCmb,oSay)
   msginfo(k)
   return nil



Any solution ?
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: Xbrowse Menu with checkbox

Postby Silvio.Falconi » Tue Nov 15, 2022 4:26 pm

in the forum https://forums.fivetechsupport.com/viewtopic.php?f=3&t=35295&p=210098&hilit=xbrowse+menu&sid=be1193a52d000ded3ceed6b8cf2c0601&sid=dc06ca29c751280f6b958bcbc06d1d2c#p210129

I found an example but made with the tree, it could be fine but after that I wouldn't have the possibility to memorize the selections

as you can see on this picture

Image

instead with a possible checkbox I could store all the selections selected by the user in a file

Any solution ?
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: Xbrowse Menu with checkbox

Postby nageswaragunupudi » Fri Nov 18, 2022 2:27 pm

is it possible to create a menu through an xbrowse and having the items with checkboxes?

for example i have this adatamenu array


Please change this part of the code:
Code: Select all  Expand view
        WITH OBJECT :aCols[ 3]
             :SetCheck(aBmp, .t. )
             :nHeadBmpNo    := 2
          END
 


TO
Code: Select all  Expand view
         WITH OBJECT :aCols[ 2 ]
             :SetCheck( aBmp , .t. )
             :nHeadBmpNo    := 2
             :bOnChange    := { || Eval( oBrw:aRow[ 3 ] ) }
          END
 
Regards

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

Re: Xbrowse Menu with checkbox

Postby Silvio.Falconi » Fri Nov 18, 2022 2:57 pm

nageswaragunupudi wrote:
is it possible to create a menu through an xbrowse and having the items with checkboxes?

for example i have this adatamenu array


Please change this part of the code:
Code: Select all  Expand view
        WITH OBJECT :aCols[ 3]
             :SetCheck(aBmp, .t. )
             :nHeadBmpNo    := 2
          END
 


TO
Code: Select all  Expand view
         WITH OBJECT :aCols[ 2 ]
             :SetCheck( aBmp , .t. )
             :nHeadBmpNo    := 2
             :bOnChange    := { || Eval( oBrw:aRow[ 3 ] ) }
          END
 







I tried and run ok

Image


I must click on checkboxes, how I can make to click on second column ?
I made
oBrw:aCols[ 2 ]:bLDClickData := < |r,c,f,oCol|
oBrw:aCols[ 1 ]:SetCheck( aBmp , .t. )
return nil
>

but not run



Can we have also the tree with checkboxes?

because I have many functions to put there
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: Xbrowse Menu with checkbox

Postby nageswaragunupudi » Fri Nov 18, 2022 4:41 pm

Code: Select all  Expand view
         oBrw:aCols[ 2 ]:bLDClickData := { || oBrw:aCols[ 1 ]:CheckToggle() }
 
Regards

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

Re: Xbrowse Menu with checkbox

Postby Silvio.Falconi » Sun Nov 20, 2022 12:46 pm

nageswaragunupudi wrote:
Code: Select all  Expand view
         oBrw:aCols[ 2 ]:bLDClickData := { || oBrw:aCols[ 1 ]:CheckToggle() }
 


thanks Rao

Can we have tree xbrowse with checkboxes ?

Once the selected numbers are saved, I can reload them in the table, but I still have problems setting the check to the brow (adatamenu)
I have found for now the solution to save the configuration in an ini file in this way:

Code: Select all  Expand view
[Datamenu]
menu=0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|
 


Image

the error in the video is given because I reset the numbers or I deleted all the selected numbers, then the UncheckAll() function tries to delete all checkboxes and makes an error because the command is wrong

FOR i := 1 TO LEN(:aCols)
oCol := :aCols[ i ]
oCol:CheckToggle()
next



But it perhaps is wrong or bad
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: No registered users and 93 guests