麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > 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";

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

圖片精選

主站蜘蛛池模板: 免费视频a | 国产午夜精品理论片a级探花 | 欧美成人精品一区二区三区 | 欧美日韩亚洲在线观看 | 视频在线中文字幕 | 国产精品一区视频 | 免费视频一区 | 黄色大片大毛片 | 国产精品久久久不卡 | 成人在线观看免费 | 亚洲欧美国产精品va在线观看 | av免费大全 | 91av爱爱 | jizzzzxxxxx| 欧美日韩网站在线观看 | 久久久麻豆 | 国产一级在线观看视频 | 竹内纱里奈和大战黑人 | 69性欧美高清影院 | 黄视频网站免费在线观看 | 欧洲色阁中文字幕 | cosplay裸体福利写真 | 欧美一区二区三区不卡免费观看 | 九九热视频这里只有精品 | 久久色伦理资源站 | 欧美一级高潮片免费的 | 国产成年人网站 | 日韩视频在线一区二区三区 | a视频网站 | 19禁国产精品福利视频 | www日韩在线观看 | 性明星video另类hd | 国产69精品久久99不卡免费版 | 中文在线观看免费视频 | av电影在线免费 | 免费午夜视频 | 欧美成人午夜 | 色av成人天堂桃色av | 最新av网址在线观看 | 主播粉嫩国产在线精品 | 精精国产xxxx视频在线播放7 |