Can't resolve error message "Instance Variable (File1) Inaccessable Here" in Delphi TFrame1 application?

Hi,

I'm creating a TFrame form using  Delphi 7, SP4.

For the Menu1 control, I am getting "Instance Variable (zzzzz) Inaccessable Here" for all top level menu items  For example, all the code in the Code Section below fails with the error message above.

What have I done wrong?

In the Code Section is the Project file and the top part of the unit file where TFrame1 is declared.

Thanks.
 

===============  Procedure to open top level Menu1 items.
procedure mnuOpen;
begin
  with TFrame1 do    
  begin
    File1.Visible    := true;
    Edit1.Visible    := true;
    Image1.Visible   := true;
    Colors1.Visible  := true;
    Rotate1.Visible  := true;
    Page1.Visible    := true;
    View1.Visible    := true;
    Zoom1.Visible    := true;
    Magnify1.Visible := true;
  end;
end;
======================  Project File (dpr)
program ImageDisplayFrame1;
uses
  Forms,
  uF1ImageDisplay in 'uF1ImageDisplay.pas' {Frame1: TFrame};

{$R *.res}

begin
  Application.Initialize;
  Application.Run;
end.
========================= Beginning of unit below.
unit uF1ImageDisplay;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, RzTabs, RzPanel, RzButton, ExtCtrls, StdCtrls, AxCtrls,
  OleCtrls, ImvbLib_TLB, DB, mySQLDbTables, mySQLDirectQuery, ImgList,
  RzBHints, Menus, Mask, RzEdit, RzStatus, Grids, DBGrids, RzDBGrid,
  RzLabel;

type
  TFrame1 = class(TFrame)

Open in new window

LVL 1
IT79637Asked:
Who is Participating?
 
systanCommented:
Review or Open your *.dfm then check the name that is inaccessible, remove it or change it to your new name(in ?unit?.pas)
0
 
cyberkiwiCommented:
The procedure should be

procedure TFrame1.mnuOpen;

to make it a member of TFrame1 and so that it can access the fields in TFrame1

Then anywhere inside that procedure, press Ctrl-Shift-C to have Delphi IDE add it into the TFrame1 class for you.
Or you can just put this manually in the private or protected section of TFrame1

TFrame1 = class(TFrame)
   Edit1: TEdit;
protected
   procedure mnuOpen;
0
 
Emmanuel PASQUIERFreelance Project ManagerCommented:
in your mnuOpen procedure , you can't do : With TFrame1 <== The CLASS
The correct use is : With aFrame1 <== an INSTANCE

Where is declared this procedure ??? By what is it called ???
As cyberwiki said, it's rightful place is within TFrame1 (where I suppose all your menus objects are defined). But to decide if it has to be protected or public, we have to know by what is it used.
Is it not just an event of something in your frame ?
procedure TFrame1.mnuOpen;
begin
  File1.Visible    := true;
  Edit1.Visible    := true;
  Image1.Visible   := true;
  Colors1.Visible  := true;
  Rotate1.Visible  := true;
  Page1.Visible    := true;
  View1.Visible    := true;
  Zoom1.Visible    := true;
  Magnify1.Visible := true;
end;

Open in new window

0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Geert GOracle dbaCommented:
create your frame
save it
in the designer, right click and add to palette

then in your form designer you can add the newly created frame descendant
by click in the frame icon on the palette and then in your form

runtime creation of your frame inside a form:

procedure TForm1.ButtonAddFrame(Sender: TObject);
var aFrame: TFrame;
begin
  aFrame := TFrame.Create(Self);
  aFrame.Parent := Self;
end;
0
 
TheRealLokiSenior DeveloperCommented:
> in your mnuOpen procedure , you can't do : With TFrame1 <== The CLASS> The  correct use is : With aFrame1 <== an INSTANCE

epasquier is spot on, this is the main problem imho. (don't accept my answer for any points btw)
0
 
Emmanuel PASQUIERFreelance Project ManagerCommented:
Excellent closing. We can only assume at least one of us solves your issue.
0
 
TheRealLokiSenior DeveloperCommented:
lol, crazy. 100 points for saying "don't accept my answer"
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.