Page 1 of 2

Checkbox in Browse

Posted: Tue Nov 10, 2015 8:15 am
by Sbryan
Hi everyone,

I'm fairly new to eXpress++ and have been learning a lot in the past few weeks.

Currently I need to have a checkbox in a browse and found this code from an older post.

Code: Select all

#INCLUDE "dcdialog.CH"
#INCLUDE "dcbitmap.CH"
#INCLUDE "appevent.CH"

FUNCTION Main()

LOCAL GetList[0], oBrowse, aDir, n := 1, GetOptions

aDir := Directory()
FOR n := 1 TO Len(aDir)
  AAdd(aDir[n],.f.)
NEXT

n := 1
@ 0,0 DCBROWSE oBrowse DATA aDir SIZE 80,12 ;
      PRESENTATION DC_BrowPres() FIT ;
      POINTER n ;
      EDIT xbeBRW_ItemSelected ACTION {|o|o:colPos > 1}

DCBROWSECOL DATA {|x|x:=DC_GetColArray(11,oBrowse), ;
      IIF(x,BITMAP_CHECKBOX_CHECKED_S,BITMAP_CHECKBOX_UNCHECKED_S)} ;
      PARENT oBrowse HEADER 'Sel' WIDTH 1 ;
      TYPE XBPCOL_TYPE_BITMAP ;
      PROTECT {||.t.} ;
      EVAL {|oB|oB:dataArea:lbClick := {|a,b,o|IIF(oBrowse:colPos=1,(aDir[n,11]:=!aDir[n,11],oBrowse:refreshCurrent()),nil)}}


DCBROWSECOL ELEMENT 1 PARENT oBrowse HEADER 'Name' WIDTH 10 PROTECT {||.t.}
DCBROWSECOL ELEMENT 2 PARENT oBrowse HEADER 'Size' WIDTH 8
DCBROWSECOL ELEMENT 3 PARENT oBrowse HEADER 'Date' WIDTH 8
DCBROWSECOL ELEMENT 4 PARENT oBrowse HEADER 'Time' WIDTH 8

DCGETOPTIONS AUTORESIZE

DCREAD GUI FIT ADDBUTTONS MODAL ;
     OPTIONS GetOptions ;
     TITLE 'Click in CheckBox to Select/Unselect'
RETURN aDir

* ----------

PROC appsys ; return

It appears to work as far as changing the value in the array but it doesn't display the checkbox.
This code was from 2011. Is it done differently in Xbase 2.0?

Stephen Bryan

Re: Checkbox in Browse

Posted: Tue Nov 10, 2015 8:33 am
by rdonnay
You need to include express.res in your project file because it contains the bitmaps for the checkboxes.

Re: Checkbox in Browse

Posted: Tue Nov 10, 2015 9:21 am
by skiman
Hi,

Instead of a bitmap, I currently prefer to use a font as wingdings, webdings, ... You just need to know which character you want to use.

Code: Select all

dcbrowsecol DATA {|x|x:=DC_GetColArray(11,oBrowse), IIF(x,'1','2')} ... font '11.webdings'
You need to replace the value 1 and 2 with the character you want.

In my opnion this gives a more modern look.

Re: Checkbox in Browse

Posted: Tue Nov 10, 2015 9:49 am
by Sbryan
I knew it had to be something simple.

I'll try the webdings font too.

Thanks,

Stephen

Re: Checkbox in Browse

Posted: Wed Nov 11, 2015 2:16 am
by Tom
There was a XbpCheckBoxColumn or something like this in the XbPacks II or III. Anyone who tried this out?

Re: Checkbox in Browse

Posted: Wed Nov 11, 2015 9:08 am
by rdonnay
Instead of a bitmap, I currently prefer to use a font as wingdings, webdings, ... You just need to know which character you want to use.
This is a much better idea.
I will need to change the sample program.

Re: Checkbox in Browse

Posted: Wed Nov 11, 2015 11:21 am
by skiman
Hi,

I just checked it. You need to use Wingdings 2 font.

The capital letters O or P, if you want a box you can use Q or R.
checkbox.png
checkbox.png (1.03 KiB) Viewed 18856 times

Re: Checkbox in Browse

Posted: Mon Nov 16, 2015 3:58 am
by Sbryan
I ended up using the Wingding font method but noticed if I resize the window it changes the font and gives me a P instead of a check mark.

How can I prevent this?

Re: Checkbox in Browse

Posted: Tue Nov 17, 2015 8:58 am
by Sbryan
I noticed that when I resize using these getoptions is when it changes from a check mark to a "P"

Code: Select all

DCGETOPTIONS RESIZE RESIZEDEFAULT DCGUI_RESIZE_AUTORESIZE_SCALEFONT
  
I want it so if the window is re-sized, everything scales properly.

Re: Checkbox in Browse

Posted: Tue Nov 17, 2015 9:49 am
by rdonnay
I haven't tested this with SCALEFONT. I will look into this.