Checkbox in Browse

This forum is for eXpress++ general support.
Message
Author
Sbryan
Posts: 31
Joined: Sun Oct 18, 2015 7:15 am

Checkbox in Browse

#1 Post 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
Attachments
checkbox.jpg
checkbox.jpg (47.25 KiB) Viewed 18895 times

User avatar
rdonnay
Site Admin
Posts: 4745
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Checkbox in Browse

#2 Post by rdonnay »

You need to include express.res in your project file because it contains the bitmaps for the checkboxes.
The eXpress train is coming - and it has more cars.

skiman
Posts: 1194
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Checkbox in Browse

#3 Post 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.
Best regards,

Chris.
www.aboservice.be

Sbryan
Posts: 31
Joined: Sun Oct 18, 2015 7:15 am

Re: Checkbox in Browse

#4 Post by Sbryan »

I knew it had to be something simple.

I'll try the webdings font too.

Thanks,

Stephen

User avatar
Tom
Posts: 1185
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Checkbox in Browse

#5 Post by Tom »

There was a XbpCheckBoxColumn or something like this in the XbPacks II or III. Anyone who tried this out?
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
rdonnay
Site Admin
Posts: 4745
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Checkbox in Browse

#6 Post 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.
The eXpress train is coming - and it has more cars.

skiman
Posts: 1194
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Checkbox in Browse

#7 Post 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 18846 times
Best regards,

Chris.
www.aboservice.be

Sbryan
Posts: 31
Joined: Sun Oct 18, 2015 7:15 am

Re: Checkbox in Browse

#8 Post 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?

Sbryan
Posts: 31
Joined: Sun Oct 18, 2015 7:15 am

Re: Checkbox in Browse

#9 Post 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.

User avatar
rdonnay
Site Admin
Posts: 4745
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Checkbox in Browse

#10 Post by rdonnay »

I haven't tested this with SCALEFONT. I will look into this.
The eXpress train is coming - and it has more cars.

Post Reply