CheckBox problem

General discussion on Visual TFT Software.
Post Reply
Author
Message
JohnGB
Posts: 183
Joined: 17 Feb 2013 18:59

CheckBox problem

#1 Post by JohnGB » 18 Aug 2013 19:09

How can I change the Checked State of the checkbox from Code?

chkRecalEnabled.Checked := True;
DrawCheckBox(@chkRecalEnabled);

The above code does not change the unchecked checkbox to checked.
JohnB
MikroPascal for PIC18 and DsPIC, Visual TFT

OT
Posts: 581
Joined: 19 May 2005 05:08
Location: Fairbanks, Alaska

Re: CheckBox problem

#2 Post by OT » 19 Aug 2013 01:45

The checked value is not true (all bits =1), but 1 (only lowest bit 1), this applies to all flags used in VTFT. Personally, I try to avoid use of the True/False assignments in my mpsdPIC code; historically the true value has changed with different versions of the compiler. Using and testing for 0 and 1 is much safer - that is when one does not forget about it and use the boolean as in other pascal compilers, which I see myself doing from time to time...

Code: Select all

  chkRecalEnabled.Checked := 1;
  DrawCheckBox(@chkRecalEnabled);
mikropascal dsPIC, Visual TFT, MMBdsPIC v.105, 1.10_9A, mikroProg, "Big"(P30F6012A)EasydsPIC2

JohnGB
Posts: 183
Joined: 17 Feb 2013 18:59

Re: CheckBox problem

#3 Post by JohnGB » 19 Aug 2013 09:47

Thanks for tip.
That also explains why

Code: Select all

chkRecalEnabled.Checked := (SerialFlash_ReadByte(0) = $FF);
didn't work.
JohnB
MikroPascal for PIC18 and DsPIC, Visual TFT

Megahurts
Posts: 900
Joined: 01 Oct 2009 22:48
Location: Rocky Mountains, USA.

Re: CheckBox problem

#4 Post by Megahurts » 20 Aug 2013 18:30

Hi guys,

Here is a trick I use in every project now to avoid this problem:

In the user code area for declarations, I assign my own constants for using in places where the code sets or checks a objects property like so-
(Basic version code)

Code: Select all

const bTRUE  as byte = 1
const bFALSE as byte = 0
This is for easier reading of the code somewhere down the line as it still looks like conventional usage of the keywords.

Hope this helps, Robert.
HW: easyPIC5|PICFlash2|easyBT|smartGSM|easyGSM|PICPLC16|mmWorkStation|FT800 Eve|PIC Clicker/2|
MMBs:PIC18F,PIC33EP,PIC32|CLICKs:DAC,ADC,GPS L10,Thermo,8x8B LED,Stepper,W/B OLED,9DOF,GPS3,tRF,Hall I|

SW: mP for PIC|mB for PIC-dsPIC-PIC32|Visual-TFT|

JohnGB
Posts: 183
Joined: 17 Feb 2013 18:59

Re: CheckBox problem

#5 Post by JohnGB » 20 Aug 2013 18:58

Yes, I agree, it does make reading the code easier, however, you still need to remember when you should use the bTrue/bFalse in place of the True/False. I just hadn't spotted that the logical states in the V-TFT controls use a bit not a full byte, why I don't know because when you set the e.g the active state in VTFT is says true or false. Another inconsistency!
JohnB
MikroPascal for PIC18 and DsPIC, Visual TFT

User avatar
marko.ziv
mikroElektronika team
Posts: 530
Joined: 06 Dec 2007 10:11
Contact:

Re: CheckBox problem

#6 Post by marko.ziv » 21 Aug 2013 08:56

Hello,

changing the way how Visual TFT generates property values from 0/1 to False/True would break the backward compatibility.
However, we can change what is accepted as True value (since 0 and False are already the same thing). To be precise, zero would be False and anything greater then zero would be acknowledged as True.
This way we will keep backward compatibility and users could write both 0/1 and True/False values to object properties (irrelevant of the architecture in question)

Best Regards

JohnGB
Posts: 183
Joined: 17 Feb 2013 18:59

Re: CheckBox problem

#7 Post by JohnGB » 21 Aug 2013 11:18

That would certainly be an improvement but does it address the following...

If VTHTControl.Active = True then ...
or
BooleanVar := VTHTControl.Active;

I guess if you are changing the compiler to accept both 1/0 and True and false as being equal then that would do it, but changing only what VTFT on it's own doesn't resolve the issue.
JohnB
MikroPascal for PIC18 and DsPIC, Visual TFT

PIC007
Posts: 179
Joined: 28 Aug 2013 18:28

Re: CheckBox problem

#8 Post by PIC007 » 28 Aug 2014 19:05

I too can not get the vTFT checkbox object working properly. This does not toggle the tick sign. I would expect the approach below to be independent of bit or byte Boolean?

void S2_ChkBox_TPOnClick()
{
S2_ChkBox_TP.Checked = !S2_ChkBox_TP.Checked;
DrawCheckBox(&S2_ChkBox_TP);
// if(S2_ChkBox_TP.Checked)
// TP_Calibrate();
}

JohnGB
Posts: 183
Joined: 17 Feb 2013 18:59

Re: CheckBox problem

#9 Post by JohnGB » 29 Aug 2014 09:17

This is an old issues and one which has been raised with mE previously.
There are many inconsistencies both within VTFT and between VTFT and the compilers.
e.g. colour values and color names.
JohnB
MikroPascal for PIC18 and DsPIC, Visual TFT

Post Reply

Return to “Visual TFT General”