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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi, Inter.
Sorry I don't know hyper66, but people do confuse me with hyper66.
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
Include REGISTRY in the Uses clause
then i.e: THIS will SAVE to the registry
procedure TForm1.BitBtn1Click(Sender
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',
WriteBinaryData('Option1',
WriteBinaryData('Option2',
CloseKey;
finally
free;
end;
ans THIS will READ from the registry
procedure TForm1.BitBtn2Click(Sender
Var r: TRegistry;
a: byte;
b: byte;
begin
a:= 0;
b:= 0;
r := TRegistry.Create;
with r do
try
CreateKey('NameOfMyProgram
OpenKey('NameOfMyProgram',
ReadBinaryData('Option1',a
ReadBinaryData('Option2',b
CloseKey;
finally
free;
if a= 1 then checkbox1.checked:= True;
if b= 1 then checkbox2.checked:= True;
end;
bryan
if you are hyper66 look at my answer to your previous questio...
igor