Page 1 of 1

checkbox

Posted: Thu May 19, 2016 10:45 pm
by c-tec
Hello,
I would like to get checkboxes in the middle of a line and not at the bottom. So I try to make my own :
#command @ <nGetRow> -.3 [,<nGetCol>] MYCHECKBOX [<uVar>] ...

but it does not work, invalid use of ... How can I get this working
regards
Rudolf

Re: checkbox

Posted: Fri May 20, 2016 1:20 am
by reganc
I have used something like the following on a DCCHECKBOX line:

EVAL {|o| o:setPos({o:CurrentPos()[1],o:CurrentPos()[2]+((nRowHgt-o:currentsize()[2])/2)}) } ;

It is an attempt to centre the checkbox within a row using the actual height of the checkbox.

I often use a separate DCSAY for the prompt as well so you have more control over how it looks.
These and comboboxes don't have a standard height. They can look real odd if you don't adjust them.

Re: checkbox

Posted: Fri May 20, 2016 5:50 am
by rdonnay
This may be what you are looking for:

Code: Select all

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

#command @ <row>, <col> MyCheckBox <lCheck> PROMPT <cPrompt> ;
   => ;
   MyCheckBox( <row>, <col>, @<lCheck>, <cPrompt>, GetList )


FUNCTION Main()

LOCAL GetList[0], lCheck1 := .f., lCheck2 := .t.

@ 0,0 MyCheckBox lCheck1 PROMPT 'This is checkbox #1'

@ 2,0 MyCheckBox lCheck2 PROMPT 'This is checkbox #2'

DCREAD GUI FIT ADDBUTTONS TITLE 'Custom Checkbox command'

RETURN nil

* ---------

PROC appsys ; RETURN

* ---------

FUNCTION MyCheckBox( nRow, nCol, lCheck, cPrompt, GetList )

LOCAL oCheck

@ nRow, nCol DCCHECKBOX lCheck PROMPT '' OBJECT oCheck

@ DCGUI_ROW, DCGUI_COL DCSAY cPrompt SAYSIZE 0 SAYBOTTOM ;
   EVAL {|o|o:lbUp := {|a,b,o|oCheck:setData(!oCheck:getData())}}

RETURN nil



Re: checkbox

Posted: Fri May 20, 2016 7:43 am
by c-tec
Hello Roger,
thank you, exactly what I need
regards
Rudolf