Skip to content

Cloud and lightweight frameworks key in 2010: Forrester

There was a time when JBuilder was dominating the Java Enterprise programming and I was visiting theserverside.com almost every day. The more I work with Embarcadero All-Access and Tool Cloud technologies the more I see the benefits single developers and teams can gain from instant access to arbitrary tools, simplified licensing and reporting.

It was not surprising to see on TheServerSide.com that the Forrester has the same feeling:

"Cloud computing platforms, low-cost application frameworks and more nimble development are among the top changes for application development in 2010, according to Forrester Research.

Cloud computing has great potential to relieve development teams of the burden of buying, installing and configuring servers, storage and networks for their applications, according to the authors."

Source: http://www.theserverside.com/news/thread.tss?thread_id=59117

Delphi 2010 DirectWrite "Hello World" Example

In my previous post I have translated Windows 7 SDK Direct2D "Advanced Geometries" example from C++ to Delphi 2010 code. That was a lot of fun, so I have decided to continue the adventure in the realm of Direct2D programming and this time converted one of the DirectWrite examples - DirectWrite sample "Hello World".

Delphi 2010 Hello World DirectWrite sample app

Delphi 2010 Hello World DirectWrite sample app

In order to avoid writing over and over again the same Direct2D-specific code for creating TDirect2DCanvas instance and implementing "Resize" and "WMEraseBkgnd" methods, I have decided to refactor this common code into a reusable base class called "TFormD2D".


unit D2DUtils;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, D2D1, Direct2D;

type
  TFormD2D = class(TForm)
  private
    FD2DCanvas: TDirect2DCanvas;
    procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
  protected
    procedure Resize; override;
    procedure Paint; override;
    procedure CreateD2DResources; virtual;
    procedure PaintD2D; virtual;
    function rt: ID2D1RenderTarget; // conveniency function
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    property D2DCanvas: TDirect2DCanvas read FD2DCanvas;
  end;

implementation

constructor TFormD2D.Create(AOwner: TComponent);
begin
  inherited;

  if not TDirect2DCanvas.Supported then
    raise Exception.Create('Direct2D not supported!');

  FD2DCanvas := TDirect2DCanvas.Create(Handle);

  CreateD2DResources;
end;

destructor TFormD2D.Destroy;
begin
  FD2DCanvas.Free;
  inherited;
end;

procedure TFormD2D.CreateD2DResources;
begin
  // create Direct2D resources in descendant class
end;

function TFormD2D.rt: ID2D1RenderTarget;
begin
  Result := D2DCanvas.RenderTarget;
end;

procedure TFormD2D.Resize;
var
  HwndTarget: ID2D1HwndRenderTarget;
begin
  inherited;

  if Assigned(D2DCanvas) then
    if Supports(
      rt, ID2D1HwndRenderTarget, HwndTarget) then
        HwndTarget.Resize(D2D1SizeU(ClientWidth, ClientHeight));

  Invalidate;
end;

procedure TFormD2D.WMEraseBkgnd(var Message: TWMEraseBkgnd);
begin
  // avoid flicker as described here:
  // http://chrisbensen.blogspot.com/2009/09/touch-demo-part-i.html
  Message.Result := 1;
end;

procedure TFormD2D.Paint;
begin
  inherited;
  D2DCanvas.BeginDraw;
  try
    PaintD2D;
  finally
    D2DCanvas.EndDraw;
  end;
end;

procedure TFormD2D.PaintD2D;
begin
  // implement painting code in descendant class
end;

end.

Using this base Direct2D class is simple. If you want to "Direct2D-enable" a VCL form class, just add "D2DUtils" unit to your project, add "D2DUtils" to the "uses" clause in the interface section of your form’s unit, and change your form’s base class from "TForm" to "TForm2D".
Now you only need to override "CreateD2DResources" and "PaintD2D" virtual methods and declare private members for different resources used for painting. In the first step you should create all Direct2D resources needed for painting like brushes, fonts, pens, geometries, and assign them to private variables in your form class. The second step is to implement "PaintD2D" that will include your painting code, most likely using "rt" convenience method that returns "D2DCanvas.RenderTarget" interface.

