sequence
I installed Delphi when it was 8:00. The first feeling at that time was disappointment because the familiar VCL vision was gone; the other feeling was strange because delphi changed its code, and if we wanted to write something, we had to follow the MS .net namespace to do things. More importantly, I have no confidence in using delphi for b/s development. After a while of upset, I turned to the java platform.
But later, I saw that asp.net was really good, and delphi could implement it, which gave me the urge to see my old friend back. But I didn't have time to learn at that time, so I didn't quite understand it. I am very interested in both IntraWeb and asp.net implementations and would like to give it a try. Later, the trial of C# builder1.0 gave me some good impression of Borland, but I still felt that it was a follower and no longer had the power to compete with ms. This reminds me of a Garfield saying that if you can't beat your enemies, the best way is to join them.
Today, I have another attitude towards delphi. No longer demanding that it is the best and fastest, but hopes that you can use delphi in b/s and think it is easy to use, which is enough. As for its appearance and space changes, after delphi8, I have begun to accept it. After all, there is no way to go if delphi does not go.net.
When I accidentally got the trial version of delphi2005 sent by Borland, I wanted to get a popular game and really wanted to try it out. However, the registration of borland is too "Chinese" and I made me run online to get a registration machine. It's not very used to not being a D version user.
(I) Hello World.
Delphi2005 is an integrated environment, including delphi and c#. It seems that you can also use vb.net, but this is not the content in the regular menu. I feel that borland has a problem with the naming of this software. It should be called borland.net2005, otherwise it would be a bit funny to use delphi to develop c#.
Let’s write Hello World using delphi first. In 2005, there were three different ways to develop delphi, and the natural application environment was also different. They are:
1 VCLForms application for .NET
2 WindowsForms Application for .NET
3 VCLForms Application for Win32.
Here are Hello World in three ways.
1 VCLForms Application for .NET
Unit code:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
PRocedure Button1Click(Sender: TObject);
Private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Begin
edit1.Text :='Hello World.';
end;
end.
Form code:
object Form1: TForm1
Left = 0
Top = 0
Width = 281
Height = 138
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 88
Top = 56
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
object Edit1: TEdit
Left = 8
Top = 8
Width = 249
Height = 21
TabOrder = 1
end
end
This seems to be no different from the previous win32 development. The unit and the form are separated, and are processed and persisted separately. In 2, these two works are merged into a pas file.
2 WindowsForms Application for .NET
unit WinForm;
interface
uses
System.Drawing, System.Collections, System.ComponentModel,
System.Windows.Forms, System.Data;
type
TWinForm = class(System.Windows.Forms.Form)
{$REGION 'Designer Managed Code'}
strict private
/// <summary>
/// Required designer variable.
/// </summary>
Components: System.ComponentModel.Container;
TextBox1: System.Windows.Forms.TextBox;
Button1: System.Windows.Forms.Button;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure InitializeComponent;
procedure Button1_Click(sender: System.Object; e: System.EventArgs);
{$ENDREGION}
strict protected
/// <summary>
/// Clean up any resources being used.
/// </summary>
procedure Dispose(Disposing: Boolean); override;
Private
{ Private Declarations }
public
constructor Create;
end;
[assembly: RuntimeRequiredAttribute(TypeOf(TWinForm))]
Implementation
{$AUTOBOX ON}
{$REGION 'Windows Form Designer generated code'}
/// <summary>
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure TWinForm.InitializeComponent;
Begin
Self.TextBox1 := System.Windows.Forms.TextBox.Create;
Self.Button1 := System.Windows.Forms.Button.Create;
Self.SuspendLayout;
//
// TextBox1
//
Self.TextBox1.Location := System.Drawing.Point.Create(72, 40);
Self.TextBox1.Name := 'TextBox1';
Self.TextBox1.Size := System.Drawing.Size.Create(152, 21);
Self.TextBox1.TabIndex := 0;
Self.TextBox1.Text := '';
//
// Button1
//
Self.Button1.Location := System.Drawing.Point.Create(80, 160);
Self.Button1.Name := 'Button1';
Self.Button1.Size := System.Drawing.Size.Create(136, 32);
Self.Button1.TabIndex := 1;
Self.Button1.Text := 'Button1';
Include(Self.Button1.Click, Self.Button1_Click);
//
// TWinForm
//
Self.AutoScaleBaseSize := System.Drawing.Size.Create(6, 14);
Self.ClientSize := System.Drawing.Size.Create(292, 273);
Self.Controls.Add(Self.Button1);
Self.Controls.Add(Self.TextBox1);
Self.Name := 'TWinForm';
Self.Text := 'WinForm';
Self.ResumeLayout(False);
end;
{$ENDREGION}
procedure TWinForm.Dispose(Disposing: Boolean);
Begin
If Disposing then
Begin
if Components <> nil then
Components.Dispose();
end;
inherited Dispose(Disposing);
end;
constructor TWinForm.Create;
Begin
inherited Create;
//
// Required for Windows Form Designer support
//
InitializeComponent;
//
// TODO: Add any constructor code after InitializeComponent call
//
end;
procedure TWinForm.Button1_Click(sender: System.Object; e: System.EventArgs);
Begin
TextBox1.Text:='Hello World!';
end;
end.
3 VCLForms Application for Win32.
Its code is exactly the same as 1.
Finally, it is helloworld written in c#. It only has one way of .net, because it was born in the .net era.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Project1
{
/// <summary>
/// Summary description for WinForm.
/// </summary>
public class WinForm: System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
public WinForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(dispose);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(72, 88);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(120, 21);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "textBox1";