Solved

Help needed with procedure

Posted on 2010-08-12
3
208 Views
Last Modified: 2012-05-10
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

0
Comment
Question by:peterkiers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
aflarin earned 500 total points
ID: 33426944
procedure TMainForm.FormCreate(Sender: TObject);
var
     ...
     bSmallButtons, bFlat: Boolean; // add these vars
...
   bSmaIlButtons:= FIniFile.ReadBool ('ENV', 'SmallButtons', False);
   OutlookBar.ButtonSize := cButtonSize[bSmallButtons];

    bFlat:= FIniFile.ReadBool ('ENV', 'Flat', False);
    OutlookBar.BorderStyle := cBorderStyle[bFlat];
......
0
 
LVL 1

Author Comment

by:peterkiers
ID: 33426974
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
0
 
LVL 13

Expert Comment

by:aflarin
ID: 33427016
You're welcome, Peter
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10 Round Image 2 218
Delphi inherited method 6 86
Not able to call Delphi XE10 dll function from Delphi 6.0 4 53
scroll down TListBox component in Delphi 1 41
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

742 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