This is the actual code that paints "‘Hello World using DirectWrite in Delphi 2010". Note that the form class derives from "TFormD2" and not "TForm".


unit Unit38;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, D2DUtils, D2D1, Direct2D;

type
  // http://msdn.microsoft.com/en-us/library/ee264320(VS.85).aspx
  TForm38 = class(TFormD2D)
  private
    FBlackBrush: ID2D1SolidColorBrush;
    FTextFormat: IDWriteTextFormat;
  protected
    procedure PaintD2D; override;
    procedure CreateD2DResources; override;
  public

    { Public declarations }
  end;

var
  Form38: TForm38;

implementation

{$R *.dfm}

{ TForm38 }

procedure TForm38.CreateD2DResources;

begin
  inherited;

  rt.CreateSolidColorBrush(
    D2D1ColorF(clBlack, 1),
    nil,
    FBlackBrush
    );

  DWriteFactory.CreateTextFormat(
    PWideChar('Gabriola'),
    nil,
    DWRITE_FONT_WEIGHT_REGULAR,
    DWRITE_FONT_STYLE_NORMAL,
    DWRITE_FONT_STRETCH_NORMAL,
    72,
    PWideChar('en-us'),
    FTextFormat
   );

   FTextFormat.SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);
   FTextFormat.SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
end;

procedure TForm38.PaintD2D;
var
  aDisplayText: string;
  aRect: TD2D1RectF;
begin

  // fill with white color the whole window
  rt.Clear(D2D1ColorF(clWhite));

  aDisplayText := 'Hello World using DirectWrite in Delphi 2010';

  rt.DrawText(
    PWideChar(aDisplayText),
    Length(aDisplayText),
    FTextFormat,
    D2D1RectF(0, 0, ClientWidth, ClientHeight),
    FBlackBrush
    );
end;

end.

The "TForm38" class derives from "TFormD2" class. We need two Direct2D resources to render "Hello World": a text format reference and a black brush. That’s why the first thing to do is to define two fields in our form class:

FBlackBrush: ID2D1SolidColorBrush;
FTextFormat: IDWriteTextFormat;

In the "D2DCreateResource" method both fields are initialized and they are used in "PaintD2D" for rendering text on the form. In order to simplify code that needs to be there for painting surrounding calls to "D2DCanvas.BeginDraw" and "D2DCanvas.EndDraw" have been moved to the ancestor class and very frequently used calls to "D2DCanvas.RenderTarget. …" have been replaced with "rt" function that returns the same thing, but with fewer lines of code.

The source code for this application can be downloaded from EDN CodeCentral.

Direct2D "Advanced Path Geometries" Win7 SDK Example Translated to Delphi 2010

In two days I’m talking about Windows 7 development at Delphi 2010 HandsOn Workshop with Bob Swart and Bruno Fierens from TMS Software.

One of the cool new features introduced in Delphi 2010 specifically for Windows 7 is support for native Direct2D development. Direct2D is very interesting, new graphics subsystem that utilizies GPU processing power for rendering regular operating system windows.

Because of the performance considerations Direct2D has been implemented in native code in Windows 7 and Delphi VCL provides superior object oriented abstractions on top of raw Windows API.

I have decided to give it a try and translated to Delphi from C++ code the "Advanced Geometries" example that ships with Windows 7 SDK.

Delphi 2010 version of Windows 7 SDK Direct2D Advanced Geometries Example

Delphi 2010 version of Windows 7 SDK Direct2D Advanced Geometries Example

The main form in my "DelphiAdvD2DGeometries" Delphi 2010 project has been structured based on information provided by Chris Bensen in his blog post http://chrisbensen.blogspot.com/2009/09/touch-demo-part-i.html.

Delphi 2010 version of Direct2D "Advanced Geometries" Windows 7 SDK example is available for download from EDN Code Central.

