Solved

Registry and Checkboxes Question

Posted on 1998-10-30
4
340 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

756 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