gettingstarted
[Top] [All Lists]

Re: Check boxes

To: Getting Started <gettingstarted at lists dot realsoftware dot com>
Subject: Re: Check boxes
From: Nils Frisch <n dot f dot forumbox at wanadoo dot fr>
Date: Fri, 29 Oct 2004 14:05:28 +0200
Delivered-to: gettingstarted at lists dot realsoftware dot com
France,
Toulouse,
Friday, October, 29th, 2004,
2:02 pm.


Hi Kim,


You must keep in mind that a checkbox control has a default value at the
beginning of its life.
This default value can be set via the properties floating window:

    - Select your "CheckBox" control, probably located in a window.
Four handles appears in the corners of your "CheckBox" control, and the
content of the properties floating window changes according to the type of
control you selected, i.e. a "CheckBox" control.

    - In this properties floating window, check the "Value" checkbox control
property in the "Initial State" properties group.

    - Run your application.
Your "CheckBox" control is checked.

If you quit and launch your application again, your "CheckBox" control still
checked.

So, you learn the existence of initial value.

Now, if you wish a more intelligent "CheckBox" control, that is to say a
control that record its last state, you must use a file. The file will be
read by you "CheckBox" control when your application launches (or when your
control starts to live), and will be written by your "CheckBox" control when
your application quits (or when your control ends to live).

Hence, you must write some code (no code, no intelligence).
But where ?

    - Double-click on your "CheckBox" control.
The code editor window opens. The "Action" event handler is selected by
default in the browser on the left.

    - Select the "Open" event handler of your "CheckBox" control.

    - Write the code that will read the content of your file and then set
the value of your "CheckBox" control.

Note:
- To set the value of "CheckBox" control: "Me.Value = True", or: "Me.Value =
False".
- About file management (open, write, file path, etc.), see the "FolderItem"
class.

    - In the browser of the code editor window, select the "Close" event
handler of your "CheckBox" control.

    - Write the code that will write the state of your "CheckBox" control.

When an application launches, almost every "Open" event handlers are fired.
When a window is created, every "Open" event handlers are fired: the "Open"
event handler of the window and the "Open" event handler of every items
hosted by this window.
Hence, when your window which hosts your "CheckBox" control is created (and
displayed), the "Open" event handler of your "CheckBox" is fired. That is to
say, the control reads your file and the set its state according to the
content of the file.
It's the same story for "Close" event handlers.

Note:
Usually, file doesn't store data such as "True" and "False".
The trick is to save, for example, an integer value: "1" for "True", and "0"
for "False".
Then the code will be:

    ...
    If (TheValueRetunedByTheFile = 1) Then
        Me.Value = True
    Else
        Me.Value = False
    End If
    ...

I hope that will help you.


Have a good day, Kim,
Yours,


Nils

----
----

Le 29/10/04 7:52, « Kim Kohen » <kim at webguide dot com dot au> a écrit :

> Hi all,
> 
> I have an issue with check boxes where I'm sure I'm missing something
> really, really simple.
> 
> How do I get a check box to remain checked when I quit an application?
> Every time I quit and restart the application the check box restores the
> 'initial state' value of false - even though the box was checked when the
> app was running. Could someone please put me out of my checkbox misery?
> 
> Cheers and thanks
> 
> Kim

----
----

"On ne voit bien qu'avec le coeur. L'essentiel est invisible pour les yeux."
"We only see well with our hearts. What is truly important is invisible to
our eyes."

Le Petit Prince, Antoine de Saint Exupéry

----
----

"Ce n'est pas l'homme qui doit s'adapter à la machine mais la machine qui
doit répondre aux besoins de l'homme."
"It is not the man who should adapt himself to the machine but the machine
which should meet the needs of the man."

Nils Frisch

----
----

Nils Frisch

Toulouse,
France. 

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>