Delphi 2010 Online Resources

Here is my handy collection of links to blog posts and resources related to new Delphi 2010 features. Enjoy and GO DELPHI !!!

1. General

  

2. IDE

 

3. Compiler and RTL

  

4. VCL

 

5. Enterprise

 

6. Misc

ITDevCon 2009 - Day 2

It is the second day of ITDevCon. The conference is really better than I was expecting. bitTime crew is taking perfect care of all attendees. Again - it is impossible to be on three parallel sessions at the same time. Especially if you are delivering sessions yourself:-)

The first session for me was my "Delphi Natural Input" session. I have covered Delphi 2010 support for touch, multitouch and gesturing. The more I go into this technology the more I like it. In order to demo multitouch you really need to have multitouch enabled hardware. It is still quite expensive to have proper laptop with touch support, but the alternative is to use either external touch-enabled screen or just an external tablet device which is much more affordable. Marco Cantu showed me in Internet yesterday this Wacom bamboo tablet that is really something like ten times less expensive. During the preparation to my Delphi touch talk I have discovered that the file format for files with gestures definitions created programatically using "TGestureManager.SaveToFile" is incompatible with files created from inside the IDE with Gesture Manager custom gesture editor at design time, but it is still great fun to create Delphi 2010 gestures programmatically:-)

The second session I have attended was by Daniel Magin. Daniel covered ways to remove BDE from your existing Delphi applications. Daniel created in a new unit with his own empty classes derived from TDatabase, TTable, TQuery and TStoredProc and used GExperts to replace throughout the application all occurances of TDatabase, TTable, TQuery and TStoredProc with his own equivalents. In the second step he changed his classes to be derived from RemObjects Data Abstract components. In my opinion this is the way to go. If you consider how DBExpress internals has been changed in Delphi 2007 without breaking the VCL component layer, that’s exactly how BDE could be refactored out from the VCL in the future.

The next session for me was my "Delphi Enterprise Architectures and DataSnap 2010". In this nicely attended slot, I have compared DataSnap 2010 features with other enterprise architectures like CORBA, JEE, WCF and WWSAPI and I think I have managed to prove that DataSnap 2010 has all the features expected from mature, robust enterprise architecture.

Jose Leon - the architect of Delphi for PHP - presented a very interesting session comparing Delphi for Win32 with Delphi for PHP. I really like Jose’s explanation of VCL for PHP library supports concepts from Delphi VCL like component streaming. Very interesting.

Now Boian Mitov is explaining good practices for creating Delphi 2010 multithreaded applications. Boian is very talented Delphi programmer and author of component libraries for video, audio, signal processing, and computer vision. All his libraries are fully multithreaded and optimized using Intel MMX technologies. The libraries are based on the advanced OpenWire technology, and allow writing complex applications with zero or near zero lines of code.

The last session was very difficult to choose. On one hand there is Marco’s "Introduction to jQuery" and on another there "iPhone Development.pas" session by Daniel Magin that is planning to cover developing for iPhone with XCode (Objective C) incl. Interface Builder, developing with Mono Touch and C#, developing with Mono Touch and Pascal (Beta) and web apps with Apple DashCode and Delphi IntraWeb. I have chosen for iPhone development session:-)

Daniel is running Mac OS X and demonstrated building simple iPhone app in XCode and Interface Builder. Objective C is not the most friendly programming language, especially for people with Delphi background. It is much easier to develop for iPhone in MonoDevelop with MonoTouch plugin in any of the .NET languages. The application is using Google Maps to locate Fabrizio:-) The room is packed with people watching Dani performing his iPhone magic with iPhone app talking to Delphi 2010 Web Services SOAP Server application.

We want Delphi for iPhone!

Where is Fabrizio?

Where is Fabrizio?

Fabrizio is here!

Fabrizio is here!

... so is Dani

... so is Dani

ITDevCon 2009 - Day 1

