-1

I've downloaded a Delphi project on internet and I'd like to use it, but there's a problem: the downloaded package contains a file with dpr extension, but if I double click to it, in the opened Delphi I can see a source code, but the Design is missing, so, I can't modify for example the windows properties. Into a Delphi project there's at least two tabs: let's name them Unit1 and Project1, but here's only on tab, with the source code. Also, into a classicaly created project the source code apperas into a pas file, but here it is into the dpr file. I tried to find a way to import its content, but found nothing. So, if somebody can tell how to convert this dpr file into a Delphi project with calssical structure, please let me know. Thanks a lot.

2 Answers2

4

I've downloaded this project. It is not VCL project, it is WinAPI-based program using OpenGL.

Some links to help with non-VCL Delphi coding:

Creating forms without using vcl

A guide to developing Delphi programs in Windows API

Delphi Without the VCL or the IDE

And here - example of VCL application with OpenGL

Community
  • 1
  • 1
MBo
  • 77,366
  • 5
  • 53
  • 86
  • Ok, thank you, I will try to read and understand these articles, then maybe I'll come back. Thanks again. – Laszlo Balazs Jul 22 '14 at 19:38
  • That's exactly what I suspected the first time I read this question, is that OP was not familiar with Delphi projects which did not involve VCL forms. I think every beginner goes through this stage, but it's still something every coder should learn and understand. – Jerry Dodge Jul 22 '14 at 23:47
  • Ok, but it's still not clear to me: can be converted a WinAPI-based program into a VCL one? – Laszlo Balazs Jul 23 '14 at 14:41
  • Last link is about using OpenGL in VCL program. I assume you can use OpenGL-based drawing principles from linked project in your VCL program – MBo Jul 23 '14 at 15:03
  • Well, in fact I had nothing to do with it before. I found this code on the internet and tried to figure out how it's realised, but couldn't, so that's why I asked my first question. – Laszlo Balazs Jul 23 '14 at 15:44
2

A .dpr file is a Delphi project file. For a normal VCL or FMX application, it's used by the IDE to list the forms that are in the project, and to contain the code that initializes the Application class, creates the main form, and starts the program's execution by calling Application.Run. For instance, here's the shell of an application created using File->New->VCL Forms Application from the IDE main menu:

program Project1;

uses
  Vcl.Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

The above tells the IDE that it needs to include the VCL.Forms unit as well as the unit Unit1 (which contains Form1). It initializes the Application, creates an instance of TForm1 in the variable Form1 which becomes the Application.MainForm, and then starts the program running. When Application.Run is exited (which usually happens when Form1 is closed), the application exits.

However, an application doesn't necessarily have to contain a forms, and a .dpr can contain all of the source code for an application. Here's an example of a Delphi console application that is a fully contained program in a single .dpr file - you can create the shell by using File->New->Other from the IDE main menu, and choosing Console Application under the Delphi Projects category. I've added three lines of code (the two calls to WriteLn and one to ReadLn) so that it does something. You can save the file as Project1.dpr, open it in any Delphi IDE, and press F9 to run it to see how it works.

program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils;

begin
  WriteLn('This is a Delphi console application.');
  WriteLn('Press Enter to quit.');
  ReadLn;
end.

Another type of Delphi project that doesn't have a form associated with it is a Windows service (File->New->Other->Delphi Projects->Service Application).

So you can't make the presumption that a .dpr file will have anything to do with a form. You can tell by examining the contents whether it does or not, but not simply by the extension.

Ken White
  • 123,280
  • 14
  • 225
  • 444