老友归来--delphi2005试用手记1

2016-02-19 16:22 3 1 收藏

下面图老师小编要向大家介绍下老友归来--delphi2005试用手记1,看起来复杂实则是简单的,掌握好技巧就OK,喜欢就赶紧收藏起来吧!

【 tulaoshi.com - 编程语言 】

 

Delphi出到8时,我曾安装过。当时第一感觉是失望,因为熟悉的vcl视觉不见了;再一个感觉是陌生,因为delphi改动了它的代码,我们再要写东西就得遵循MS的.net命名空间做事。更重要的是,我对使用delphi做b/s开发没有信心。好不爽了一阵子后,我转向了java平台。

?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 

但后来,我看到asp.net真的非常好,而且delphi也可以实现它,这让我有种想回见老友的冲动。但当时没时间学,所以还不太懂。我对IntraWeb和asp.net两种实现都很有兴趣,很想试试。在后来,c# builder1.0的试用让我对borland多少有了点好感,但还是觉得它是跟屁虫,已经没有ms抗衡的力量了。这让我想起了加菲猫的一句话,如果打不过你的敌人,最好的办法就是加入他们。

 

今天,我对delphi有了另一种态度。不再苛刻地要求它就是最好最快的,而是希望自己在b/s也能用得上delphi,并觉得还好用,这就足够了。至于它外观和空间的变化,在delphi8后,我已开始接受,毕竟delphi不走.net就没什么路可走了。

 

当我意外地得到borland寄来的delphi2005试用版时,我就想得到了一款正在流行的游戏一样,非常想试玩一下。可是,borland的注册太没有“中国特色”了,害得我跑到网上弄了个注册机。不做D版用户还不太习惯。

 

(一)Hello World.

Delphi2005是个集成环境,包括了delphi、c#,好像还可以使用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.

?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />


  下面是三个方式下的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'

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

  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;

  //

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

  // Required for Windows Form Designer support

  //

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

  InitializeComponent;

  //

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

  // TODO: Add any constructor code after InitializeComponent call

  //

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

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

来源:https://www.tulaoshi.com/n/20160219/1611862.html

延伸阅读
标签: CorelDRAW
三、增强的绘形工具(Shaping Tools) 1、涂抹笔刷和粗糙笔刷(Smudege Brush和Roughen Brush) 简单的说,这是两个新增的基于矢量图形的变形工具,大致可以看作AI10液化工具组的精简版。这些工具实际上能帮助我们创建更为复杂的曲线图形。 这两个新增Smudge和Roughen笔刷的支持压感笔,可感知倾斜角...
标签: CorelDRAW
2.稳定性 软件的稳定性是至关重要的。比起那个不尽人意的 10,CorelDRAW11稳定性又如何呢? 据说有人“试图使它中断崩溃,用有999步的调和与999步的渐变,还有奇形怪状的图形进行轮廓线工具的测试,并且建立一个真实不正当的工作空间,然而没有不幸发生”。 据说还有网友已经连续使用它48小时,而且全部是处...
标签: CorelDRAW
五、符号功能 先前版本的符号功能相对简单,并且是一个单方向的处理方式,即只能使用,无法存储。CorelDRAW 11中做了很多改进。 1. 创建和应用符号 CorelDRAW 11中,可将页面上常见对象保存为符号,并加入库中。 而方法简单的几乎几步即可完成:执行“Edit”-“Symbol”-“Library”打开Library泊坞窗,...
  之前用的是Java那一套东西,有Eclipse什么都搞定了。现在因为要用Delphi改一个即时通讯软件的缘故,想着怎么能把重构和单元测试那一套搬到Delphi这边来。书上说给现有的代码加单元测试能够加深对代码的理解,并且可以作为改善代码的基础,这不正是我要做的事情吗?于是,为了搭建这么一个敏捷平台,我以Delphi2005和DUnit进行了一点...
标签: Delphi
  之前用的是Java那一套东西,有Eclipse什么都搞定了。现在因为要用Delphi改一个即时通讯软件的缘故,想着怎么能把重构和单元测试那一套搬到Delphi这边来。书上说给现有的代码加单元测试能够加深对代码的理解,并且可以作为改善代码的基础,这不正是我要做的事情吗?于是,为了搭建这么一个敏捷平台,我以Delphi2005和DUnit进行了一点...

经验教程

744

收藏

53
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部