Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FormCreate Load Saved Settings 1

Status
Not open for further replies.

BobbaFet

Programmer
Feb 25, 2001
903
NL
One of my friends said it would be usefull to be able to
save the settings of my program (and I agree, it would be
usefull). Now I want want to accomplish this by using
Inifiles. I have looked it up in the helpfile but it was
all confusing to me. I just dont understand how it works ...

Can someone please help me out???

Thanx allot,

Bobba_Fet Everybody has a right to my opinion.
 
What settings are you looking to save ?
I've used INI files successfully in a Delphi 5 application in order to save a series of printer margin settings for Crystal reports printing.
Let me know what you're trying to achieve and I'll send you some code examples ....
Regards,
Steve
 
Thanks for your response Steve,

I was looking to save save some string (for TEdit.Text)
and boolean (for TCheckbox.State) values.

Bobba_Fet Everybody has a right to my opinion.
 
hi,

You can use TIniFile for your need, For ex.,
You can store all users option in IniFile and retrive for current user's options.

To Create IniFile...
UserFile := tIniFile.Create('userdefs.ini'); {userdefs.ini File is in Current Dir.}

To Write in IniFile (String)
// to store Current User Seleted Font's name
UserFile.WriteString(CurUser, 'FontName', PassValue);

To Write in IniFile (Boolean)
// to store Current User Seleted Option For Confirmation Msg
// Needed Before delete/Edit..
UserFile.WriteBool(CurUser, 'ConfirmNeeded', PassBool);

To Read in IniFile (String)
// to retrive Current User Seleted Font's name
CurFontName := UserFile.ReadString(CurUser, 'FontName',
'Default Value');

To Read in IniFile (Boolean)
// to retrive Current User Seleted Option For Confirmation
// Msg Needed Before delete/Edit..
Result := UserFile.ReadBool(CurUser, 'ConfirmNeeded',
PassBool);
// PassBool is Default Value

For Freeing the IniFile.
UserFile.free;

You can try this,

Regards
Pradeep.
Delphidhasan
 
I have used your explination and it works just great!!!
But when I use this code in the FormCreate event I get the
EInvalidOperation error. It says that it "Cannot focus a
disabled or invisible window", but I got around that by
using the FormShow event !!!

Thanx allot you guys !!!

Happy me ;-) Everybody has a right to my opinion.
E-mail me at cwcon@programmer.net
 
hi,
"Cannot focus a disabled or invisible window" Error will come, if you are trying to setfocus on particular control which is not enabled/visible. In your case i think you are trying to setting focus before creating the the controls.

Regards
Pradeep Delphidhasan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top