I’m here in Verona - Italian city best known for Romeo and Juliet - on the biggest live Delphi conference in Europe this year - ITDevCon. The conference is organized by bitTime Software- Embarcadero representative in Italy - and there are plenty of Delphi experts presenting on three parallel tracks.

The conference has started from the keynote session where speakers could introduce themselves and we also had David I greeting attendees remotely via skype video session. At the end of the keynote I had an opportunity to demo Embarcadero All-Access.

Some of the sessions are in Italian and some in English. My "What’s New in Delphi 2010 IDE and Compiler" session was obviously in English. It was the first time I was demoing Delphi 2010 on Windows 7. Even if you are a presenter, you always can learn something new from attendees. When I have started demoing debugger visualizers, to my surprise there was nothing in debugger windows. No local variables, nothing. Luckily Boian Mitov suggested to turn off Delphi compiler optimization and rebuild the project. That has made the trick. In fact it would make great sense to turn off compiler optimization in the default "Debug" build configuration. Boian has also implemented Delphi 2010 debugger visualizer for bitmaps. Very interesting.

The next session was by Daniele Teti on Delphi 2010 support for JSON serialization and deserialization. It was not completely new to me, as Daniele has already published very interesting blog post about custom marshaling and unmarshaling in Delphi 2010, but there is nothing like watching the session live. Even in Italian:-) You can find support for JSON in the new "DBXJSON.pas" unit and support for marshalling/unmarshalling in "DBXJSONReflect.pas" unit. The support for serialization and deserialization is very elegant and pluggable. You just need to implement your own custom converters and reverters. When I was watching Daniele, I have realized how useful are generics and anonymous methods introduced in Delphi 2009. In fact the Delphi 2010 VCL uses them quite heavily in different places. Another thing is why in "DBXJSONReflect.pas" in "TTypeMarshaller<TSerial: class>" generic class method params are called "clazz" and not "class"? Interesting…

After lunch I have decided to see Daniel Magin presenting "Delphi and Subversion". Daniel demonstrated setting up Subversion and practical information about Subversion itself and useful tools to work with Subversion, which is probably the most popular version control system in use.

I could not miss the opportunity to see "Advanced Delphi for PHP" session by its architect - Jose Leon.
Jose made his life a little bit easier by playing prerecorded demo episodes and explaining live what was happening on the screen. Delphi for PHP is a very interesting tool for building pure PHP web applications, but using the Delphi concepts in the PHP world. Delphi for PHP is 100% visual IDE, with visual class library modeled after Delphi VCL library. There is nothing that compares to Delphi for PHP in the PHP world. Instead of working in text editor with raw PHP source code and libraries downloaded from Internet, you can work on the higher level of abstraction, because VCL for PHP components encapsulate and abstract away underlying low-level details. You can easily wrap existing PHP libraries, like Zend Framework or ExtJS, with visual components which you can work with visually at design time, pretty much like you can in a normal Delphi 2010 application. One of the very powerful aspects of Delphi for PHP is support for templates to integrate components with fancy CSS designs using popular PHP Smarty Templates engine. You can also easlily create web service servers and consume web services with NuSOAP PHP library available via VCL for PHP components. Another cool features are support for master pages, where you can inherit pages from a master page, and internationalization where you can change page language by changing just one property on a VCL for PHP form. Very cool…

The next session is 99% is Italian by Luca Giacalone and Fabrizio Bitti and is called "Delphi e l’interfacciamento con l’hardware… the easy way" and is all about using Delphi applications to interface with external hardware. The starting point are printed circuits that you can connect to your machine either via serial port or Ethernet. Check out this page to get an idea what external hardware we are talking about. External hardware can be controlled from your application using TIdHttp component. The second example was to use TVaComm component from TMSSoftware to switch on and off a lamp, blinking LEDs and then working with video camera to capture images into your Delphi app. The most spectacular part of the demo was to use Delphi app to control via radio a race car model. That was followed by replacing keyboard with Nintendo Wii remote ("wiimote") control with GlovePIE to steer the car from Delphi app. How cool is that?

Delphi app to control race car model via radio

Delphi app to control race car model via radio

