Solved

Preferances

Posted on 2004-04-27
7
435 Views
Last Modified: 2010-04-05
I must provide a means for the User to choose their preferred font, and their preferred font colour. This preferance should be saved to disk in a file called ExtrasPreferances.ini in the root directory of my drive u: drive. When the application loads it should read the users saved preferances and apply them to all of the forms the application subsequently opens. Also since this functionality is likely to be extended in the future you should encapusulate all of this functionality in a class of your own devising which is accesses only from the main form.
0
Comment
Question by:James_Napier
  • 3
  • 2
  • 2
7 Comments
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10928628

   uses
      ..., IniFiles;

   ClassClientOptions = class
   private
     Form1Color : TColor;
   public
     procedure LoadFromFile(FileName : String);
     procedure SaveToFile (FileName : String);
   end;


   // example pof procedure LoadFromFile
   procedure ClassClientOptions.LoadFromFile(FileName : String);
   var
      IniFile : TIniFile;
   begin
      IniFile := TIniFile.Create(FileName);
      with IniFile do
         begin
            Form1Color := IniFile.ReadInteger('Settings', 'FormColor', clBlue);
            // etc ... your code below
         end;
   end;

   use LoadFromFile in OnCreate and SaveFromFile in OnClose of the form

   define variabe with class ClassClientOptions only once and use it as global variable.
0
 

Author Comment

by:James_Napier
ID: 10928673
If i want to save each specific user how would i go about this.
0
 
LVL 19

Expert Comment

by:Melih SARICA
ID: 10928680
Make  Gloabal Variable

like
  Selected_font : String;
  Selected Color : string ;


On form Creation
   with tinifile.create('u:\ExtrasPreferances.in') do
   begin
     Selected_font := readString('Prefered','fontname','');
     Selected Color:= readString('Prefered','fontColor','');
     free;
  end;


And u ll use all these to variables in all ur Forms...




 
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 19

Accepted Solution

by:
Melih SARICA earned 500 total points
ID: 10928694
save them in their local hdd..

or

create a ini file part for each username
and create values for all preferences u want
0
 

Author Comment

by:James_Napier
ID: 10928743
Thanks thats a great help.
0
 
LVL 19

Expert Comment

by:Melih SARICA
ID: 10928749
I think ... i musnt get the all point from this question ..
Ivanov's answer is worth to share .. I ll be pleased to share it with Ivanov..

cuz he points another opinion about this kinda  works..

Creating a  class.. and using it.. saving and loading preferences as a standart part of ur application..

0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10928802

   non_zero, you are friend ... :)))

   it is author decision who and how much points to give. don't bother with this. it is ok :)))
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi selector screen 2 80
oracle global variables 4 70
Open a URL with Internet Explorer in a new tab (not a new window) 1 99
Graphics32 under Delphi 10.1 Berlin 2 69
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…

832 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