Go Back   FileForums > Game Backup > PC Games > PC Games - CD/DVD Conversions > Conversion Tutorials
Register FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 27-08-2017, 16:07
lupetto77's Avatar
lupetto77 lupetto77 is offline
Registered User
 
Join Date: Nov 2008
Location: Italia
Posts: 87
Thanks: 1
Thanked 2 Times in 2 Posts
lupetto77 is on a distinguished road
Write on an ini file

Using Inno Setup Compiler I have added a screen with the various components, I should read the content that is inserted into a textbox and write it in an ini file.

Same thing with the combobox component.

I added the section
Code:
[Ini]
Filename: {app} \ fileProva.ini; Section: prova1; Key: nomeTextBox1
Filename: {app} \ fileProva.ini; Section: Prova2; Key: nomeTextBox2

Is that okay?

Or should I add something else?
Reply With Quote
Sponsored Links
  #2  
Old 28-08-2017, 12:50
JRD!'s Avatar
JRD! JRD! is offline
Registered User
 
Join Date: Sep 2015
Location: Matrix
Posts: 274
Thanks: 225
Thanked 600 Times in 168 Posts
JRD! is on a distinguished road
function GetIniBool(const Section, Key: String; const: Boolean; const Filename: String): Boolean;
function GetIniInt(const Section, Key: String; const Default, Min, Max: Longint; const Filename: String): Longint;
function GetIniString(const Section, Key, Default, Filename: String): String;
Code:
Example:

var
  sCaption: string;
  iLeft, iTop, iWidth, iHeight: integer;
  bChecked: boolean;

  sCaption:=GetIniString('chkb', 'Caption', 'Component 1', ExpandConstant('{src}') + '\YourFile.ini');
  iLeft:=GetIniInt('chkb', 'Left', '30', ExpandConstant('{src}') + '\YourFile.ini');
  iTop:=GetIniInt('chkb', 'Top', '50', ExpandConstant('{src}') + '\YourFile.ini');  
  iWidth:=GetIniInt('chkb', 'Width', '150', ExpandConstant('{src}') + '\YourFile.ini');
  iHeight:=GetIniInt('chkb', 'Height', '20', ExpandConstant('{src}') + '\YourFile.ini'); 
  bChecked=GetIniBool('chkb', 'Checked', 'true', ExpandConstant('{src}') + '\YourFile.ini');

  CheckBox1.Caption:=sCaption;
  CheckBox1.SetBounds(iLeft, iTop, iWidth, iHeight);
  CheckBox1.Checked:=bChecked;
__________________
Practice makes perfect.
Reply With Quote
The Following 2 Users Say Thank You to JRD! For This Useful Post:
EzzEldin16 (28-08-2017), Simorq (28-08-2017)
  #3  
Old 28-08-2017, 14:13
JRD!'s Avatar
JRD! JRD! is offline
Registered User
 
Join Date: Sep 2015
Location: Matrix
Posts: 274
Thanks: 225
Thanked 600 Times in 168 Posts
JRD! is on a distinguished road
function SetIniBool(const Section, Key: String; const Value: Boolean; const Filename: String): Boolean;
function SetIniInt(const Section, Key: String; const Value: Longint; const Filename: String): Boolean;
function SetIniString(const Section, Key, Value, Filename: String): Boolean;

Code:
[Setup]
AppName='Write to ini example';
AppVerName=0.0.0.0
CreateAppDir=false
OutputDir=".\"

[ Code ]
const
  INIFILE = 'config.ini';

procedure OnChange(Sender: TObject);
begin
  SetIniString(TControl(Sender).Name, 'Text', TEdit(Sender).Text, ExpandConstant('{src}\') + INIFILE);
end;

procedure OnClick(Sender: TObject);
begin
  SetIniBool(TControl(Sender).Name, 'State', (Sender as TCheckBox).Checked, ExpandConstant('{src}\') + INIFILE);
end;

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
  Confirm:=False
  Cancel:=True
end;

procedure InitializeWizard();
begin

  with WizardForm do
  begin
    BorderStyle := bsToolWindow;
    Position := poScreenCenter;
    AutoScroll := False;
    ClientWidth := ScaleX(300);
    ClientHeight := ScaleY(100);
    Caption:={#SetupSetting("AppName")};
    InnerNotebook.Hide;
    OuterNotebook.Hide;
  end;

  with TLabel.Create(WizardForm) do
  begin
    Parent := WizardForm;
    SetBounds(5, 8, 40, 15);
    Caption:='Edit1: ';
    Font.Size:=10;
  end;
  
  with TEdit.Create(WizardForm) do
  begin
    Parent := WizardForm;
    SetBounds(50, 5, WizardForm.ClientWidth - 60, 15);
    OnChange:=@OnChange;
    Name:='Edit1';
  end;

  with TLabel.Create(WizardForm) do
  begin
    Parent := WizardForm;
    SetBounds(5, 33, 40, 15);
    Caption:='Edit2: ';
    Font.Size:=10;
  end;

  with TEdit.Create(WizardForm) do
  begin
    Parent := WizardForm;
    SetBounds(50, 30, WizardForm.ClientWidth - 60, 15);
    OnChange:=@OnChange;
    Name:='Edit2';
  end;

  with TCheckBox.Create(WizardForm) do
  begin
    Parent := WizardForm;
    SetBounds(50, 70, 150, 15);
    OnClick:=@OnClick;
    Name:='CheckBox1';
    Checked:=GetIniBool(Name, 'State', false, ExpandConstant('{src}\') + INIFILE);
  end;

  with TCheckBox.Create(WizardForm) do
  begin
    Parent := WizardForm;
    SetBounds(150, 70, 150, 15);
    OnClick:=@OnClick;
    Name:='CheckBox2';
    Checked:=GetIniBool(Name, 'State', false, ExpandConstant('{src}\') + INIFILE);
  end;

end;
__________________
Practice makes perfect.
Reply With Quote
The Following 3 Users Say Thank You to JRD! For This Useful Post:
EzzEldin16 (28-08-2017), lupetto77 (31-08-2017), Simorq (29-08-2017)
  #4  
Old 31-08-2017, 16:19
lupetto77's Avatar
lupetto77 lupetto77 is offline
Registered User
 
Join Date: Nov 2008
Location: Italia
Posts: 87
Thanks: 1
Thanked 2 Times in 2 Posts
lupetto77 is on a distinguished road
Sorry for the response delay.

Thanks for the help, I will try to figure out how it works.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Anno 1701 won't load, just get a blue screen! Shadow22 General Gaming 5 28-08-2012 12:52
Having a nightmare with Iomega USB ZipCD - Help! Tranced CD/DVD-Writers 2 03-04-2005 06:00
PMA Update failure....????????? dannyk DVD Backup Forum 1 05-01-2005 14:19
Flat Out Protection t.foster73 PC Games 59 26-11-2004 01:39
HELP ME PLZ!!!! Dalvin DC Games 0 02-01-2001 22:14



All times are GMT -7. The time now is 14:34.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
FileForums @ https://fileforums.com