Jump to content

Qasim Shahzad

Members
  • Content Count

    8
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Qasim Shahzad

  • Birthday September 25

Technical Information

  • Delphi-Version
    Delphi 10.3 Rio
  1. That's good idea and we can get ModalResults with this method. Thanks for sharing.
  2. Exactly, My usage is also like this. For any other scenario (In/Out Values) this might not be good solution. But for simple creation, display and destroy usage it is neat and time saving.
  3. Yes these are valid concerns. But in my usage, these forms are like different parts of the application and mostly have no need to pass values or get result. Even if something is changed by a form like SettingsForm, It is persisted in file, DB or registry so next Form or Calling routine can/should load it from there. So in this scenario it is OK. But if it gets complex as you pointed out then we can create that form directly instead of calling a procedure. Nevertheless, your solution was a mental massage😊. This little problem/challenge was annoying me very much. Thank you so much. Stay Blessed.
  4. That's great. These are valid concerns. To me the real benefit was readability and clean code. But centralizing logging is another benefit. Procedure name suggestion is also very thoughtful. It should be ShowModalForm Thank you so much.
  5. Now Please guide why this is a bad idea. It reduces a lot of code duplication and we can add Form Creation procedure in a common library.
  6. unit uMain; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons, Unit1, Unit2, Unit3; type TfrmMain = class ( TForm ) BitBtn1: TBitBtn; BitBtn2: TBitBtn; BitBtn3: TBitBtn; procedure BitBtn1Click ( Sender: TObject ) ; procedure BitBtn2Click ( Sender: TObject ) ; procedure BitBtn3Click ( Sender: TObject ) ; private { Private declarations } public { Public declarations } end; var frmMain: TfrmMain; implementation {$R *.dfm} procedure ShowForm ( ThisForm: TFormClass ) ; var lForm: TForm; begin lForm := ThisForm.Create ( nil ) ; try lForm.ShowModal; finally lForm.Free; end; end; procedure TfrmMain.BitBtn1Click ( Sender: TObject ) ; begin ShowForm ( TForm1 ) ; end; procedure TfrmMain.BitBtn2Click ( Sender: TObject ) ; begin ShowForm ( TForm2 ) ; end; procedure TfrmMain.BitBtn3Click ( Sender: TObject ) ; begin ShowForm ( TForm3 ) ; end; end. Thank you so much. That was very clever. VCL version is working perfectly fine. I will check on FMX also.
  7. Qasim Shahzad

    Cannot write to GetLibraryPath (Android)

    This call was successful in previous Delphi versions? Have you tried any other device? docwiki.embarcadero says: So it might be related to device or application permissions.
  8. Greetings Dear Delphians, Say we have 20 Forms in an App. We use these 6 lines to create 20 Forms at different places. Form1 := TForm1.Create; try Form1.ShowModal; finally Form1.Free; end; When refactoring we can see this is a lot of code duplication and we should encapsulate form creation in a procedure like this. procedure ShowForm ( ThisForm: TCustomForm ) ; begin ThisForm := TCustomForm(ThisFormClass.Create);//?? How to Get Form Class try ThisForm.ShowModal; finally ThisForm.Free; end; end; I only have problem in first line. how to get ThisForm parent class to call it. Is it even possible? If yes then how? What about FMX? Any help or pointer is appreciated. Thanks and stay blessed
×