Solved

Registry and Checkboxes Question

Posted on 1998-10-30
4
339 Views
Last Modified: 2010-04-06
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.
0
Comment
Question by:hyperion66
4 Comments
 
LVL 5

Expert Comment

by:inter
ID: 1345031
Hi,
if you are hyper66 look at my answer to your previous questio...
igor
0
 
LVL 2

Accepted Solution

by:
Thaddy earned 100 total points
ID: 1345032
procedure TForm1.FormCreate(Sender: TObject);
begin
  with TreginiFile.create('Checkboxes') do
  try
    Checkbox1.Checked:=ReadBool('Checkboxes','CheckBox1',false);
    Checkbox2.Checked:=ReadBool('Checkboxes','CheckBox2',false);
  finally
     free;
  end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  with TreginiFile.create('Checkboxes') do
  try
    WriteBool('Checkboxes','CheckBox1',Checkbox1.checked);
    WriteBool('Checkboxes','CheckBox2',Checkbox2.checked);
  finally
     free;
  end;

end;

0
 

Author Comment

by:hyperion66
ID: 1345033
Hi, Inter.
 Sorry I don't know hyper66, but people do confuse me with hyper66.

 
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1345034
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

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question