Solved

How to do Delphi 7 Frames.

Posted on 2010-08-28
9
3,374 Views
Last Modified: 2013-11-11
Hi,
I'm on a WinXP Pro, SP3 using Delphi 7.

I have a fundamental problem starting a new Frame project/program from scratch.

In the IDE, I do:
1.  File, New, Frame.  The unit and frame are displayed.  
2.  Drop  Button1 and  Edit1 on the form.
3.  Double click Button1 and add "Close;" between the "begin" and "end;"  .
4.  Save the code as Unti1.pas.
5. In the project directory, I have two files: Unit1.dfm and Unit1.pas.

Here is what I don't understand:

1.  Why can't I create a Project (dpr) file?   I can't do a File, Save Project As...  because it is grayed out.
2.  Why is the  green "|>" Run button grayed out?

I thought I could save a Frame as a Project and I obviously need to use the "Run" button to compile the code.

What am I fundamentally misunderstanding about Delphi Frames and Projects?


Thanks.
0
Comment
Question by:IT79637
  • 2
  • 2
  • 2
  • +2
9 Comments
 
LVL 14

Accepted Solution

by:
systan earned 144 total points
ID: 33551372
try that;
frametest1.zip
0
 
LVL 14

Assisted Solution

by:systan
systan earned 144 total points
ID: 33551383
>>4.  Save the code as Unti1.pas.
Wrong!
Save the code as Unit2.pas
Because Unit1 is Form1 and Unit1.pas

When you Save the frame, it will named as unit2.pas, because there is a unit1.pas already which is the form1

See the frametest code I attached
0
 
LVL 37

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 143 total points
ID: 33551754
you need to look at a frame as a jigsaw piece
the jigsaw would be the form

you can't save a frame as a project
but you can save a frame as a unit inside a project
a frame can be totally standalone
-> but you can't compile this, you need a project around this

there are a few issues with frames and inheritance
editing a frame after you put it on a form may cause some odd behaviour
mostly there is a problem with a mix of default and non-default property values

the best approach is to put a frame on the form at runtime to prevent this problem

to save frames, i would first create a new standard vcl application
and save them in that application
in my apps, i have a common folder for this
this is sample of my dir structure
development directory : c:\company\dev =dev
delpi structure
dev\general\report
dev\general\label
dev\common\utils
dev\common\frames
dev\test\projectFrames
dev\quickstep\tools\client
dev\quickstep\tools\server

now why this structure ?
well are you going to use frames in different projects ?
probably ...

* then the very first concern is to make sure you don't use units inside your frames of other forms
in my structure from the dir common\frames i can use any unit from common\utils, but not from the general or quickstep dirs
this is the first basic concept for sharing frames amongst projects

after creating a new project (inside dev\test\prjFrames)
add a new frame
and save it in the common\frames
i usually give my units a relevant name -> fraFileList
i would show a frame with a listbox to select a file from

then use this frame in 2 different units

you can add a frame to the component pallet - right click on the frame and click *add to palette*
then it's just like a component to put on your form
0
 
LVL 37

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 143 total points
ID: 33551852
this is a sample of that frame listing the files with a extension in a directory

and this is my test unit1 code:

always use a distinct name when adding frames to your form
unit uMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  TfrmMain = class(TForm)
    BitBtn1: TBitBtn;
    Panel1: TPanel;
    Memo1: TMemo;
    BitBtn2: TBitBtn;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmMain: TfrmMain;

implementation

uses frameFiles;

{$R *.dfm}

procedure TfrmMain.BitBtn1Click(Sender: TObject);
var fra: TfraFiles;
begin
  fra := TfraFiles(FindComponent('fraFilesTxt'));
  if fra <> nil then
    fra.Free;
  fra := TfraFiles.Create(Self);
  fra.Parent := panel1;
  fra.Align := alClient;
  fra.BeginUpdate;
  try
    fra.Folder := 'c:\data';
    fra.Ext := '.TXT';
  finally
    fra.EndUpdate;
  end;
  fra.Name := 'fraFilesTxt';