Race car model on the conference room floor

Race car model on the conference room floor

Luca Giacalone uses Wiimote to steer the car with Delphi application

Luca Giacalone uses Wiimote to steer the car with Delphi application

Delphi@SDC2009

The SDC 2009 conference is over. It is the biggest annual developer conference in the Netherlands with 2 days full of session in 9 parallel tracks and international speakers. This year SDN Conference was also hosting the official Dutch Windows 7 launch event for Developers from Microsoft. On Monday evening a keynote took place, followed by 2 timeslots from which you could select specific Windows 7 sessions. Microsoft in the Netherlands - represented by some of the former Borland employees - has announced developer competition for the most interesting Windows 7 applications using touch, rich animation, sensor and location, taskbar and ribbon. It would be really cool to write such an application in Delphi 2010 as there is already great support for many of the cutting-edge features in Windows 7, like Task Dialog and glassing (D2007), Ribbon controls (D2009), Touch, Multitouch and Gesturing (D2010). All Windows 7 API are exposed via native interfaces (that’s what Delphi is using directly) and there is also an additional .NET layer provided for building Windows applications in managed code (http://code.msdn.microsoft.com/WindowsAPICodePack).

On Delphi track for the first time we had a great guest - Barry Kelly, Delphi R&D compiler engineer - who talked about new RTTI enhancements (check out "rtti.pas" unit in your Delphi 2010 installation) and experimental Delphi garbage collector called "TFreezer". He, he… That was a good fun!

I’ve also followed Marco Cantu sessions on threading and Windows 7 development in Delphi 2010 and Cary Jensen session on 9 techniques for thread and process synchronization. Very, very interesting. Cary and Marco are extremally popular Delphi speakers and they are looking to organize another round of Delphi Developer Days next year. If you REALLY want them to come to your city - just shout:-)

From my personal point of view the most interesting sessions were by Hadi Hariri. Hadi is very popular and knowledgeable Delphi programmer who in the past worked on Intraweb and Indy components. The first session by Hadi that I have attended was a replacement session where he presented "Introduction to jQuery". I was always interested in jQuery and it was very informative session with lots of additional useful comments on technology. Basically you do not need any server side technology to have great looking web pages that take advantage of the locally available processing horse power and properly use AJAX (or AJAJ, as there is JSON instead of XML).

The next two sessions from Hadi were on Delphi Prism ASP.NET MVC development. Hadi explained why he does not like abstractions of WebForms and why MVC approach is so much better. The ASP.NET MVC architecture is basically Ruby on Rails framework recreated in the ASP.NET. One of the corner stones of Ruby on Rails is "convention over configuration" and this is really powerful. The idea is that you start from a complete web application with proper structure and all unit tests in place. It is easier to modify than starting from scratch.

Hadi, Marco and other speakers very often were comparing different web architectures to WebBroker that is there in Delphi since at least Delphi 5. Back than 10 years ago WebBroker was a little bit too much into the future, but now all the concepts of WebBroker architecture are absolutely relevant. Maybe it is an idea to do what Microsoft did with Ruby on Rails - replicate RoR on our own Delphi WebBroker architecture?

Delphi 2010 in Croatia

I really like Croatia and it was such a pleasure to visit Zagreb on Tuesday with Mark Barringer (who did great DBOptimizer Beta 2 and ER/Studio demos) for the Delphi 2010 launch events. Delphi and C++Builder developers in Croatia really cares about their beloved products and were asking lots of - sometimes tough - questions.

It was really great to meet in person Zarko Gajic. If you are interested in Delphi, you must have heard already about "delphi.about.com" that Zarko is updating with new articles every few days for the last at least 10 years!

with Zarko Gajic

with Zarko Gajic of delphi about com

More photos from the event can be found on the Konto website at http://www.codegear.com.hr/download/Delphi2010_Zagreb/

Next week I’m off to Papendal in Netherlands for the annual SDC conference. We are going to have plenty of big Delphi experts presenting in the Delphi track including Barry Kelly, Bob Swart, Marco Cantu, Cary Jensen, Chad Hower and Hadi Hariri.

