Solved

Registry and Checkboxes Question

Posted on 1998-10-30
4
336 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
Comment Utility
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
Comment Utility
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
Comment Utility
Hi, Inter.
 Sorry I don't know hyper66, but people do confuse me with hyper66.

 
0
 
LVL 3

Expert Comment

by:bryan7
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now