a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 編程 > Delphi > 正文

老友歸來--delphi2005試用手記1

2019-11-18 18:06:52
字體:
來源:轉載
供稿:網友
 

Delphi出到8時,我曾安裝過。當時第一感覺是失望,因為熟悉的vcl視覺不見了;再一個感覺是陌生,因為delphi改動了它的代碼,我們再要寫東西就得遵循MS.net命名空間做事。更重要的是,我對使用delphib/s開發沒有信心。好不爽了一陣子后,我轉向了java平臺。

 

但后來,我看到asp.net真的非常好,而且delphi也可以實現它,這讓我有種想回見老友的沖動。但當時沒時間學,所以還不太懂。我對IntraWebasp.net兩種實現都很有興趣,很想試試。在后來,c# builder1.0的試用讓我對borland多少有了點好感,但還是覺得它是跟屁蟲,已經沒有ms抗衡的力量了。這讓我想起了加菲貓的一句話,如果打不過你的敵人,最好的辦法就是加入他們。

 

今天,我對delphi有了另一種態度。不再苛刻地要求它就是最好最快的,而是希望自己在b/s也能用得上delphi,并覺得還好用,這就足夠了。至于它外觀和空間的變化,在delphi8后,我已開始接受,畢竟delphi不走.net就沒什么路可走了。

 

當我意外地得到borland寄來的delphi2005試用版時,我就想得到了一款正在流行的游戲一樣,非常想試玩一下。可是,borland的注冊太沒有“中國特色”了,害得我跑到網上弄了個注冊機。不做D版用戶還不太習慣。

 

(一)Hello World.

Delphi2005是個集成環境,包括了delphic#,好像還可以使用vb.net,但這不是常規菜單里的內容。我感覺borland對此款軟件的命名有問題,應該叫borland.net2005才對,不然用delphi開發c#,聽起來有點搞笑。

 

先來用delphi寫個Hello World吧。在2005里,開發delphi有三種不同的途徑,自然應用環境也不同。分別是:

1 VCLForms application for .NET

2 WindowsForms Application for .NET

3 VCLForms Application for Win32.


下面是三個方式下的
Hello World.

1 VCLForms Application for .NET

單元代碼:

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.

 

窗體代碼:

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
 

這看起來,和從前的win32開發沒有什么不同。單元和窗體分開,分別作處理和持久化工作。而在2中這兩個工作合并在一個pas文件里了。

 

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.

它的代碼和1完全一樣。

 

最后是用c#寫的helloworld.它只有.net一種方式,因為它誕生在.net時代。

 

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(disposing);

                   }

 

                   #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";

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 日韩精品久久久免费观看夜色 | 中文字幕一区二区三区日韩精品 | 可以在线看的黄色网址 | 成人黄视频在线观看 | 免费一级毛片 | 日韩精品免费一区二区夜夜嗨 | 国产拍拍拍拍拍拍拍拍拍拍拍拍拍 | 天天操狠狠 | 国内久久精品 | 在线污污 | 黄色精品视频 | 亚洲欧洲一区二区三区 | 欧美国产高清 | 一区二区精品视频 | 国产精品一区av | 97久久精品午夜一区二区 | 噜噜噜噜狠狠狠7777视频 | 亚洲日本韩国在线观看 | 亚洲精品成人 | 国产最新精品视频 | 自拍偷拍亚洲视频 | 密色视频| 玖玖操| 午夜视频福利 | 日韩精品免费观看 | 999国内精品永久免费视频 | 国产小视频在线免费观看 | 精品欧美一区二区三区久久久 | 丁香久久 | 国产精品一区视频 | 久草免费电影 | 中文字幕亚洲一区二区三区 | 国产成人精品一区二区 | 91在线最新 | 成人精品 | 999在线视频免费观看 | 久久久久久亚洲av毛片大全 | 特级毛片在线大全免费播放 | 岛国精品 | 99精品国产一区二区三区 | 北条麻妃国产九九九精品小说 |