Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to save and load the state of a TMenuItem to/ from a TIniFile Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
21-Feb-03
Category
VCL-Menu
Language
Delphi 2.x
Views
158
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

How to save and load the state of a TMenuItem to/ from a TIniFile

Answer:

1   uses
2     IniFiles;
3   
4   procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
5   var
6     ini: TIniFile;
7   begin
8     {Save the checked state of each menu item when the form closes}
9     Ini := TIniFile.Create('mysettings.ini');
10    Ini.WriteBool('Settings', 'MenuItem1Checked', MenuItem1.Checked);
11    Ini.WriteBool('Settings', 'MenuItem2Checked', MenuItem2.Checked);
12    Ini.WriteBool('Settings', 'MenuItem2Checked', MenuItem2.Checked);
13    Ini.Free;
14  end;
15  
16  procedure TForm1.FormShow(Sender: TObject);
17  var
18    ini: TIniFile;
19  begin
20    {Reload the checked state of each menu item when the form opens}
21    Ini := TIniFile.Create('mysettings.ini');
22    MenuItem1.Checked := Ini.ReadBool('Settings', 'MenuItem1Checked', False);
23    MenuItem2.Checked := Ini.ReadBool('Settings', 'MenuItem2Checked', False);
24    MenuItem3.Checked := Ini.ReadBool('Settings', 'MenuItem3Checked', False);
25    Ini.Free;
26  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC