Link to home
Start Free TrialLog in
Avatar of Peter Kiers
Peter KiersFlag for Netherlands

asked on

Help needed with procedure

Hello,

I have a main form called MainForm and a dialogform called frmSettings
that can be accessed by menu-item Settings. On the settings-form I have
3 checkboxes called chkRemoveBtn, chkSmallBtn and chkFlat.
All the states of these checkboxes are being loaded and saved to ini-file.
I have put the 3 procedure that belong to these checkboxes to the code-
section. For checkbox chkRemoveBtn and chkSmallBtn I have code in the
OnCreate-event of the mainform that looks in the ini-file if these checkboxes
are check or not. Now I am working on checkbox chkFlat, that looks like this:

  If FIniFile.ReadBool ('ENV', 'Flat', False) then
  OutlookBar.BorderStyle := cBorderStyle[chkFlat.Checked];

I get undeclared identifier: chkFlat. That because its on the form frmSettings
What can I do about this.

Who knows the solution.

Greetings,

Peter Kiers
procedure TfrmSettings.chkRemoveBtnClick(Sender: TObject);
begin
  if chkRemoveBtn.Checked then
  begin
    MainForm.OutlookBar.LargeImages := nil;
    MainForm.OutlookBar.SmallImages := nil;
  end
  else
  begin
    MainForm.OutlookBar.LargeImages := MainForm.mglstLarge;
    MainForm.OutlookBar.SmallImages := MainForm.mglstSmall;
  end;
end;
(*---------------------------------------------------*)
procedure TMainForm.acSmallButtonsExecute(Sender: TObject);
const
  cButtonSize: array[boolean] of TJvBarButtonSize = (olbsLarge,olbsSmall);
begin
  acSmallButtons.Checked := not acSmallButtons.Checked;
  OutlookBar.ButtonSize := cButtonSize[acSmallButtons.Checked];
end;
(*---------------------------------------------------*)
procedure TfrmSettings.chkFlatClick(Sender: TObject);
const
  cBorderStyle:array [boolean] of TBorderStyle = (bsSingle, bsNone);
begin
  MainForm.OutlookBar.BorderStyle := cBorderStyle[chkFlat.Checked];
end;
(*---------------------------------------------------*)
procedure TMainForm.FormCreate(Sender: TObject);
const
  cButtonSize: array[boolean] of TJvBarButtonSize = (olbsLarge,olbsSmall);
  cBorderStyle:array [boolean] of TBorderStyle = (bsSingle, bsNone);
var
   DataPath: string;
   conn_str:string;
   FIniFile: TIniFile;
begin
  PgCtrlMain.ActivePage := tbshGlucose;
  PgCtrlAg.ActivePage := tbshDayView;
  FIniFile:= TIniFile.Create( ChangeFileExt(Application.ExeName, '.ini') );
  if FIniFile.ReadBool ('ENV', 'RemoveButtons', False) then
  begin
    OutlookBar.LargeImages := nil;
    OutlookBar.SmallImages := nil;
  end
  else
  begin
    OutlookBar.LargeImages := mglstLarge;
    OutlookBar.SmallImages := mglstSmall;
  end;
  If FIniFile.ReadBool ('ENV', 'SmallButtons', False) then
  OutlookBar.ButtonSize := cButtonSize[acSmallButtons.Checked];

  If FIniFile.ReadBool ('ENV', 'Flat', False) then
  OutlookBar.BorderStyle := cBorderStyle[chkFlat.Checked];

  FIniFile.Free;
......

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of aflarin
aflarin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Peter Kiers

ASKER

Thank you for this solution:

  FIniFile:= TIniFile.Create( ChangeFileExt(Application.ExeName, '.ini') );
  if FIniFile.ReadBool ('ENV', 'RemoveButtons', False) then
  begin
    OutlookBar.LargeImages := nil;
    OutlookBar.SmallImages := nil;
  end
  else
  begin
    OutlookBar.LargeImages := mglstLarge;
    OutlookBar.SmallImages := mglstSmall;
  end;
  bSmallButtons:= FIniFile.ReadBool ('ENV', 'SmallButtons', False);
  OutlookBar.ButtonSize := cButtonSize[bSmallButtons];
  bFlat:= FIniFile.ReadBool ('ENV', 'Flat', False);
  OutlookBar.BorderStyle := cBorderStyle[bFlat];
  FIniFile.Free;

it works great.

Greetings,

Peter Kiers
Avatar of aflarin
aflarin

You're welcome, Peter