From Win32 To .NET Programming With Delphi

Document Sample
scope of work template
							From Win32 To .NET Programming
          With Delphi
                   Agenda

 從 Win32 的 Object Pascal 程 式 語 言
  到 .NET 的 Delphi 程 式 語 言
 一 般 Delphi 程 式 如 何 移 植 到 .NET
 DLL/COM/COM+/ActiveX 元 件 和 .NET
  程式
 Delphi 元 件 和 .NET 元 件
 VCL Framework 和 VCL .NET
 Delphi 資 料 庫 應 用 程 式 如 何 移 植
  成 .NET 資 料 庫 應 用 程 式
 Q&A
               Borland Delphi

 Large and loyal independent developer
  community
  - Estimated 1 million developers world wide
  - 50% of the BDN community (1.6m registrations)
  - 580 registered component developers
 Strong solution for SME, Departmental, and
  ISV Applications
Delphi Technology Innovation

                                         Future Technology

                                      ALM / .NET

                                 Web Services

                          Intranet/Internet
                                              ALM/.NET
                    Multi-tier            ALM/.NET
                                     Web Services
             Client/Server
                        Multi-tier
         Database

Windows/desktop
        Delphi Technology Foundation


             Application         Design
              Lifecycle           Driven            Future
 Strategic   Management        Development

                               Delphi IDE
             Delphi Compiler           Delphi Compiler
Language         Win32                      .NET

     API          VCL            VCL.NET Winforms WebForms

 Platform        Win32                       .NET
        What the Analysts Say


  “Delphi developers should pay careful
attention to the delivery of Borland‟s new
 .NET IDE before any transition to Visual
   Studio .NET … it has the potential to
   better meet the needs of developers
 leveraging .NET in a multi-vendor, best-
          of-breed environment.”
          —Mark Driver, Research Analyst, Gartner Group
Project Octane
 Delphi for Win32 and .NET
   Project Octane for Win32 and .NET

                                   Accelerate the Delphi
                                    Application Lifecycle for Win32
                       Develop      and .NET
     Design
                                   Address the needs of Delphi
                                    developers on Windows and
               Change
             Management
                                    those moving to .NET
Requirements               Test
                                   Increase productivity with
              Deploy                Design Driven development
                                   Interoperability with Mixed
                                    environments
     Microsoft Platform Evolution


   Delphi 1             Delphi 2               Octane

    Win16                Win32                  .NET

     x86                   x86            Managed Code

 Delphi supports the Windows  .NET evolution
  - Managed code, Optimized for Windows
  - The “new API” for Windows, the Windows Platform Standard
  - .NET adoption, Not “if” but “when”
  Borland Commitment to Windows
             and .NET
02/02 Borland announces support for Microsoft .NET
        Delphi 7 Studio and the Borland Preview for Microsoft
08/02
        .NET shipped
10/02 Borland joins .NET Advisory Council
12/02 .NET SDK redistribution agreement signed
        Borland announces Optimizeit Profiler for the Microsoft
02/03
        .NET Framework
        Borland Platinum sponsor at Microsoft Windows Server
04/03
        2003 launch event
04/03 Borland announces ALM for .NET strategy
        Borland announces C#Builder for the Microsoft .NET
05/03
        Framework and Borland Janeva
                      .NET Support

 Reuse Delphi language skills with the Microsoft .NET
  Framework
   - DCCIL compiler is first class .NET citizen generating 100% .NET
     code
   - Build new .NET applications using the Delphi language

 Migrate existing Delphi applications to .NET
   - VCL.NET is 100% .NET compliant component library with a high
     degree of VCL compatibility
   - Reuse existing code

 Single environment for Delphi and C# development
   - Octane IDE will interoperate with C#Builder IDE (or vice-versa)
   - Enables Delphi developers to add C# to their projects and skills
         Application Lifecycle Management
                Solution for Octane

                                                                   Easily check Octane
Win32 and .NET
                                                                   source files in and out
modeling tool
                                                                   of StarTeam repository
integration. Integrated
                                                                   through Octane’s built-
UML Designer                    Design        Project Octane
                                                                   in LiveTeam features




                                         StarTeam®
                          CaliberRM™                  Optimizeit
                                                      Profiler™     Conveniently profile
Monitor Octane project                                For .NET      any Octane .NET
requirements progress                    Microsoft                  assembly or
via the CaliberRM status                                            executable in your
                                       Windows .NET
pane within Octane                                                  project from within
                                          Server
                                                                    Octane
From Now On Only Pure Tech.

      Are You Ready?

     Don‟t Fall Asleep!
 從 Win32 的 Object Pascal 程 式 語 言
    到 .NET 的 Delphi 程 式 語 言

 Object Pascal幾乎完整的移植到.NET中, 除了不符
  合.NET CLR/CLS規範以及存取硬體的機制
 Object Pascal強化了語言機制, 支持.NET
  CLR/CLS功能, 因此改為Delphi語言
 DFM檔案內之Persistent資訊將以Delphi原始碼的
  形式融入.PAS檔案中
