Link to home
Start Free TrialLog in
Avatar of hyperion66
hyperion66

asked on

Registry and Checkboxes Question

Hello
  I would like to have a options to hold settings to my programs, I have 10 checkboxs on a form somthing like Internet Explorer 4.0 internet options menu in advanced.

For Example:

Checkbox1 is for Toolbars Visible or Not Visible.
Checkbox2 is for Statusbar Visible or Not Visible.
Etc..

How can I save Checkboxs settings so when my program loads the checkboxs that i checked before are checked or vise versa when I load this form again.
Avatar of inter
inter
Flag of Türkiye image

Hi,
if you are hyper66 look at my answer to your previous questio...
igor
ASKER CERTIFIED SOLUTION
Avatar of Thaddy
Thaddy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hyperion66
hyperion66

ASKER

Hi, Inter.
 Sorry I don't know hyper66, but people do confuse me with hyper66.

 
try this:

Include     REGISTRY     in the Uses clause

then i.e:   THIS will SAVE to the registry

procedure TForm1.BitBtn1Click(Sender: TObject);
Var r: TRegistry;
      a: byte;
      b: byte;
begin
a:= 0;
b:= 0;
if checkbox1.checked= True then a:= 1;
if checkbox2.checked= True then b:= 1;
r := TRegistry.Create;
        with r do
        try
           CreateKey('NameOfMyProgram');
           OpenKey('NameOfMyProgram', False);
           WriteBinaryData('Option1',a,1);
           WriteBinaryData('Option2',b,1);
           CloseKey;
        finally
           free;
        end;

ans   THIS will READ from the registry

procedure TForm1.BitBtn2Click(Sender: TObject);
Var r: TRegistry;
      a: byte;
      b: byte;
begin
a:= 0;
b:= 0;
r := TRegistry.Create;
        with r do
        try
           CreateKey('NameOfMyProgram');
           OpenKey('NameOfMyProgram', False);
           ReadBinaryData('Option1',a,1);
           ReadBinaryData('Option2',b,1);
           CloseKey;
        finally
           free;
if a= 1 then checkbox1.checked:= True;
if b= 1 then checkbox2.checked:= True;
        end;


bryan