JamieR 3 Posted November 30, 2021 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
David Heffernan 2345 Posted November 30, 2021 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? 1 Share this post Link to post
Anders Melander 1784 Posted November 30, 2021 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. 1 Share this post Link to post
Attila Kovacs 629 Posted November 30, 2021 (edited) 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 November 30, 2021 by Attila Kovacs 1 Share this post Link to post
Der schöne Günther 316 Posted November 30, 2021 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... 2 Share this post Link to post
Attila Kovacs 629 Posted November 30, 2021 8 minutes ago, Der schöne Günther said: is not the most intuitive choice It's part of the know-how. 😉 Share this post Link to post
DelphiUdIT 176 Posted November 30, 2021 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
Fr0sT.Brutal 900 Posted December 1, 2021 11 hours ago, Der schöne Günther said: I wish I still remebered how I first found it... F7 1 Share this post Link to post
Der schöne Günther 316 Posted December 1, 2021 That might actually be possible. Accidently pressing F7 and then like "Uh, where am I?" Share this post Link to post
dummzeuch 1505 Posted December 1, 2021 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
JamieR 3 Posted December 1, 2021 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
JamieR 3 Posted December 1, 2021 I feel like a bit of plum not knowing this ha ha. Thank you to all. Share this post Link to post
Stano 143 Posted December 1, 2021 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