-
Content Count
14 -
Joined
-
Last visited
Everything posted by Qasim Shahzad
-
I plan to create some introductory videos for my DelphiTube channel on this topic: Delphi for C-Sharpers The question is, why should a C-Sharper (C# user) learn Delphi? I am definitely biased toward Delphi, but is it really beneficial for a C-Sharp user? My thoughts are: Learning another language is a good option. Delphi can create standalone executable that do not need third-party frameworks. You can build cross-platform native applications with Delphi. It would be an easy move if you joined through the C++ Builder path. Delphi is highly productive. What's your point of view? Can you add some reasons? Please guide. Thank you so much for your attention and participation.
- 14 replies
-
Respected @David Heffernan. Thanks for your explanation. You are right. I think this is one of the main reasons Delphi does not natively support Right-To-Left Languages on Android because it is not using native components. What is your view about FPC and its nativeness?
- 14 replies
-
Thanks @programmerdelphi2k Yes some more great reasons. What BUGs
- 14 replies
-
Thanks @programmerdelphi2k Those are valid points, and I totally agree with you here. But then someone might say, why not learn Python or something else instead of Delphi? As you said, the market will dictate its rules. I believe there are productivity and life-cycle maintenance benefits to using Delphi. But how can we logically convey these benefits to others? For example, we can say that Delphi can target many processors. Moreover, we can port our Delphi code to Free Pascal Compiler, and it can target many processor architectures. Like: Intel x86 (16 and 32 bit) AMD64/x86-64 PowerPC PowerPC64 SPARC SPARC64 ARM AArch64 MIPS Motorola 68k AVR JVM
- 14 replies
-
Is asked ChatGPT: What is Internet Component Suite for Delphi?
Qasim Shahzad replied to FPiette's topic in ICS - Internet Component Suite
@dummzeuch Well, there are many wrong answers, but it will surely improve. The first time I used a pseudo-AI bot ELIZA, it was mind-blowing to my younger self at that time. Of course, Knight rider and many other sci-fi movies were also fascinating. Now we reached a point where things are going in that direction. Still, we might be a decade or two away from a full-blown system, but things are racing now. -
Is asked ChatGPT: What is Internet Component Suite for Delphi?
Qasim Shahzad replied to FPiette's topic in ICS - Internet Component Suite
It is strange how much ChatGPT "Knows" about Delphi and Pascal. Q. How to use ICS to fetch a webpage === === === === === === === === === Ans: To use ICS (Internet Component Suite) to fetch a webpage in Delphi, you can follow these steps: Make sure that you have ICS installed on your system. If you are using the Embarcadero RAD Studio platform, ICS should already be included. In your Delphi project, add a reference to the ICS library by going to Project > Add to Project > Import a Type Library. In the Delphi unit where you want to fetch the webpage, add the following line at the top of the file to import the ICS components: uses Ics.HttpProt; Create an instance of the THttpCli component and set its URL property to the address of the webpage you want to fetch. For example: Copy code HttpCli.URL := 'https://www.example.com'; Set the HttpCli.RcvdStream property to a TMemoryStream object, which will be used to store the data from the webpage. Call the HttpCli.GetAsync method to initiate the request to fetch the webpage. This method is asynchronous, which means that it will return immediately and the webpage data will be received in the background. To receive the data from the webpage, you will need to handle the HttpCli.DocData event. This event is triggered when data is received from the webpage. In the event handler, you can use the HttpCli.RcvdStream property to access the data that was received. When the request is complete, the HttpCli.DocBegin and HttpCli.DocEnd events will be triggered. You can use these events to clean up any resources that you have allocated and to notify the user that the request has completed. Here is an example of how you might use these steps to fetch a webpage and display its contents in a TMemo component:Copy code procedure TForm1.Button1Click(Sender: TObject); var HttpCli: THttpCli; begin HttpCli := THttpCli.Create(nil); try HttpCli.URL := 'https://www.example.com'; HttpCli.RcvdStream := TMemoryStream.Create; HttpCli.OnDocData := HttpCliDocData; HttpCli.GetAsync; finally HttpCli.Free; end; end; procedure TForm1.HttpCliDocData(Sender: TObject; Buffer: Pointer; Len: Integer); begin Memo1.Lines.LoadFromStream(THttpCli(Sender).RcvdStream); end; This is just a basic example, and there are many other features and options available in ICS for more advanced scenarios. You can refer to the ICS documentation for more information. -
How to get ThisFormClass (TForm1) from Form1
Qasim Shahzad posted a topic in Algorithms, Data Structures and Class Design
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- 20 replies
-
- form creation
- refactoring
-
(and 3 more)
Tagged with:
-
How to get ThisFormClass (TForm1) from Form1
Qasim Shahzad replied to Qasim Shahzad's topic in Algorithms, Data Structures and Class Design
That's good idea and we can get ModalResults with this method. Thanks for sharing.- 20 replies
-
- form creation
- refactoring
-
(and 3 more)
Tagged with:
-
How to get ThisFormClass (TForm1) from Form1
Qasim Shahzad replied to Qasim Shahzad's topic in Algorithms, Data Structures and Class Design
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.- 20 replies
-
- form creation
- refactoring
-
(and 3 more)
Tagged with:
-
How to get ThisFormClass (TForm1) from Form1
Qasim Shahzad replied to Qasim Shahzad's topic in Algorithms, Data Structures and Class Design
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.- 20 replies
-
- form creation
- refactoring
-
(and 3 more)
Tagged with:
-
How to get ThisFormClass (TForm1) from Form1
Qasim Shahzad replied to Qasim Shahzad's topic in Algorithms, Data Structures and Class Design
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.- 20 replies
-
- form creation
- refactoring
-
(and 3 more)
Tagged with:
-
How to get ThisFormClass (TForm1) from Form1
Qasim Shahzad replied to Qasim Shahzad's topic in Algorithms, Data Structures and Class Design
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.- 20 replies
-
- form creation
- refactoring
-
(and 3 more)
Tagged with:
-
How to get ThisFormClass (TForm1) from Form1
Qasim Shahzad replied to Qasim Shahzad's topic in Algorithms, Data Structures and Class Design
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.- 20 replies
-
- form creation
- refactoring
-
(and 3 more)
Tagged with:
-
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.