<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/wordpress-mu-1.2.3-2.2.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Pawel Glowacki</title>
	<link>http://blogs.codegear.com/pawelglowacki</link>
	<description>CodeGear EMEA Technical Evangelist</description>
	<pubDate>Thu, 10 Apr 2008 17:07:27 +0000</pubDate>
	<generator>http://wordpress.org/?v=wordpress-mu-1.2.3-2.2.1</generator>
	<language>en-US</language>
			<item>
		<title>Greetings to all Czech Delphi Developers:-)</title>
		<link>http://blogs.codegear.com/pawelglowacki/2008/04/10/38509</link>
		<comments>http://blogs.codegear.com/pawelglowacki/2008/04/10/38509#comments</comments>
		<pubDate>Thu, 10 Apr 2008 17:00:49 +0000</pubDate>
		<dc:creator>Pawel Glowacki</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.codegear.com/pawelglowacki/2008/04/10/38509</guid>
		<description><![CDATA[More then 130 developers attended "CodeGear RAD Studio 2007" presentation during recent "Belohrad 2008" conference in Lazne Belohrad in Czech. This is one of the biggest and most important independent developer conferences in Czech and traditionally attracts lots of Delphi developers. It was great fun demonstrating native Delphi VCL for the Web development with AJAX [...]]]></description>
			<content:encoded><![CDATA[<p>More then 130 developers attended "CodeGear RAD Studio 2007" presentation during recent <a href="http://www.haes.cz/ws_pozv.asp">"Belohrad 2008" conference</a> in Lazne Belohrad in Czech. This is one of the biggest and most important independent developer conferences in Czech and traditionally attracts lots of Delphi developers. It was great fun demonstrating native Delphi VCL for the Web development with AJAX support, extending Blackfish SQL for Windows with Delphi for .NET stored procedures and building RESTful .NET 3.5 web services with Delphi for .NET.</p>
<p><a href="http://bdntv.borland.com/pix/pawelglowacki/20080408/PawelCzechy2008Apr1.jpg"><img src="http://bdntv.borland.com/pix/pawelglowacki/20080408/PawelCzechy2008AprSmall.PNG" alt="click here for a bigger photo" /> </a></p>
<p>The conference was held in <a href="http://maps.google.com/maps?f=q&amp;hl=en&amp;geocode=&amp;q=Lazne+Belohrad&amp;sll=37.0625,-95.677068&amp;sspn=40.409448,95.976562&amp;ie=UTF8&amp;ll=50.429518,15.578613&amp;spn=8.149508,23.994141&amp;z=6&amp;iwloc=addr">Lazne Belohrad</a>, which is a very beautiful, small spa in Czech mountains. In the past it was called "Delphi conference" and this was the 10th anniversary of this great event. I&#8217;m looking forward to the next year:-)</p>
<p class="akst_link"><a href="http://blogs.codegear.com/pawelglowacki/?p=38509&amp;akst_action=share-this"  title="Post to del.icio.us, etc." id="akst_link_38509" class="akst_share_link" rel="nofollow">Share This</a> | <a href="mailto:?subject=Greetings%20to%20all%20Czech%20Delphi%20Developers%3A-%29&body=Have you seen this? http%3A%2F%2Fblogs.codegear.com%2Fpawelglowacki%2F2008%2F04%2F10%2F38509" id="akst_email_38509" class="akst_share_email" rel="nofollow">Email this page to a friend</a></p>]]></content:encoded>
			<wfw:commentRss>http://blogs.codegear.com/pawelglowacki/2008/04/10/38509/feed</wfw:commentRss>
		</item>
		<item>
		<title>Building .NET 3.5 WCF RESTful web services with Delphi 2007</title>
		<link>http://blogs.codegear.com/pawelglowacki/2008/04/04/38508</link>
		<comments>http://blogs.codegear.com/pawelglowacki/2008/04/04/38508#comments</comments>
		<pubDate>Fri, 04 Apr 2008 15:01:08 +0000</pubDate>
		<dc:creator>Pawel Glowacki</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.codegear.com/pawelglowacki/2008/04/04/38508</guid>
		<description><![CDATA[What is "REST" anyway? 
"REST" does not have anything to do with relaxing. It is rather a hot term used in the context of Service Oriented Architecture (SOA). The term "Representational State Transfer" was coined by Thomas Fielding in 2000, in his PhD dissertation "Architectural Styles and the Design of Network-based Software Architecture". In essence [...]]]></description>
			<content:encoded><![CDATA[<p><strong>What is "REST" anyway? </strong><br />
"REST" does not have anything to do with relaxing. It is rather a hot term used in the context of <a href="http://en.wikipedia.org/wiki/Service-oriented_architecture">Service Oriented Architecture</a> (SOA). The term <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">"Representational State Transfer"</a> was coined by Thomas Fielding in 2000, in his PhD dissertation <a href="http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm">"Architectural Styles and the Design of Network-based Software Architecture"</a>. In essence it is all about making services available through HTTP protocol easier. With traditional web services HTTP is used as transport for exchanging SOAP messages. REST supporters make a point that HTTP protocol is rich enough on its own, and it is possible to use it directly for exchanging arbitrary messages, not necessarily SOAP, and not necessarily XML.</p>
<p>In the early days of web services the HTTP protocol was the only mean for exchanging XML-encoded SOAP messages. Windows Communication Foundation (WCF) architecture introduced in .NET 3.0 decouples SOAP messaging from the underlying transport and introduces other then HTTP transports for exchanging SOAP messages. For example there is <a href="http://msdn2.microsoft.com/en-us/library/ms731092.aspx">"NetTcpBinding"</a> that uses TCP as transport protocol. With RESTful web services the underlying protocol is HTTP, however messages are not encoded as SOAP envelopes, and does not even need to be encoded in XML. It is more and more common to encode them in simpler <a href="http://www.json.org/">JSON</a> format instead, or even plain text. RESTful web services can be used to retrieve arbitrary MIME-types, not necessarily text, for example images.</p>
<p>Aaron Lerch in his <a href="http://www.developer.com/net/article.php/3695436">"Creating RESTful Web Services with WCF 3.5"</a> article points out that "Representational State Transfer" is a phrase that describes the generic principles that make up much of what we know to be the HTTP protocol. As it applies to web services, the primary concepts of interest are resources, and the actions that can be taken on a given resource. Resources are identified by Uniform Resource Identifiers (URIs), something that nearly everybody is familiar with. SOAP-based web services typically use a single URI to represent the service endpoint plus an operation. A RESTful web service uses a unique URI to reference every resource, and HTTP verbs to define actions on those resources. REST-based services are making heavy use of different HTTP verbs (GET, POST, PUT, DELETE), HTTP result status codes, and encoding request details inside the URI.</p>
<p>The .NET 3.5 Framework introduces support for this low-level "web programming" through new types defined in the "System.ServiceModel.Web" namespace. Specifically there is a new WCF binding for web programming called <a href="http://msdn2.microsoft.com/en-us/library/system.servicemodel.webhttpbinding.aspx">"WebHttpBinding"</a>, corresponding "WebHttpBehavior", new attributes for specifying HTTP GET or POST methods - "WebGet" and "WebInvoke", and also new "UriTemplate" custom attribute for mapping URIs to methods and their parameters.</p>
<p><strong>Building basic Delphi 2007 WCF REST service </strong></p>
<p>Let&#8217;s build a simple Delphi 2007 WCF REST service application. The structure of Delphi 2007 WCF 3.5 web application is very similar to the Delphi 2007 WCF 3.0 applications described in the <a href="http://dn.codegear.com/article/36962">"Introduction to WCF Programming in Delphi"</a> CodeGear Developer Network article. To successfully build the service application make sure to have .NET 3.5 installed and CodeGear RAD Studio 2007 <a href="http://dn.codegear.com/article/37442">"December Update"</a> installed.</p>
<p>The first step is to create a new "Console Application - Delphi for .NET" and save it for example as "DelphiRESTBasicSample_Service" project.</p>
<p>The second thing to do is to add appropriate project references. Right click on the "References" node in the "Project Manager" and select "Add Reference&#8230;". Click the browse button and add the following reference assemblies to the project:</p>
<ul>
<li>C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.ServiceModel.dll</li>
<li>C:\WINDOWS\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\System.Runtime.Serialization.dll</li>
<li>C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.ServiceModel.Web.dll</li>
</ul>
<p>The side effect of adding these references to the project is adding directories where these assemblies reside to the project&#8217;s search paths.</p>
<p><img src="http://bdntv.borland.com/pix/pawelglowacki/20080404/projrefs.PNG" /></p>
<p>Now it is time to add two empty units to the project. One for the service interface and one for the implementation. I&#8217;m going to start from implementing a simple "calculator" service. This time using new WCF attributes introduced in the .NET 3.5.</p>
<pre>
unit uServiceIntf;  

interface  

uses
  System.ServiceModel,
  System.ServiceModel.Web;  

type
  [ServiceContract]
  IService = interface  

    [OperationContract]
    [WebGet(UriTemplate='Add?a={x}&amp;b={y}')]
    function Add(x, y: integer): integer;  

    [OperationContract]
    [WebGet(UriTemplate='Sub?a={x}&amp;b={y}', ResponseFormat=WebMessageFormat.Json)]
    function Subtract(x, y: integer): integer;  

  end;  

implementation  

end.</pre>
<p>Note the usage of the new "WebGet" attribute. To invoke both methods declared in the "IService" interface HTTP GET method must be used. The "UriTemplate" is used to specify how the web method is going to be invoked. The "UriTemplate" class supports the matching or binding of a string template with name-value pairs. When defining an OperationContract, a UriTemplate is specified and it accomplishes two purposes. First, it provides the mapping between a request URI and an OperationContract, and second, it identifies the named values that are subsequently bound to matching OperationContract method parameters. By default responses are encoded in XML. The second "WebGet" attribute contains "ResponseFormat=WebMessageFormat.Json" to instructs the WCF runtime to encode response as JSON, instead of XML.</p>
<p>The implementation of the service is trivial:</p>
<pre>
unit uServiceImpl;  

interface  

uses
  uServiceIntf;  

type
  TService = class(TObject, IService)
  public
    function Add(x, y: integer): integer;
    function Subtract(x, y: integer): integer;
  end;    

implementation  

{ TService }  

function TService.Add(x, y: integer): integer;
begin
  Result := x + y;
end;  

function TService.Subtract(x, y: integer): integer;
begin
  Result := x - y;
end;  

end.</pre>
<p>The last step is to add code to the project&#8217;s source code. To display project source in the editor select "View Source" option from "Project" menu. Here is the full source code of the project.</p>
<pre>
program DelphiRESTBasicSample_Service;  

{$APPTYPE CONSOLE}  

uses
  SysUtils,
  System.ServiceModel.Web,
  System.ServiceModel,
  uServiceIntf in 'uServiceIntf.pas',
  uServiceImpl in 'uServiceImpl.pas';  

var
  aBaseAddress: string;
  URIs: array of Uri;
  host: WebServiceHost;  

begin
  try
    aBaseAddress := 'http://localhost:8000/';
    SetLength(URIs, 1);
    URIs[0] := Uri.Create(aBaseAddress);  

    host := WebServiceHost.Create(typeof(TService), URIs);
    host.Open;  

    writeln('Service is running and listening at ' + aBaseAddress);
    writeln('Press any key to quit...');
    readln;  

    host.Close;  

  except
    on e: Exception do
    begin
      host.Abort;
      writeln(e.Classname, ': ', e.Message);
      readln;
    end;
  end;
end.</pre>
<p>Note the new "WebServiceHost" class for hosting our RESTful service web service. The service is complete. After running it from inside the IDE you should see the following window. Press any key to stop the service application. Here we are hosting the WCF service in the console application, but it is also possible to host it inside the IIS.</p>
<p><img src="http://bdntv.borland.com/pix/pawelglowacki/20080404/consoleservice1.PNG" /></p>
<p>To test the service application we can just start a web browser and type in the following URL:</p>
<pre>http://localhost:8000/Add?a=2&amp;b=3</pre>
<p>Right-clicking on the browser window and selecting "View Page Source" reveals that the following string was returned from the "Add" method.</p>
<p><img src="http://bdntv.borland.com/pix/pawelglowacki/20080404/webbrows1.PNG" /></p>
<p>In order to consume RESTful web service an arbitrary HTTP client is required. Luckily Delphi 2007 comes with a number of <a href="http://www.indyproject.org/index.EN.aspx">Indy 10</a> components for low-level network programming. The "TIdHTTP" component implements an HTTP client and can be used to interact with our RESTful web application. In the CodeGear RAD Studio 2007 installation there is a demo Delphi for Win32 project that uses "TIdHTTP" component that can be used directly as a test client for our service application. In the default installation it can be found in the following location:</p>
<p>C:\Documents and Settings\All Users\Documents\RAD Studio\5.0\Demos\Indy10\HTTPVCLForm\IdHttpDemoVCL.dproj </p>
<p>Now we can test both methods: "Add" and "Sub". I have compiled the "IdHttpDemoVCL" project and started it from outside the IDE. Because I keep changing the service application, it is more easy to run the service from within the IDE.</p>
<p><img src="http://bdntv.borland.com/pix/pawelglowacki/20080404/client_add.PNG" /> <img src="http://bdntv.borland.com/pix/pawelglowacki/20080404/client_sub.PNG" /></p>
<p><strong>Summary </strong></p>
<p>The .NET 3.5 introduced support for building RESTful web services that do not use SOAP for encoding messages. This simplifies building SOA applications and clients. In this article I have demonstrated building basic .NET 3.5 RESTful web services with Delphi 2007 for .NET and consuming them with TIdHTTP component from Delphi 2007 for Win32 VCL Forms application.</p>
<p><strong>References </strong></p>
<ul>
<li><a href="http://www.codegear.com/products/radstudio">CodeGear RAD Studio 2007 </a></li>
<li><a href="http://dn.codegear.com/article/36962">"Introduction to WCF Programming in Delphi"</a> by Pawel Glowacki, CodeGear Developer Network article</li>
<li><a href="http://en.wikipedia.org/wiki/Windows_Communication_Foundation">Wikipedia: Windows Communication Foundation </a></li>
<li><a href="http://msdn2.microsoft.com/en-us/magazine/cc135976.aspx">"WCF Syndication: HTTP Programming with WCF and the .NET Framework 3.5"</a> by Justin Smith, MSDN Magazine, January 2008</li>
<li><a href="http://www.developer.com/net/article.php/3695436">"Creating RESTful Web Services with WCF 3.5"</a> by Aaron Lerch, www.developer.com</li>
<li><a href="http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm">"Architectural Styles and the Design of Network-based Software Architecture"</a> by Roy Thomas Fielding, Doctor of Philosophy Dissertation, University of California, Irvine, 2000</li>
<li><a href="http://www.json.org/">JSON Homepage </a></li>
<li><a href="http://www.indyproject.org/index.EN.aspx">The Indy Project </a></li>
</ul>
<p class="akst_link"><a href="http://blogs.codegear.com/pawelglowacki/?p=38508&amp;akst_action=share-this"  title="Post to del.icio.us, etc." id="akst_link_38508" class="akst_share_link" rel="nofollow">Share This</a> | <a href="mailto:?subject=Building%20.NET%203.5%20WCF%20RESTful%20web%20services%20with%20Delphi%202007&body=Have you seen this? http%3A%2F%2Fblogs.codegear.com%2Fpawelglowacki%2F2008%2F04%2F04%2F38508" id="akst_email_38508" class="akst_share_email" rel="nofollow">Email this page to a friend</a></p>]]></content:encoded>
			<wfw:commentRss>http://blogs.codegear.com/pawelglowacki/2008/04/04/38508/feed</wfw:commentRss>
		</item>
		<item>
		<title>Register Now for Free Delphi SOA and Web Services Webinars, April 2008</title>
		<link>http://blogs.codegear.com/pawelglowacki/2008/03/12/38507</link>
		<comments>http://blogs.codegear.com/pawelglowacki/2008/03/12/38507#comments</comments>
		<pubDate>Wed, 12 Mar 2008 20:19:01 +0000</pubDate>
		<dc:creator>Pawel Glowacki</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.codegear.com/pawelglowacki/2008/03/12/38507</guid>
		<description><![CDATA[Check out the new layout of the EMEA CodeGear Event Calendar at www.codegear-events.eu. It is now easier to find things. There are two new main columns. One for future events and one for watching playbacks. Looks great to me.
I&#8217;m going to present the following 60 minutes Delphi webinars around Service Oriented Architecture and Web Services [...]]]></description>
			<content:encoded><![CDATA[<p>Check out the new layout of the EMEA CodeGear Event Calendar at <a href="http://www.codegear-events.eu/">www.codegear-events.eu</a>. It is now easier to find things. There are two new main columns. One for future events and one for watching playbacks. Looks great to me.</p>
<p>I&#8217;m going to present the following 60 minutes <a href="http://www.codegear.com/products/radstudio">Delphi</a> webinars around <a href="http://en.wikipedia.org/wiki/Service-oriented_architecture">Service Oriented Architecture</a> and <a href="http://en.wikipedia.org/wiki/Web_service/">Web Services</a> theme in April and I do invite you to register. It is going to be fun:-) See you online on Tuesdays at 11am and 3pm in April (<a href="http://en.wikipedia.org/wiki/Central_European_Time">CET</a>, GMT +1).</p>
<hr />Title: <strong>Understanding XML</strong><br />
Date: Tuesday, April 1st, 2008<br />
Time: 11:00 CET<br />
Length: 60 minutes<br />
URL: <a href="http://borland.interwise.com/borland/iClass/KD5785/default.asp">http://borland.interwise.com/borland/iClass/KD5785/default.asp </a></p>
<p>In this webinar attendees will be introduced to basics of <a href="http://en.wikipedia.org/wiki/XML">eXtensible Markup Language</a> (XML). The following topics will be discussed:</p>
<ul>
<li>XML as a better HTML</li>
<li>XML document structure</li>
<li>Rules of well-formedness</li>
<li><a href="http://www.w3.org/TR/REC-xml-names/">XML Namespaces</a></li>
<li>Validating XML with DTD and <a href="http://www.w3.org/TR/xmlschema-0/">XML Schema</a></li>
<li><a href="http://www.w3schools.com/xsl/">XSLT</a> and <a href="http://en.wikipedia.org/wiki/XPath">XPath</a></li>
<li>XML Parser Types</li>
</ul>
<p>The "Understanding XML" session is designed as a <a href="http://en.wikipedia.org/wiki/Programming_language">programming language</a> neutral introduction to XML and starting point for using XML in a programming language of your choice.</p>
<hr />Title: <strong>Delphi XML Programming</strong><br />
Date: Tuesday, April 1st, 2008<br />
Time: 15:00 CET<br />
Length: 60 minutes<br />
URL: <a href="http://borland.interwise.com/borland/iClass/CA9054/default.asp">http://borland.interwise.com/borland/iClass/CA9054/default.asp </a></p>
<p>This webinar builds on “Understanding XML” session and covers Delphi XML programming using:</p>
<ul>
<li>TXMLDocument component</li>
<li><a href="http://en.wikipedia.org/wiki/XML_data_binding">Data Binding</a> Wizard</li>
<li>XML Mapper</li>
</ul>
<hr />Title: <strong>Understanding Web Services and SOA</strong><br />
Date: Tuesday, April 15th, 2008<br />
Time: 11:00 CET<br />
Length: 60 minutes<br />
URL: <a href="http://borland.interwise.com/borland/iClass/VN3690/default.asp">http://borland.interwise.com/borland/iClass/VN3690/default.asp </a></p>
<p>Service Oriented Architecture (<a href="http://www.service-architecture.com/">SOA</a>) gains a lot of attention as a modern approach for building scalable and maintainable software systems. This session covers the following topics:</p>
<ul>
<li>Benefits of Service Oriented Architecture (<a href="http://www.service-architecture.com/web-services/articles/service-oriented_architecture_soa_definition.html">SOA</a>)</li>
<li>Understanding Web Services Description Language (<a href="http://www.w3schools.com/wsdl/wsdl_intro.asp">WSDL</a>)</li>
</ul>
<p>This session is designed as a programming language-neutral introduction to SOA and Web Services and starting point for building service-oriented application in <a href="http://en.wikipedia.org/wiki/Lists_of_programming_languages">programming language</a> of your choice.</p>
<hr />Title: <strong>Delphi for Win32 Web Services Programming</strong><br />
Date: Tuesday, April 15th, 2008<br />
Time: 15:00 CET<br />
Length: 60 minutes<br />
URL: <a href="http://borland.interwise.com/borland/iClass/GR4596/default.asp">http://borland.interwise.com/borland/iClass/GR4596/default.asp </a></p>
<p>This webinar builds on the contents “Understanding Web Services and SOA” session and discusses Web Service development with <a href="http://www.codegear.com/products/delphi/win32">Delphi for Win32</a>. The following topics will be presented:</p>
<ul>
<li>Consuming Web Services in Delphi for Win32 with "Web Service Importer"</li>
<li>Building Delphi for Win32 Web Services with "<a href="http://en.wikipedia.org/wiki/SOAP">SOAP</a> Server Wizard"</li>
</ul>
<hr />Title: <strong>Delphi for .NET Web Services Programming</strong><br />
Date: Tuesday, April 22nd, 2008<br />
Time: 11:00 CET<br />
Length: 60 minutes<br />
URL: <a href="http://borland.interwise.com/borland/iClass/AO6376/default.asp">http://borland.interwise.com/borland/iClass/AO6376/default.asp </a></p>
<p>This webinar builds on the contents “Understanding Web Services and SOA” session and discusses Web Service development with Delphi for .NET. The following topics will be presented:</p>
<ul>
<li>Consuming Web Services in Delphi for .NET with "Add Web Reference" wizard</li>
<li>Building Delphi <a href="http://en.wikipedia.org/wiki/ASP.NET">ASP.NET</a> Web Service Applications</li>
</ul>
<hr />Title: <strong>Delphi Interoperable WCF Programming</strong><br />
Date: Tuesday, April 22nd, 2008<br />
Time: 15:00 CET<br />
Length: 60 minutes<br />
URL: <a href="http://borland.interwise.com/borland/iClass/TT3731/default.asp">http://borland.interwise.com/borland/iClass/TT3731/default.asp </a></p>
<p>This webinar builds on the contents “Understanding Web Services and SOA” session and discusses SOA development with <a href="http://www.codegear.com/products/radstudio">Delphi</a> using <a href="http://en.wikipedia.org/wiki/Windows_Communication_Foundation">Windows Communication Foundation</a>. The following topics will be presented:</p>
<ul>
<li><a href="http://msdn2.microsoft.com/en-us/library/aa480188.aspx">WCF Basics</a>: understanding service descriptions, bindings, endpoints and channels</li>
<li>Building interoperable WCF Service applications with Delphi for <a href="http://download.microsoft.com/download/4/a/3/4a3c7c55-84ab-4588-84a4-f96424a7d82d/NET_35_Namespaces_Poster_JAN08.pdf">.NET 3.5</a></li>
<li>Consuming <a href="http://dn.codegear.com/article/36962">WCF services in Delphi</a> for .NET and Delphi for Win32</li>
</ul>
<hr />
<p class="akst_link"><a href="http://blogs.codegear.com/pawelglowacki/?p=38507&amp;akst_action=share-this"  title="Post to del.icio.us, etc." id="akst_link_38507" class="akst_share_link" rel="nofollow">Share This</a> | <a href="mailto:?subject=Register%20Now%20for%20Free%20Delphi%20SOA%20and%20Web%20Services%20Webinars%2C%20April%202008&body=Have you seen this? http%3A%2F%2Fblogs.codegear.com%2Fpawelglowacki%2F2008%2F03%2F12%2F38507" id="akst_email_38507" class="akst_share_email" rel="nofollow">Email this page to a friend</a></p>]]></content:encoded>
			<wfw:commentRss>http://blogs.codegear.com/pawelglowacki/2008/03/12/38507/feed</wfw:commentRss>
		</item>
		<item>
		<title>codegearbuntu in distro heaven</title>
		<link>http://blogs.codegear.com/pawelglowacki/2008/03/07/38506</link>
		<comments>http://blogs.codegear.com/pawelglowacki/2008/03/07/38506#comments</comments>
		<pubDate>Fri, 07 Mar 2008 14:14:35 +0000</pubDate>
		<dc:creator>Pawel Glowacki</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.codegear.com/pawelglowacki/2008/03/07/38506</guid>
		<description><![CDATA["Distro heaven" is the main theme of the March 2008 Linux Format issue. Ubuntu is currently probably the most popular Linux distribution and also basis of myriads of derivatives, like Kubuntu,  Edubuntu, Linux Mint, Ubuntu Studio, Mythbuntu, Fluxbuntu and thousands of others.
This made me thinking if it would make sense to create "CodeGearBuntu"? What should go [...]]]></description>
			<content:encoded><![CDATA[<p>"Distro heaven" is the main theme of the <a href="http://www.linuxformat.co.uk/modules.php?op=modload&amp;name=NewArchives&amp;issue=103">March 2008</a> Linux Format issue. <a href="http://www.ubuntu.com/products/whatisubuntu">Ubuntu</a> is currently probably the most popular Linux distribution and also basis of myriads of <a href="http://en.wikipedia.org/wiki/List_of_Ubuntu-based_distributions">derivatives</a>, like Kubuntu,  Edubuntu, Linux Mint, Ubuntu Studio, Mythbuntu, Fluxbuntu and thousands of others.</p>
<p>This made me thinking if it would make sense to create "CodeGearBuntu"? What should go into Linux CodeGear distro? Maybe there should be more "codegearbuntus" like <a href="http://www.codegear.com/products/3rdrail/get-excited/">"CodeGearBuntu3rdRailDesktop"</a> with Rails 2.0, <a href="http://teaminsight.codegear.com/">"CodeGearBuntuJBuilderTeamInsight"</a> with subversion, xplanner, bugzilla and continuum, and <a href="http://www.chevelleinc.com/">"CodeGearBuntuHardcoreDeveloper"</a> with a trendy <a href="http://www.codegear.com/">CodeGear</a> wallpaper preinstalled?</p>
<p class="akst_link"><a href="http://blogs.codegear.com/pawelglowacki/?p=38506&amp;akst_action=share-this"  title="Post to del.icio.us, etc." id="akst_link_38506" class="akst_share_link" rel="nofollow">Share This</a> | <a href="mailto:?subject=codegearbuntu%20in%20distro%20heaven&body=Have you seen this? http%3A%2F%2Fblogs.codegear.com%2Fpawelglowacki%2F2008%2F03%2F07%2F38506" id="akst_email_38506" class="akst_share_email" rel="nofollow">Email this page to a friend</a></p>]]></content:encoded>
			<wfw:commentRss>http://blogs.codegear.com/pawelglowacki/2008/03/07/38506/feed</wfw:commentRss>
		</item>
		<item>
		<title>What about watching a Delphi webinar today?</title>
		<link>http://blogs.codegear.com/pawelglowacki/2008/03/03/38505</link>
		<comments>http://blogs.codegear.com/pawelglowacki/2008/03/03/38505#comments</comments>
		<pubDate>Mon, 03 Mar 2008 13:12:00 +0000</pubDate>
		<dc:creator>Pawel Glowacki</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.codegear.com/pawelglowacki/2008/03/03/38505</guid>
		<description><![CDATA[Depending on your timezone it may or may not be "today" for you, but in coming hours I&#8217;m doing a couple of live Delphi webinars, and please feel invited to join:-) You only need to install free InterWise client and just few minutes before the event click on one of the URLs below to watch and [...]]]></description>
			<content:encoded><![CDATA[<p>Depending on your <a href="http://www.timeanddate.com/worldclock/">timezone</a> it may or may not be "today" for you, but in coming hours I&#8217;m doing a couple of live Delphi webinars, and please feel invited to join:-) You only need to install free InterWise client and just few minutes before the event click on one of the URLs below to watch and ask questions. The first webinar is on 10am in Lisbon and Dublin, 11am in Amsterdam, Warsaw and Zagreb, and on 12am in Ankara and Kyiv.</p>
<p><em>Morning&#8230;</em></p>
<p>Tuesday, March 4th, 11.00 <a href="http://www.timeanddate.com/library/abbreviations/timezones/eu/cet.html">CET</a> (<a href="http://www.timeanddate.com/library/abbreviations/timezones/eu/gmt.html">GMT</a> +1), <a href="http://borland.interwise.com/borland/iClass/NM6405/">"What&#8217;s New in RAD Studio 2007 for Delphi Developers?"</a></p>
<p>Native Delphi AJAX web application with new VCL for the Web framework, parameterized types (generics) in Delphi compiler, new DBX4 database driver architecture, Visual Query Builder, ASP.NET 2.0, live templates for HTML tags inside integrated HTML Editor, adding projecs to "New Items" dialog through Template Libraries - new Delphi Repository mechanism.</p>
<p><em>Afternoon&#8230;</em></p>
<p>Tuesday, March 4th, 15.00 CET, <a href="http://borland.interwise.com/borland/iClass/YS8650/">"DBX4 for BDE Developers"</a></p>
<p>New Delphi DBX4 Database Driver Architecture, Data Explorer VCL Form Designer integration, unidirectional datasets and provider architecture, moving from BDE to DBX data-access components, programmatically reading BDE and DBX metadata, creating tables with DBX metadata classes and migrating data from BDE to DBX in code.</p>
<p><em>Any time&#8230;</em></p>
<p><a href="http://www.codegear-events.eu/">http://www.codegear-events.eu/</a></p>
<p class="akst_link"><a href="http://blogs.codegear.com/pawelglowacki/?p=38505&amp;akst_action=share-this"  title="Post to del.icio.us, etc." id="akst_link_38505" class="akst_share_link" rel="nofollow">Share This</a> | <a href="mailto:?subject=What%20about%20watching%20a%20Delphi%20webinar%20today%3F&body=Have you seen this? http%3A%2F%2Fblogs.codegear.com%2Fpawelglowacki%2F2008%2F03%2F03%2F38505" id="akst_email_38505" class="akst_share_email" rel="nofollow">Email this page to a friend</a></p>]]></content:encoded>
			<wfw:commentRss>http://blogs.codegear.com/pawelglowacki/2008/03/03/38505/feed</wfw:commentRss>
		</item>
		<item>
		<title>Creating database tables programmatically with Delphi DBX4 metadata classes</title>
		<link>http://blogs.codegear.com/pawelglowacki/2008/02/28/38504</link>
		<comments>http://blogs.codegear.com/pawelglowacki/2008/02/28/38504#comments</comments>
		<pubDate>Thu, 28 Feb 2008 16:44:49 +0000</pubDate>
		<dc:creator>Pawel Glowacki</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.codegear.com/pawelglowacki/2008/02/28/38504</guid>
		<description><![CDATA[Inspired by Steve Shaughnessy&#8217;s post on "The New dbExpress 4.0 MetaData" I&#8217;ve decided to give this approach a try and created a sample Delphi 2007 for .NET VCL Forms application that I&#8217;m using during current serie of CodeGear seminars to demonstrate the incredible amount of innovation in DBX4 architecture. Many Delphi programmers asked me to [...]]]></description>
			<content:encoded><![CDATA[<p>Inspired by Steve Shaughnessy&#8217;s post on <a href="http://blogs.codegear.com/steveshaughnessy/2007/09/07/38810">"The New dbExpress 4.0 MetaData"</a> I&#8217;ve decided to give this approach a try and created a sample Delphi 2007 for .NET VCL Forms application that I&#8217;m using during current serie of CodeGear seminars to demonstrate the incredible amount of innovation in DBX4 architecture. Many Delphi programmers asked me to blog about it, so here we are:-)</p>
<p>With the new DBX4 metadata classes it is possible to programmatically create database tables and indices in code against any database connection configured in the <a href="http://www.codegear.com/products/radstudio">CodeGear RAD Studio 2007</a> Data Explorer.</p>
<p>One possible approach, as demonstrated by <a href="http://www.drbob42.com/">Dr. Bob</a> during <a href="http://www.sdn.nl/Default.aspx?tabid=266">2007 December SDE</a> conference on "Migratie: van BDE naar BlackfishSQL via dbExpress" session, is to programmatically construct a SQL statement with appropriate "CREATE TABLE &#8230;" SQL code and pass it to "TSQLConnection.ExecuteDirect" method for immediate execution. One problem with this approach is the fact that there are subtle differences in SQL syntax accross different database products, so it is very difficult to create one SQL "create table" string good for all databases.</p>
<p>With Delphi DBX4 Metadata classes it is possible to create database tables and indices on the higher level of abstraction. You can now do it in Pascal code instead of low-level SQL statements.</p>
<p><strong>Steps:</strong></p>
<p><strong>1.</strong> Start CodeGear RAD Studio 2007</p>
<p><strong>2.</strong> In Data Explorer add a connection to a database where you want to programmatically create a new database table. I&#8217;m using sample CodeGear InterBase 2007 "Employee.gdb" database located in default installation under: "C:\Program Files\Common Files\CodeGear Shared\Data". Make sure that the name of the database in Data Explorer is "EMPLOYEE".</p>
<p><strong>3.</strong> In the "New Items" dialog select "VCL Forms Application - Delphi for .NET". Save All.</p>
<p><img src="http://bdntv.borland.com/pix/pawelglowacki/20080227/dbxmeta_newapp.PNG" /></p>
<p><strong>4.</strong> Select "Add Reference" from "Project" menu. In the "Add Reference" dialog select "Borland.Data.DbxCommonDriver.dll", "Borland.Data.DbxReadOnlyMetaData.dll" and "Borland.Data.AdoDbxClient" assemblies. Click "Add Reference" button, and then OK.</p>
<p><img src="http://bdntv.borland.com/pix/pawelglowacki/20080227/dbxmeta_refs.PNG" /></p>
<p><strong>5.</strong> Add an empty Delphi unit to project and save it as "dbxutils".</p>
<p><img src="http://bdntv.borland.com/pix/pawelglowacki/20080227/dbxmeta_newunit.PNG" /></p>
<p><img src="http://bdntv.borland.com/pix/pawelglowacki/20080227/dbxmeta_empty_unit.PNG" /></p>
<p><strong>6.</strong> Replace new unit&#8217;s empty body with the following code and save.</p>
<pre>
unit dbxutils;      

interface      

uses
  System.Data.Common,
  Borland.Data.DBXMetaDataProvider,
  Borland.Data.AdoMetaDataProvider,      

  // database specific metadata writers
  Borland.Data.DBXInterbaseMetaData,
  Borland.Data.DBXDataStoreMetaData;      

type
  TDBXUtils = class
  public
    class function GetAdoConnection(aConnectionName: string): DBConnection;
    class function GetAdoMetaDataProvider(aConnection: DBConnection): TAdoMetaDataProvider;
    class function GetMetaDataProvider(aConnectionName: string): TDBXMetaDataProvider;
  end;      

implementation      

{ TDBXUtils }      

class function TDBXUtils.GetAdoConnection(
  aConnectionName: string): DBConnection;
var
  Factory: System.Data.Common.DbProviderFactory;
  Connection: System.Data.Common.DbConnection;
begin
  Factory := System.Data.Common.DbProviderFactories.GetFactory(
    'Borland.Data.AdoDbxClient');
  Connection := Factory.CreateConnection();
  Connection.ConnectionString := 'ConnectionName=' + aConnectionName;
  Connection.Open;
  Result := Connection;
end;      

class function TDBXUtils.GetAdoMetaDataProvider(
  aConnection: DBConnection): TAdoMetaDataProvider;
begin
  if aConnection = nil then
    raise Exception.Create('Connection is nil');      

  Result := TAdoMetadataProvider.Create;
  Result.Connection := aConnection;
  Result.Open;
end;      

class function TDBXUtils.GetMetaDataProvider(
  aConnectionName: string): TDBXMetaDataProvider;
begin
  Result := GetAdoMetaDataProvider(GetAdoConnection(aConnectionName));
end;      

end.</pre>
<p><strong>7.</strong> Add two "TEdit" and one "TButton" components to the main form of your application. In the Object Inspector change "Name" property of TEdit components to respectively "EditConnectionName" and "EditNewTableName".</p>
<p><img src="http://bdntv.borland.com/pix/pawelglowacki/20080227/dbxmeta_form.PNG" /></p>
<p><strong>8.</strong> Add "dbxutils" and "Borland.Data.DBXMetaDataProvider" to the form&#8217;s unit "uses" clause.</p>
<p><strong>9.</strong> Add the following code in the button&#8217;s "OnClick" event:</p>
<pre>
procedure TFormMain.Button1Click(Sender: TObject);
var
  AMetaDataTable: TDBXMetaDataTable;
  AMetaDataProvider: TDBXMetaDataProvider;
begin
  AMetaDataTable := TDBXMetaDataTable.Create;      

  AMetaDataTable.TableName := EditNewTableName.Text;
  AMetaDataTable.AddColumn(TDBXInt32Column.Create('C1'));
  AMetaDataTable.AddColumn(TDBXDecimalColumn.Create('C2', 10, 2));
  AMetaDataTable.AddColumn(TDBXUnicodeCharColumn.Create('C3', 32));      

  AMetaDataProvider := TDBXUtils.GetMetaDataProvider(EditConnectionName.Text);
  AMetaDataProvider.CreateTable(AMetaDataTable);
end;</pre>
<p><strong>10.</strong> Run the application, and click on the button to execute database table creation code. Close the application.</p>
<p><strong>11.</strong> In the Data Explorer right-click on "EMPLOYEE" database node and select "Refresh". When you expand "Tables" node you should see newly created database table. If you right-click on the new table and select "Alter Table" you should see the metadata information about the new table.</p>
<p><img src="http://bdntv.borland.com/pix/pawelglowacki/20080227/dbxmeta_alter.PNG" /></p>
<p><strong>CONGRATULATIONS!</strong> You have just created the first database table in code with the new RAD Studio 2007 DBX4 Metadata classes. The complete project source code is available for download from <a href="http://cc.codegear.com/item/25432">CodeGear </a><a href="http://cc.codegear.com/item/25432">Developer Network CodeCentral.</a></p>
<hr />One of the nicest things about Delphi since its first release is availability of Delphi VCL source code. DBX4 is not different and it comes with the source code. DBX4 is written in very elegant pure Delphi code, with very useful embedded XMLDocumentation Comments, and most interestingly it is <a href="http://blogs.codegear.com/steveshaughnessy/2007/02/16/31865"><strong>single sourced</strong></a>, which means that the same Delphi source was compiled with either the native <em>dcc32</em> or managed <em>dccil</em> compilers.In order to be able to step into the VCL DBX4 source code from within our project we need to add "C:\Program Files\CodeGear\RAD Studio\5.0\source\database\src\pas\dbx\metadata" directory to search path of the project in "Project Options".</p>
<p><img src="http://bdntv.borland.com/pix/pawelglowacki/20080227/dbxmeta_projoptions.PNG" /></p>
<p>If you now press "Ctrl" button and move mouse over "DBXMetaDataProvider" in "uses" clause</p>
<p><img src="http://bdntv.borland.com/pix/pawelglowacki/20080227/dbxmeta_navig.PNG" /></p>
<p>you will be able to step into the VCL DBX source code where types used in "dbxutils" unit are defined.</p>
<p><img src="http://bdntv.borland.com/pix/pawelglowacki/20080227/dbxmeta_stepin.PNG" /></p>
<p>The "DBXMetaDataProvider" unit defines a number of interesting classes</p>
<ul>
<li>TDBXMetaDataProvider</li>
<li>TDBXMetaDataTable</li>
<li>TDBXMetaDataColumn</li>
<li>TDBXMetaDataIndex</li>
<li>TDBXMetaDataForeignKey</li>
</ul>
<p>that can be used to programmatically created tables with indices and foreign keys in code. There is also a number of different convenience classes derived from "TDBXMetaDataColumn" that makes it easy to define columns of certain type. They contain a constructor only, so in reality you will be probably using properties of the base class to define different aspects of the database table column, like for example "AutoIncrement" or "Nullable".</p>
<ul>
<li>TDBXInt8Column</li>
<li>TDBXInt64Column</li>
<li>TDBXInt32Column</li>
<li>TDBXInt16Column</li>
<li>TDBXDoubleColumn</li>
<li>TDBXDecimalColumn</li>
<li>TDBXDateColumn</li>
<li>TDBXBooleanColumn</li>
<li>TDBXBinaryLongColumn</li>
<li>TDBXBinaryColumn</li>
<li>TDBXAnsiVarCharColumn</li>
<li>TDBXAnsiLongColumn</li>
<li>TDBXAnsiCharColumn</li>
<li>TDBXObjectColumn</li>
<li>TDBXSingleColumn</li>
<li>TDBXTimeColumn</li>
<li>TDBXTimestampColumn</li>
<li>TDBXUInt16Column</li>
<li>TDBXUInt32Column</li>
<li>TDBXUInt64Column</li>
<li>TDBXUInt8Column</li>
<li>TDBXUnicodeCharColumn</li>
<li>TDBXUnicodeLongColumn</li>
<li>TDBXVarBinaryColumn</li>
<li>TDBXWideVarCharColumn</li>
</ul>
<p><strong>Summary</strong></p>
<p>In this example I&#8217;ve been using Delphi 2007 for .NET, but since RAD Studio 2007 <a href="http://dn.codegear.com/article/37442">December Update</a> it is also possibly to write a similar application in Delphi 2007 for Win32.</p>
<p>The complete project source code is available for download from <a href="http://cc.codegear.com/item/25432">CodeGear Developer Network CodeCentral</a>.</p>
<p class="akst_link"><a href="http://blogs.codegear.com/pawelglowacki/?p=38504&amp;akst_action=share-this"  title="Post to del.icio.us, etc." id="akst_link_38504" class="akst_share_link" rel="nofollow">Share This</a> | <a href="mailto:?subject=Creating%20database%20tables%20programmatically%20with%20Delphi%20DBX4%20metadata%20classes&body=Have you seen this? http%3A%2F%2Fblogs.codegear.com%2Fpawelglowacki%2F2008%2F02%2F28%2F38504" id="akst_email_38504" class="akst_share_email" rel="nofollow">Email this page to a friend</a></p>]]></content:encoded>
			<wfw:commentRss>http://blogs.codegear.com/pawelglowacki/2008/02/28/38504/feed</wfw:commentRss>
		</item>
		<item>
		<title>Delphi Webinars Today and Next Tuesday</title>
		<link>http://blogs.codegear.com/pawelglowacki/2008/02/05/38503</link>
		<comments>http://blogs.codegear.com/pawelglowacki/2008/02/05/38503#comments</comments>
		<pubDate>Tue, 05 Feb 2008 15:53:23 +0000</pubDate>
		<dc:creator>Pawel Glowacki</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.codegear.com/pawelglowacki/2008/02/05/38503</guid>
		<description><![CDATA[As promised during the two webinars that I gave today here are the links to download presentations. I&#8217;m really happy to attract so many Delphi developers online:-) There were 69 programmers in the morning, and 92 in the afternoon!
"What&#8217;s New in CodeGear RAD Studio 2007 for Delphi Programmers?"

CodeGear RAD Studio 2007 Overview
New Language Features
DBX4 Architecture
Blackfish [...]]]></description>
			<content:encoded><![CDATA[<p>As promised during the two webinars that I gave today here are the links to download presentations. I&#8217;m really happy to attract so many Delphi developers online:-) There were 69 programmers in the morning, and 92 in the afternoon!</p>
<p><a href="http://bdntv.borland.com/pix/pawelglowacki/20080205/080205_Whats_New_in_RAD_Studio_2007_for_Delphi_Developers.pdf">"What&#8217;s New in CodeGear RAD Studio 2007 for Delphi Programmers?"</a></p>
<ul>
<li>CodeGear RAD Studio 2007 Overview</li>
<li>New Language Features</li>
<li>DBX4 Architecture</li>
<li>Blackfish SQL Database Engine</li>
<li>ASP.NET 2.0</li>
</ul>
<p><a href="http://bdntv.borland.com/pix/pawelglowacki/20080205/080205_Agile_Delphi_Techniques.pdf">"Agile Techniques for Building Quality into Delphi Applications"</a></p>
<ul>
<li>Introduction to Agile Programming</li>
<li>Unit Testing and Refactoring</li>
<li>Modelling and Design Patterns</li>
<li>Audits and Metrics</li>
</ul>
<p>The list of all CodeGear webinars planned for coming weeks is avaiable on the <a href="http://www.codegear-events.eu/">CodeGear European Event Calendar</a> page. See You on <a href="http://borland.interwis%3c/ul%3E%3Cp%3Ee.com/borland/iClass/KG4333/">"Effective DBX4 Database Programming"</a> and <a href="http://borland.interwise.com/borland/iClass/AB1820/">"Advanced DBX4 Database Architecture"</a> webinars next Tuesday same time (11am and 3pm CET).</p>
<p class="akst_link"><a href="http://blogs.codegear.com/pawelglowacki/?p=38503&amp;akst_action=share-this"  title="Post to del.icio.us, etc." id="akst_link_38503" class="akst_share_link" rel="nofollow">Share This</a> | <a href="mailto:?subject=Delphi%20Webinars%20Today%20and%20Next%20Tuesday&body=Have you seen this? http%3A%2F%2Fblogs.codegear.com%2Fpawelglowacki%2F2008%2F02%2F05%2F38503" id="akst_email_38503" class="akst_share_email" rel="nofollow">Email this page to a friend</a></p>]]></content:encoded>
			<wfw:commentRss>http://blogs.codegear.com/pawelglowacki/2008/02/05/38503/feed</wfw:commentRss>
		</item>
		<item>
		<title>My Delphi EMEA Webinars in Q1</title>
		<link>http://blogs.codegear.com/pawelglowacki/2008/01/09/38502</link>
		<comments>http://blogs.codegear.com/pawelglowacki/2008/01/09/38502#comments</comments>
		<pubDate>Wed, 09 Jan 2008 10:03:01 +0000</pubDate>
		<dc:creator>Pawel Glowacki</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.codegear.com/pawelglowacki/2008/01/09/38502</guid>
		<description><![CDATA[CodeGear in Europe is busy scheduling live seminars and regular free webinars. There is a number of sessions given by many experts on different subjects in different languages. If you have not yet visited the "CodeGear European Event Calendar" page, make sure to do it now and register for a webinar or two.
I will be [...]]]></description>
			<content:encoded><![CDATA[<p>CodeGear in Europe is busy scheduling live seminars and regular free webinars. There is a number of sessions given by many experts on different subjects in different languages. If you have not yet visited the <a href="http://www.codegear-events.eu/">"CodeGear European Event Calendar"</a> page, make sure to do it now and register for a webinar or two.</p>
<p>I will be hosting 10 Delphi webinars almost every Tuesday at 11AM and 3PM.</p>
<p>This time the focus is on database development and software quality.</p>
<ul>
<li><a href="http://borland.interwise.com/borland/iClass/MR4643/">What&#8217;s New in RAD Studio 2007 for Delphi Developers?</a></li>
<li><a href="http://borland.interwise.com/borland/iClass/PM1063/">DBX4 for BDE Developers</a></li>
<li><a href="http://borland.interwise.com/borland/iClass/XV7794/">Agile techniques for building quality into Delphi applications</a></li>
<li><a href="http://borland.interwise.com/borland/iClass/KG4333/">Effective DBX4 database architecture programming</a></li>
<li><a href="http://borland.interwise.com/borland/iClass/AB1820/">Advanced DBX4 database architecture</a></li>
<li><a href="http://borland.interwise.com/borland/iClass/PT2533/">Database Part I : Unleash the power of ClientDataSet</a></li>
<li><a href="http://borland.interwise.com/borland/iClass/RT5680/">Database Part II : ClientDataSet use in disconnected multi-tier applications</a></li>
</ul>
<p>All webinars are free, but you need to register first. All webinars are in InterWise iClass format. The calendar with all CodeGear European Events is available <a href="http://www.codegear-events.eu/">here</a>.</p>
<p class="akst_link"><a href="http://blogs.codegear.com/pawelglowacki/?p=38502&amp;akst_action=share-this"  title="Post to del.icio.us, etc." id="akst_link_38502" class="akst_share_link" rel="nofollow">Share This</a> | <a href="mailto:?subject=My%20Delphi%20EMEA%20Webinars%20in%20Q1&body=Have you seen this? http%3A%2F%2Fblogs.codegear.com%2Fpawelglowacki%2F2008%2F01%2F09%2F38502" id="akst_email_38502" class="akst_share_email" rel="nofollow">Email this page to a friend</a></p>]]></content:encoded>
			<wfw:commentRss>http://blogs.codegear.com/pawelglowacki/2008/01/09/38502/feed</wfw:commentRss>
		</item>
		<item>
		<title>3D Programming with Delphi for .NET and WPF</title>
		<link>http://blogs.codegear.com/pawelglowacki/2007/12/18/38501</link>
		<comments>http://blogs.codegear.com/pawelglowacki/2007/12/18/38501#comments</comments>
		<pubDate>Tue, 18 Dec 2007 21:36:40 +0000</pubDate>
		<dc:creator>Pawel Glowacki</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.codegear.com/pawelglowacki/2007/12/18/38501</guid>
		<description><![CDATA[Note: Make sure to install RAD Studio 2007 December Update before trying to compile this code. If you are on XP, make sure you have .NET 3.0 or 3.5 installed. 
Do you know Charles Petzold? Yes. He is the one who authored classical "Programming Windows" book back in eighties. Last year Petzold wrote a very [...]]]></description>
			<content:encoded><![CDATA[<p><em><strong>Note: </strong>Make sure to install RAD Studio 2007 December Update before trying to compile this code. If you are on XP, make sure you have .NET 3.0 or 3.5 installed. </em></p>
<p>Do you know Charles Petzold? Yes. He is the one who authored classical "Programming Windows" book back in eighties. Last year Petzold wrote a very good guide to WPF programming under intriguing title <a href="http://www.charlespetzold.com/wpf/index.html">"Applications = Code + Markup"</a>, which is a very obvious reference to another classical book written in 1975 by creator of <a href="http://en.wikipedia.org/wiki/Pascal_%28programming_language%29">Pascal</a> programming language <a href="http://en.wikipedia.org/wiki/Niklaus_Wirth">Niklas Wirth</a> "Algorithms + Data Structures = Programs".<br />
When I heard that Petzold is writing a book on <a href="http://www.charlespetzold.com/3D/index.html">"3D Programming for Windows"</a>, I knew that I needed to have this book on my bookshelf.</p>
<p><img src="http://bdntv.borland.com/pix/pawelglowacki/20071218/Petzold_3D_small.png" /></p>
<p>I was studying 3D visualization algorithms in <a href="http://www.pw.edu.pl/english/">Warsaw University of Technology</a>, so <a href="http://en.wikipedia.org/wiki/Quaternion">quaternions</a>, matrices and this type of mathematics do not scare me. Quite contrary I like it a lot. When operator overloading was introduced in Delphi 2006 for Win32 compiler, my first thought was to implement basic operations for quaternions like "add" and "subtract". At the end quaternions are just plain 4-D vectors, that happened to be very useful representations of arbitrary rotations in 3-D space.</p>
<p>Windows Presentation Foundation comes with the impressive number of specialized types for advanced 3D programming.<br />
I like to think about these classes as a kind of standardization for abstractions used in 3D graphics.</p>
<p><strong>Delphi for .NET Simple Scene in Code</strong></p>
<p>"3D Programming for Windows" contains many useful <a href="http://www.microsoft.com/mspress/companion/9780735623941/">examples</a> of code, and I thought it would be fun to translate one of them to Delphi for .NET. I have decided to implement "Simple Scene In Code" example, that contains a simple scene with just one triangle, camera and a combo box to change the position of the camera and look at the triangle from different angles.</p>
<p><img src="http://bdntv.borland.com/pix/pawelglowacki/20071218/DelphiNetSimple3DSceneInCode1.PNG" /><br />
<img src="http://bdntv.borland.com/pix/pawelglowacki/20071218/DelphiNetSimple3DSceneInCode2.PNG" /></p>
<p>The steps to get started with Delphi for .NET WPF application were outlined in <a href="http://blogs.codegear.com/pawelglowacki/2007/10/29/38498">my post on template libraries</a> a few weeks ago. In principle you need to create a new Delphi for .NET Console Application project, and add project references to .NET assemblies where WPF types are implemented. From this point it just a matter of adding correct namespace to "uses" clauses of your Delphi units and you should be up and running.</p>
<p>The program file looks like this:</p>
<pre>
<strong>program</strong> DelphiSimpleSceneInCode;      

<em>// {$APPTYPE CONSOLE}</em>      

<strong>uses</strong>
  System.Windows,
  uFormMain in &#8216;uFormMain.pas&#8217;;      

<strong>var</strong>
  app: Application;      

[STAThread]
<strong>begin</strong>
  <strong>try</strong>
    app := Application.Create;
    app.Run(TFormMain.Create);      

  <strong>except</strong>
    <strong>on</strong> E:Exception <strong>do</strong>
    <strong>begin</strong>
      Writeln(E.Classname, &#8216;: &#8216;, E.Message);
      Readln;
    <strong>end</strong>;
  <strong>end</strong>;
end.</pre>
<p>Note that I have commented out the {$APPTYPE CONSOLE} directive, so the console window is not displayed.</p>
<p>The main program functionality is implemented inside the "TFormMain" class that represents the main window of my application. Below is the implementation of the "TFormMain" class.</p>
<pre>
<strong>unit</strong> uFormMain;      

<strong>interface</strong>      

<strong>uses</strong>
  System.Windows,
  System.Windows.Controls,
  System.Windows.Controls.Primitives,
  System.Windows.Media,
  System.Windows.Media.Media3D;      

<strong>type</strong>
  TFormMain = <strong>class</strong>(Window)
  <strong>strict private</strong>
    FCam: PerspectiveCamera;
    <strong>procedure</strong> ScrollBarOnValueChanged(Sender: TObject;
      args: RoutedPropertyChangedEventArgs);
  <strong>public</strong>
    <strong>constructor</strong> Create;
    <strong>destructor</strong> Destroy; <strong>override</strong>;
  <strong>end</strong>;      

<strong>implementation</strong>      

<em>{ TFormMain }</em>      

<strong>constructor</strong> TFormMain.Create;
<strong>var</strong>
  dock: DockPanel;
  scroll: ScrollBar;
  viewport: Viewport3D;
  mesh: MeshGeometry3D;
  indices: Int32Collection;
  geomod: GeometryModel3D;
  modvis: ModelVisual3D;      

<strong>begin</strong>
  <strong>inherited</strong> Create;      

  self.Title := &#8216;Delphi for .NET Simple 3D Scene in Code&#8217;;      

<em>  // Make DockPanel content of window.</em>
  dock := DockPanel.Create;
  self.Content := dock;      

<em>  // Create Scrollbar for moving camera.</em>
  scroll := ScrollBar.Create;
  scroll.Orientation := Orientation.Horizontal;
  scroll.Value := -2;
  scroll.Minimum := -2;
  scroll.Maximum := 2;      

  Include(scroll.ValueChanged, ScrollBarOnValueChanged);      

  dock.Children.Add(scroll);
  DockPanel.SetDock(scroll, System.Windows.Controls.Dock.Bottom);      

<em>  // Create Viewport3D for 3D scene.</em>
  viewport := Viewport3D.Create;
  dock.Children.Add(viewport);      

<em>  // Define the MeshGeometry3D.</em>
  mesh := MeshGeometry3D.Create;
  mesh.Positions.Add(Point3D.Create(0, 0, 0));
  mesh.Positions.Add(Point3D.Create(0, 1, -1));
  mesh.Positions.Add(Point3D.Create(0, 0, -2));
  indices := Int32Collection.Create;
  indices.Add(0);
  indices.Add(1);
  indices.Add(2);
  mesh.TriangleIndices := indices;      

<em>  // Define the GeometryModel3D.</em>
  geomod := GeometryModel3D.Create;
  geomod.Geometry := mesh;
  geomod.Material := DiffuseMaterial.Create(Brushes.Cyan);
  geomod.BackMaterial := DiffuseMaterial.Create(Brushes.Red);      

<em>  // Create ModelVisual3D for GeometryModel3D.</em>
  modvis := ModelVisual3D.Create;
  modvis.Content := geomod;
  viewport.Children.Add(modvis);      

<em>  // Create another ModelVisual3D for light.</em>
  modvis := ModelVisual3D.Create;
  modvis.Content := AmbientLight.Create(Colors.White);
  viewport.Children.Add(modvis);      

<em>  // Create the camera.</em>
  FCam := PerspectiveCamera.Create(
    Point3D.Create(-2,0,5),
    Vector3D.Create(0, 0, -1),
    Vector3D.Create(0, 1, 0),
    45);      

  viewport.Camera := FCam;
<strong>end</strong>;      

<strong>destructor</strong> TFormMain.Destroy;
<strong>begin</strong>
  <strong>inherited</strong>;
<strong>end</strong>;      

<strong>procedure</strong> TFormMain.ScrollBarOnValueChanged(Sender: TObject;
  args: RoutedPropertyChangedEventArgs);
<strong>begin</strong>
  FCam.Position := Point3D.Create(args.NewValue, 0, 5);
<strong>end</strong>;      

<strong>end</strong>.</pre>
<p>Translating c# code to Delphi for .NET is very straightforward, however there are certain things you need to know. For example syntax for adding event handlers to events. .NET features multicast event handlers. This is different as compared to traditional Delphi for Win32 programs that sport singlecast events. In c# to add "ScrollBarOnValueChanged" event handler to "ValueChanged" event of the combobox overloaded "+=" operator is used. Delphi uses "Include" and "Exclude" standard routines to respectively add and remove an event handler from an event.</p>
<p>The source code for this post can be downloaded from <a href="http://cc.codegear.com/item/25362">CodeCentral</a>. </p>
<p><img src="http://bdntv.borland.com/pix/pawelglowacki/20071218/PoweredByDelphiSmall.png" /></p>
<p>Happy 3D coding:-)</p>
<p>Merry Christmas and a Happy New Year for all of You!</p>
<p class="akst_link"><a href="http://blogs.codegear.com/pawelglowacki/?p=38501&amp;akst_action=share-this"  title="Post to del.icio.us, etc." id="akst_link_38501" class="akst_share_link" rel="nofollow">Share This</a> | <a href="mailto:?subject=3D%20Programming%20with%20Delphi%20for%20.NET%20and%20WPF&body=Have you seen this? http%3A%2F%2Fblogs.codegear.com%2Fpawelglowacki%2F2007%2F12%2F18%2F38501" id="akst_email_38501" class="akst_share_email" rel="nofollow">Email this page to a friend</a></p>]]></content:encoded>
			<wfw:commentRss>http://blogs.codegear.com/pawelglowacki/2007/12/18/38501/feed</wfw:commentRss>
		</item>
		<item>
		<title>My CodeRage II Session: 10 Top Things Added to Delphi Since Delphi 7</title>
		<link>http://blogs.codegear.com/pawelglowacki/2007/11/26/38500</link>
		<comments>http://blogs.codegear.com/pawelglowacki/2007/11/26/38500#comments</comments>
		<pubDate>Mon, 26 Nov 2007 18:02:15 +0000</pubDate>
		<dc:creator>Pawel Glowacki</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.codegear.com/pawelglowacki/2007/11/26/38500</guid>
		<description><![CDATA[I&#8217;m sitting right now in the Schiphol airport, and my CodeRage II session is just about to start&#8230; I need to be ready for Q&#38;A session in an hour or so. Do not worry if you hear flight information in your headphones;-)
First of all it is my personal and subjective list, and second - english [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sitting right now in the Schiphol airport, and my CodeRage II session is just about to start&#8230; I need to be ready for Q&amp;A session in an hour or so. Do not worry if you hear flight information in your headphones;-)</p>
<p>First of all it is my personal and subjective list, and second - english is not my native language so I hope that you would like the session anyway:-)</p>
<p>The written version of my <strong><a href="http://dn.codegear.com/article/37416">"Leveraging What You Have: 10 Top Things Added to Delphi Since Delphi 7"</a></strong> is available as an article on the CodeGear Developer Network.</p>
<p>264 people at the CodeRage II at this moment in the InterWise room. Cool!</p>
<p class="akst_link"><a href="http://blogs.codegear.com/pawelglowacki/?p=38500&amp;akst_action=share-this"  title="Post to del.icio.us, etc." id="akst_link_38500" class="akst_share_link" rel="nofollow">Share This</a> | <a href="mailto:?subject=My%20CodeRage%20II%20Session%3A%2010%20Top%20Things%20Added%20to%20Delphi%20Since%20Delphi%207&body=Have you seen this? http%3A%2F%2Fblogs.codegear.com%2Fpawelglowacki%2F2007%2F11%2F26%2F38500" id="akst_email_38500" class="akst_share_email" rel="nofollow">Email this page to a friend</a></p>]]></content:encoded>
			<wfw:commentRss>http://blogs.codegear.com/pawelglowacki/2007/11/26/38500/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
