Solved

Registry and Checkboxes Question

Posted on 1998-10-30
4
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi 2 91
Find and Replace Stream with 0s 8 88
Why is there a Difference between the SQL String and using the Parameter ? 7 61
Posting a string with PostMessage 23 49
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…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

751 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