On Thursday, October 22nd, I’m running two webinars about new Delphi 2010 features. The first one in the morning (11am CET, 10am UK) covers new IDE, language and VCL stuff and the afternoon one (3pm CET, 2pm UK) is all about DataSnap 2010 architecture. It is free but you need to register at http://www.embarcadero-events.eu/

If you cannot make it to see Delphi in October - make sure to visit Verona in Italy on November 11 and 12 for the ITDevCon conference. David I is coming from the US and it looks like it is going to be the biggest Delphi conference in Europe this year.

Delphi 2010 never sleeps!

Man! I can’t remember when I was travelling so much. In the last two weeks I’ve been on the road with Mark Barringer - ER/Studio guru - and we were in 5 different cities. Right now I’m in the Hotel Antunovic in Zagreb where we are going to have Croatian RAD Studio 2010 launch event tomorrow morning organized by Konto - Embarcadero partner company in Croatia.

Last week we’ve been to Sweden and Danmark - Stockholm on Tuesday, Gothenburg on Wedesday and Kopenhagen on Thursday. I had my camera, but only I found it on the last day, so… no photos from Sweden. Delphi and C++Builder programmers in Scandinavia really care about Embarcadero and Delphi. The number of questions that we got was incredible:-)

Delphi 2010 in Denmark (8 Oct 2009)

Delphi 2010 in Denmark (8 Oct 2009)

Seminars is one thing, but Delphi user group meetings is another:-) In Gothenburg, in the evening before the event, we had dinner in Italian restaurant with the Delphi user group. At some moment of time I felt like it was iPhone user group but that’s a different story… Gothenburg is with no doubt the Delphi capitol of Sweden. Magnus Flysjö - Delphi community leader in Sweden - not only was kind enough to show some cool stuff with Delphi 2010 custom attributes (setting a caption and color for a form with "DemoForm" attribute), but also designed and produced great RAD Studio 2010 blouses.

Here are the two guys pretending to have something to do with Embarcadero (by "Magnus clothing"):

MarkB and PawelG - Embarcadero Crew

MarkB and PawelG - Embarcadero Crew

If you cannot come for any of the live Delphi 2010 launch events make sure to register for one of the many upcoming live webinars. Next Thursday, October 22nd, I’m going to run two 60 minutes webinars (11am and 3pm Amsterdam time) about new Delphi 2010 features and new DataSnap 2010 architecture for building Delphi applications that communicate over the network. It is all free and you only need to register.

More Delphi 2010 Launch Events in Europe:-)

It is such a pleasure to demonstrate Delphi 2010 and C++Builder 2010 to developers in different cities and countries. The feedback everywhere is overwhelmingly positive. Esepcially IDE Insight, DataSnap 2010, Gesturing and Delphi for MacOSX and Linux on the Delphi roadmap. In the last three weeks I have met about 800 Delphi and C++Builder developers in 7 different cities around Europe.

Here are some photos from RAD Studio 2010 events.

Manchester and London, 2009 September 15th and 16th. More then 100 developers in total.

Lier, Belgium, September 17th. Great location and great fun.

 

I was really pleased to see almost 200 developers gathered in Prague on September 22nd.

In my home city - Warsaw in Poland - more then 160 developers and IT managers gathered to see the new features in Delphi and C++Builder (September 24th).

In Ljubljana - Slovenia - there was close to 100 attendess on RAD Studio 2010 launch event. September 29th.

The Delphi 2010 launch in Budapest on September 30th was simply excellent. Plenty of very interesing questions and great athmosphere.

It is Friday evening. RAD Studio 2010 launch events in Sweden and Denmark are only few days ahead. And there is beautiful Croatia on Tuesday, October 13th.

Delphi 2010 is clearly the best release of Delphi I have ever used and F6 for easy keyboard access to everything simply rulez!

Bad Behavior has blocked 2 access attempts in the last 7 days.

Close