Data Type Mapping
        Data Type Mapping

 Extended  System.Double是一個8-byte
  floating-point type
 Char變成2個位元
 String成為WideString
                   New & Improved
   Unit Namespaces
                                Multicast Events
   Qualified Identifiers
                                Include/Exclude events
   Nested Types
                                Array prop overloads
   Custom Attributes
                                “Boxing” into objects
   Class (static) data
   Class properties
   Class static methods
   Records w/ Inheritance
   Records w/ methods
   Sealed classes
   Final methods
                 Unit Namespaces

 Access units with fully qualified idents
  - Uses Borland.VCL.Forms;

 Delphi unit defines its own namespace
  - Dotted names in unit identifiers and file names

 Project namespace search path
  -   Search for unqualified unit names on namespace path
  -   Uses Forms;
  -   In VCL project, Forms -> Borland.VCL.Forms
  -   In CLX project, Forms-> Borland.CLX.Forms

 Project default namespace
              Project Namespaces

 Eliminate uses clause IFDEFs
 Project namespace search path
  -   Search for unqualified unit names on namespace path
  -   Uses Forms;
  -   In VCL project, Forms -> Borland.VCL.Forms
  -   In CLX project, Forms-> Borland.CLX.Forms

 Project default namespace
  - Unit MyControl;
  - VCL project: compiles to Borland.VCL.MyControl.DCU
  - CLX project: compiles to Borland.CLX.MyControl.DCU
           Using Attributes
type
  [ FooAttribute(‘Hello’, 23) ]
  TMyClass = class
     [ SpecialDataAttribute ]
     Fdata: Integer;
     [ WebMethod,
          DebuggerStepThrough ]
     function SampleCount: Byte;
  end;
                      開發流程

 Delphi專案(*.dpr)
   a
Delphi程式單元(*.dfm)

                             .NET應用程式
    DFM2PAS


Delphi.NET專案(*.dpr)
                         Delphi.NET Compiler
                                 dccil
     Delphi.NET
    原始程式(*.pas)
A Win32 Sample Program
          使用DFM2PAS/Dccil

 Dfm2pas PWin32Prg.dpr PNetPrg.dpr
 修改PWin32Prg.dpr
 dfm2pas fmMain.pas fmNetMain.pas

 Dccil –v PNetPrg.dpr
    A Object Pascal/Delphi Language
            Sample Program
   TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
   private
    { Private declarations }
    class var
      iX : Integer;
      iY : Integer;
    class function GetX : Integer; static;
    class procedure WriteX(const iValue : Integer); static;
   public
    { Public declarations }
    class function GetSystemTime : String; static;
    class property X : Integer read GetX write WriteX;
   end;
    A Object Pascal/Delphi Language
            Sample Program
   class function TForm1.GetX : Integer;
   begin
    Result := TForm1.iX;
   end;
   class procedure TForm1.WriteX(const iValue : Integer);
   begin
    if (iValue <> TForm1.iX) then

    TForm1.iX := iValue;
   end;
   procedure TForm1.Button1Click(Sender: TObject);
   begin
    Button1.Caption := TForm1.GetSystemTime;
    TForm1.X := 999;
    Button2.Caption := IntToStr(TForm1.X);
   end;
一 般 Delphi 程 式 如 何 移 植 到 .NET

 現在使用Dfm2Pas/Dccil即可轉換大部份的一
  般程式
 未來在Delphi 8的IDE中重新Compile即可
 一般的語法將轉為Delphi語法,資料型態將轉為
  CLR/CLS資料型態
 對於Win32 API的呼叫將藉由.NET的InterOp
  呼叫
DLL/COM/COM+/ActiveX 元 件 和
         .NET 程 式
  DLL/COM/COM+/ActiveX 元 件 和
           .NET 程 式

 A DLL Demo
  - 使用DllImport Attribute

  - //[DllImport('aviPlayer.dll', CharSet=CharSet.Ansi,
    EntryPoint = 'PlayAVI')]
  - //procedure PlayAVI(const sName : String);
    external;
  DLL/COM/COM+/ActiveX 元 件 和
           .NET 程 式

 A COM+ Demo
              A COM+ Demo
 function TdDemoCOM.GetSystemInfo: WideString;
 begin
 Result := 'This is COM+ Object Right now is : ' +
  DateToStr(now);
 end;
               Demo Process

 Step 1先為COM+建立Type Library wrapper
  Assembly
  - Tlbimp PDemoCOM.dll /out:PNETDemoCOM.dll
 Step 2 使用dfm2pas轉換Delphi Client應用程式
  - Dfm2pas PCOMDemo.dpr PNETCOMDemo.dpr
  - Dfm2pas fmMain.pas fmNETMain.pas
 Step 3修改PNETCOMDemo.dpr, fmNETMain.pas
 Step 4 使用dccil
  - Dccil –v –luPNETDemoCOM PNETDemoCOM.dpr
                  .NET Application

               Your Application or Package

.NET Framework

                      .Data            .Windows
               .Xml                          .Web
        Etc.                                        Etc.
                              System



          Win32
      .NET‟s System.Windows.Forms

               Your Application or Package

