Jump to content
Sign in to follow this  
JamieR

Can I change the entry point for a VCL application?

Recommended Posts

Hey all. I've recently came to Delphi after 20 odd years using many other languages. I love it for creating desktop applications, which leads me to question ...

 

What design patterns are useful when building UI? I know DI, MVC and have the GoF book (not read it all, references appreciated). Once my application gets to a certain size it becomes really difficult to manage.

 

When I create a new VCL application the "main" entry point appears to be the main form (defaults to Form1). But I'd like to do something different by having the entry point as Appliction.pas, and have that file bootstrap the application with a service controller. I'd also like immutable state (like how React, or Redux work. I believe these are finite state machines?).

 

Is the above even possible? How do you develop VCL applications while decoupling the components of application?

Share this post


Link to post

If you want to build a VCL app then you need to fit into the framework. The main form is the first one created by a call to Application.CreateForm. Can be valle anything. Does not need to be Form1. You can create other forms before the main form if you want. 

 

The outer begin/end block in the dpr file is the effective entry point. 

 

You arent going to have immutability with VCL controls. If you want immutability, look elsewhere. 

 

Are you building a GUI app? 

  • Like 1

Share this post


Link to post

The entry point is the begin...end block in the dpr file. You can instantiate whatever you want from there. The default is to create the mainform (and whatever "autocreate" forms/modules you have configured) in there. The first form to be created with Application.CreateForm becomes the main form. If you don't want a main form then just don't use Application.CreateForm.

Oh, and btw, Application.Run is the message loop.

  • Like 1

Share this post


Link to post
45 minutes ago, JamieR said:

But I'd like to do something different by having the entry point as Appliction.pas

ctrl-v on the project name (xy.exe or .dll etc..) in the project manager at the upper right corner of the IDE. Just saying. Looks like it will open something new for you.

Edited by Attila Kovacs
  • Like 1

Share this post


Link to post

I'd not be surprised if Jamie didn't even know about the DPR file. How would you stumble across it, anyway? Right-clicking the project node and then finding "View Source" among two dozen other entries is not the most intuitive choice.

 

I wish I still remebered how I first found it...

  • Like 2

Share this post


Link to post

You can create applications of various types, each with its own characteristics:
- a Windows service, this is an application with no user interface that runs as a service;
- a console application, also an application without a graphical interface, runs on the command line.

All these have the access point in the .dpr file, but the path develops in a different way than in a graphic application (typically with a Form).

 

Bye

Share this post


Link to post
13 hours ago, Der schöne Günther said:

Right-clicking the project node and then finding "View Source" among two dozen other entries is not the most intuitive choice.

 

There is also Project -> View Source  in the main menu (at least until they reordered the menu, no idea whether it's still there).

Share this post


Link to post
21 hours ago, Der schöne Günther said:

I'd not be surprised if Jamie didn't even know about the DPR file. How would you stumble across it, anyway? Right-clicking the project node and then finding "View Source" among two dozen other entries is not the most intuitive choice.

 

I wish I still remebered how I first found it...

Exactly this. Just knowing this has solved a lot questions I had.

Share this post


Link to post

I feel like a bit of plum not knowing this ha ha. Thank you to all.

Share this post


Link to post

I read a book for beginners. There it was. I mean * .dpr. A search in the menu probably followed. D7

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×