end;

procedure TfrmMain.BitBtn2Click(Sender: TObject);
var fra: TfraFiles;
begin
  fra := TfraFiles(FindComponent('fraFilesTxt'));
  if Assigned(fra) then
  begin
    fra.SelectedFiles(memo1.Lines);
  end;
end;

end.

Open in new window

frameFiles.pas
frameFiles.dfm
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 13

Assisted Solution

by:aflarin
aflarin earned 142 total points
ID: 33551941
>> 1.  Why can't I create a Project (dpr) file?   I can't do a File, Save Project As...  because it is grayed out.

To create an empty project use File, New, Application. It creates a new project and a new form

>> 2.  Why is the  green "|>" Run button grayed out?

Only projects can be run. You can't run Frames, Forms and other units if they are not included into  project

>> I thought I could save a Frame as a Project and I obviously need to use the "Run" button to compile the code.

You can create a new Project and a new Frame into this project. Then you can save the project (.dpr) and the frame (.pas and .dfm)

>> What am I fundamentally misunderstanding about Delphi Frames and Projects?

Im afraid you confuse Frames and Forms. Usually the simplest Delphi project consists of project unit (.dpr file) and main Form (.pas and .dfm files). You can create the simplest project via File, New, Application

The frames are not used as separate windows, they are used as part of forms.

So, I suppose you need to do :

1.  File, New, Application.  The unit and form are displayed.  
2.  Drop  Button1 and  Edit1 on the form.
3.  Double click Button1 and add "Close;" between the "begin" and "end;"  .
4.  File, Save All. Save the project as Project1, save the code as Unti1.pas.
5. In the project directory, you have three files: Project1.dpr, Unit1.dfm and Unit1.pas.
6. click Run

0
 
LVL 13

Assisted Solution

by:aflarin
aflarin earned 142 total points
ID: 33551969
If you want to create exactly the Frame, then:

1. File, New, Application.  The unit and form are displayed.  
2. File, New, Frame, The second unit and form are displayed. It's a Frame
3. Drop  Button1 and  Edit1 on the Frame form.
4. Double click Button1 and add "Close;" between the "begin" and "end;"  .
5. Switch to form (the first frame).
6. Drop Frames from the Standard palette to the Form. The frame select dialog will be displayed. Select the Frame1 and click OK
7.  File, Save All. Save the project as Project1, save the form as Unti1.pas and save the frame as Unit2
8. In the project directory, you have 5th files: Project1.dpr, Unit1.dfm and Unit1.pas, Unit2.dfm and Unit2.pas.
9. click Run
0
 
LVL 13

Assisted Solution

by:rfwoolf
rfwoolf earned 71 total points
ID: 33552700
In short... when you start Delphi from scratch and close the default new project, and then say New -> Frame, you are not creating a project, you are only creating a frame.
Perhaps what you're looking for is to say New Project, and THEN, say New Frame.
0
 
LVL 1

Author Comment

by:IT79637
ID: 33712105
Found out how to create a Frame Project in the help section under the Find tab.

See image below.

When you open the "Create frames" in step three, the following text can be found:

"If you want to create a project that contains only frames and no forms, choose File|New| Application, close the new form and unit without saving them, then choose File|New|Frame and save the project."
DelphiFrame2.jpg
0
 
LVL 1

Author Comment

by:IT79637
ID: 33712113
Found solution in Delphi help.  See above.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Welcome to my series of short tips on migrations. Whilst based on Microsoft migrations the same principles can be applied to any type of migration. My first tip Migration Tip #1 – Source Server Health can be found listed in my profile here: http:…
Issue: One Windows 2008 R2 64bit server on the network unable to connect to a buffalo Device (Linkstation) with firmware version 1.56. There are a total of four servers on the network this being one of them. Troubleshooting Steps: Connect via h…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

919 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now