.NET Framework

                      .Data            .Windows
               .Xml                           .Web
        Etc.                                         Etc.
                              System



          Win32
                                          User32

                               ComCtrls     RichEd
          Delphi for .NET application
   Your Application or Package   Your Application or Package


.NET Framework


       Borland.VCL                  .Windows.Forms

      .Web       .Data                    .Xml      .Net
                         Borland System



             Win32
          Delphi for .NET application
   Your Application or Package   Your Application or Package


.NET Framework


       Borland.VCL                  .Windows.Forms

      .Web       .Data                    .Xml      .Net
                         Borland System



             Win32
Delphi 資 料 庫 應 用 程 式 如 何 移 植
    成 .NET 資 料 庫 應 用 程 式

   BDE/IDAPI
   Midas
   dbExpress
   ADO.NET
                BDE/IDAPI
 Native drivers to various DataSource
  - Oracle, MS SQL Server, InterBase, dBase, Paradox…
 在.NET中仍然可以使用BDE/IDAPI嗎?
  - 是的, 但是僅限於BDE/IDAPI最後支援的資料庫和版本
 VCL.NET藉由InterOp允許.NET程式存取
  BDE/IDAPI
                     BDE/IDAPI
 a                      .NET 應用程式



                  .NET InterOp Technology



                         IDAPI32.DLL


 Sqlora8.dll   Sqlmss32.dll   Sqldb232.dll   Idpdx32.dll.dll   …
            BDE/IDAPI
 Borland.VCL.DB,
 Borland.VCL.BDE.DbTables,
 Borland.VCL.CDS.DBClient,
 Borland.VCL.DBGrids,
 Borland.VCL.DBCtrls;
           BDE/IDAPI
 A BDE Demo
                    Midas
 Delphi 8會移植Midas
  -   Borland.Db.CDS.DBClient
  -   Borland.Db.CDS.DSIntf
  -   Borland.Db.CDS.Mconnect
  -   Borland.Db.CDS.Midas
  -   Borland.Db.CDS.Provider
  -   Borland.Db.CDS.TConnect
  BDE/IDAPI
 BDE結合Midas的範例
           dbExpress

 Delphi 8應該會把dbExpress移植到.NET中
              ADO.NET
 Delphi 8將可直接使用ADO.NET存取資料
 - Borland.Db.ADONET.ADONETDb
The Next Generation‟s C/C++ Tool
           The Target: C++ Developers

         C++ will remain the largest community through 2005

               3M
                    C++
Professional              Visual Basic
Developers 2M
WorldWide           COBOL
                     Delphi
               1M
                       Java                 C#

 Source: IDC
                    2000      2001   2002   2003   2004   2005
    Current Trends in the C++ market

 Large effort in maintenance of C++ code
 Multi-platform supported applications
 Mobile and Embedded support is strong
 C++ is preferred for performance
 computing
 Microsoft focus on managed code
 Migration from Unix to Linux on Intel
 The C++ standard is evolving.
                 Enabling C++ Developers
                           Rapid Application
                         Designers and Wizards         RAD Tool
                                                       RAD Tool
       Project
        IRIS
                         Re-usable component
                             Development


                          System Libraries                          Xplatform
                      Connectivity and DB access                       IDE


Mobile tools           Operating System Feature
                            Programming

                                                       System
                    Device Drivers/Hardware Specific   Dev
                             Programming               Tools
 Together          ALM tools
 StarTeam
                                                                Multi-toolchain
            C++BuilderX Overview

 Multi-platform IDE
   - Same PrimeTime IDE (and look and feel) as JBuilder
   - Windows, Linux, Solaris
 Multiple compiler toolchain support
   - Supports Borland, Microsoft, GNU, Metrowerks, Intel, Sun Forte
   - New Borland 100% ANSI/ISO C++ and C99 compliant compiler
 ALM integration
   - Caliber, Together, StarTeam, Visibroker, Interbase
   - Intel VTune Performance Analyzer, InstallShield MultiPlatform
 Visual Development environment
   - Pure C++ RAD framework and designers
 Mobile solutions
   - Supports any Symbian SDK
      C++BuilderX ALM Integration

 Same level of integration as offered in
  JBuilder 9
  -   Caliber read-only client in Together
  -   Together Touch-Point integration
  -   StarTeam SCM advanced integration
  -   Intel VTune Performance Analyzer*
  -   VisiBroker 5.2 integration
  -   Interbase 7.1 support
  -   InstallShield MultiPlatform*
Together® Edition for C++BuilderX™
            Overview
 Provides an integrated and agile UML
  development environment using the C++BuilderX
  environment.
 Adds ease in designing and working with classes,
  the core of C++
 Creates visual models from code and keeps
  models and code automatically synchronized
 Provides audits and metrics capabilities to
  improve and measure quality of applications
         1983-2003
  20 years of „Turbo Charging‟
Software Development Excellence

     20 years of support for
  Microsoft operating systems,
   technologies, and initiatives.
C++BuilderX Demo
Q&A

						
Related docs