<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The curse of Dennis D. Spreen &#187; Delphi Programming</title>
	<atom:link href="http://www.spreendigital.de/blog/tag/delphi/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.spreendigital.de/blog</link>
	<description>A blog about Delphi programming, web and other technical stuff</description>
	<lastBuildDate>Fri, 26 Mar 2010 08:35:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Lua 5.1 for Delphi 2010</title>
		<link>http://www.spreendigital.de/blog/2009/09/28/lua-5-1-for-delphi-2010/</link>
		<comments>http://www.spreendigital.de/blog/2009/09/28/lua-5-1-for-delphi-2010/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 18:36:18 +0000</pubDate>
		<dc:creator>Dennis Spreen</dc:creator>
				<category><![CDATA[Delphi 2009]]></category>
		<category><![CDATA[Delphi 2010]]></category>
		<category><![CDATA[Delphi Programming]]></category>
		<category><![CDATA[Lua]]></category>

		<guid isPermaLink="false">http://www.spreendigital.de/blog/?p=375</guid>
		<description><![CDATA[This is a Lua 5.1 Wrapper for Delphi 2009 and Delphi 2010 which automatically creates OOP callback functions.

&#8220;Lua is a powerful, fast, lightweight, embeddable scripting language, it has been used in many industrial applications (e.g., Adobe&#8217;s Photoshop Lightroom), with an emphasis on embedded systems (e.g., the Ginga middleware for digital TV in Brazil) and games [...]]]></description>
			<content:encoded><![CDATA[<p>This is a Lua 5.1 Wrapper for Delphi 2009 and Delphi 2010 which automatically creates OOP callback functions.<br />
<span id="more-375"></span><a href="http://www.lua.org/about.html" target="_blank"><br />
<em>&#8220;Lua</em></a><em> is a powerful, fast, lightweight, embeddable scripting language, it has been used in many industrial applications (e.g., Adobe&#8217;s Photoshop Lightroom), with an emphasis on embedded systems (e.g., the Ginga middleware for digital TV in Brazil) and games (e.g., World of Warcraft). Lua is currently the leading scripting language in games and it has a deserved reputation for performance. To claim to be &#8220;as fast as Lua&#8221; is an aspiration of other scripting languages.&#8221;</em></p>
<p>This Lua Wrapper is based on Lua-Pascal v0.2 by <a href="http://www.marcoabreu.eti.br" target="_blank">Marco Antonio Abreu</a><br />
- converted PChar to PAnsiChar<br />
- converted Char to AnsiChar<br />
- added function LuaLibLoaded: Boolean;<br />
- added a new base class (TLua) with OOP call back functions</p>
<p><strong>Download</strong><br />
<a href="http://www.spreendigital.de/blog/wp-content/uploads/2009/09/LuaDelphi2010-v1.2.zip"></a><a href="http://www.spreendigital.de/blog/wp-content/uploads/2009/10/LuaDelphi2010-v1.3.zip">LuaDelphi2010-v1.3</a></p>
<p><strong>History</strong><br />
1.3 Improved Callback, now uses pointer instead of object index. Modified RegisterFunctions to allow methods from other class to be registered, moved object table into TLua class<br />
1.2  Added example on how to extend lua with a delphi dll<br />
1.1  Improved global object table, optimized delphi function calls<br />
1.0  Initial Release</p>
<p><strong>Example</strong><br />
TLua automatically creates OOP callback functions for Delphi &lt;-&gt; Lua:</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">uses</span>
  Lua<span style="color: #000066;">,</span> LuaLib<span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">type</span>
  TMyLua <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #000066;">&#40;</span>TLua<span style="color: #000066;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">published</span>
    <span style="color: #000000; font-weight: bold;">function</span> HelloWorld<span style="color: #000066;">&#40;</span>LuaState<span style="color: #000066;">:</span> TLuaState<span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> TMyLua<span style="color: #000066;">.</span><span style="color: #006600;">HelloWorld</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">var</span>
  ArgCount<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span><span style="color: #000066;">;</span>
  I<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">integer</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #000066;">writeln</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Delphi: Hello World'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
  ArgCount <span style="color: #000066;">:</span><span style="color: #000066;">=</span> Lua_GetTop<span style="color: #000066;">&#40;</span>LuaState<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #000066;">writeln</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Arguments: '</span><span style="color: #000066;">,</span> ArgCount<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">for</span> I <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">1</span> <span style="color: #000000; font-weight: bold;">to</span> ArgCount <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #000066;">writeln</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Arg1'</span><span style="color: #000066;">,</span> I<span style="color: #000066;">,</span> <span style="color: #ff0000;">': '</span><span style="color: #000066;">,</span> Lua_ToInteger<span style="color: #000066;">&#40;</span>LuaState<span style="color: #000066;">,</span> I<span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">// Clear stack</span>
  Lua_Pop<span style="color: #000066;">&#40;</span>LuaState<span style="color: #000066;">,</span> Lua_GetTop<span style="color: #000066;">&#40;</span>LuaState<span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">// Push return values</span>
  Lua_PushInteger<span style="color: #000066;">&#40;</span>LuaState<span style="color: #000066;">,</span> <span style="color: #0000ff;">101</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  Lua_PushInteger<span style="color: #000066;">&#40;</span>LuaState<span style="color: #000066;">,</span> <span style="color: #0000ff;">102</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">2</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span>
  MyLua<span style="color: #000066;">:</span> TLua<span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">begin</span>
  MyLua <span style="color: #000066;">:</span><span style="color: #000066;">=</span> TMyLua<span style="color: #000066;">.</span><span style="color: #006600;">Create</span><span style="color: #000066;">;</span>
  MyLua<span style="color: #000066;">.</span><span style="color: #006600;">DoFile</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Helloworld.lua'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  MyLua<span style="color: #000066;">.</span><span style="color: #006600;">Free</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></pre></div></div>

<p><em>helloworld.lua</em></p>

<div class="wp_syntax"><div class="code"><pre class="lua" style="font-family:monospace;"><span style="color: #b1b100;">print</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;LuaDelphi Test&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
p1,p2 <span style="color: #66cc66;">=</span> HelloWorld<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #b1b100;">print</span> <span style="color: #ff0000;">&quot;Results:&quot;</span><span style="color: #66cc66;">;</span>
<span style="color: #b1b100;">print</span> <span style="color: #66cc66;">&#40;</span>p1<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #b1b100;">print</span> <span style="color: #66cc66;">&#40;</span>p2<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.spreendigital.de/blog/2009/09/28/lua-5-1-for-delphi-2010/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Delphi Prism new language features</title>
		<link>http://www.spreendigital.de/blog/2008/11/21/delphi-prism-new-language-features/</link>
		<comments>http://www.spreendigital.de/blog/2008/11/21/delphi-prism-new-language-features/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 15:38:05 +0000</pubDate>
		<dc:creator>Dennis Spreen</dc:creator>
				<category><![CDATA[Delphi Prism]]></category>
		<category><![CDATA[Delphi Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[Object-oriented programming]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[Prism]]></category>

		<guid isPermaLink="false">http://www.spreendigital.de/blog/?p=84</guid>
		<description><![CDATA[Andreano Lanusse wrote about the new Delphi Prism language features compared to Delphi Win32.
Some of them I really would like to see in Delphi Win32 and some I don&#8217;t like and disallowed it in our internal code creation rules. The most important I dislike is

&#8220;Variable everywhere and create a instance at the same time you [...]]]></description>
			<content:encoded><![CDATA[<p>Andreano Lanusse <a href="http://blogs.codegear.com/andreanolanusse/2008/11/19/delphi-prism-language-what-you-can-do/" target="_blank">wrote</a> about the new Delphi Prism language features compared to Delphi Win32.</p>
<p>Some of them I really would like to see in Delphi Win32 and some I don&#8217;t like and disallowed it in our internal code creation rules. The most important I dislike is</p>
<p><span id="more-84"></span></p>
<p>&#8220;Variable everywhere and create a instance at the same time you declare.&#8221;</p>
<pre><strong>var</strong>
  path : String := System.IO.Path.GetFullPath(tbDatabase.Text);
  db : DataContext := new DataContext(path);
<strong>begin</strong>
  var i : Integer := 0;
  var contacts := from contact in db.GetTable&lt;Contact&gt;() select contact;
<strong>end.</strong></pre>
<p>Looks awkful to me (like VB). This is the code written by our long term code creation rules:</p>
<p style="padding-left: 30px;">
<pre><strong>var</strong>
  Path: String;
  Db: DataContext;
  I: Integer := 0;
<strong>begin</strong>
  Path := System.IO.Path.GetFullPath(tbDatabase.Text);
  Db := new DataContext(Path);
  Contacts := from contact in db.GetTable&lt;Contact&gt;() select contact;
<strong>end;

</strong></pre>
<p>I like the separation from var declaration and code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.spreendigital.de/blog/2008/11/21/delphi-prism-new-language-features/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Unicode in Resource files</title>
		<link>http://www.spreendigital.de/blog/2008/10/14/unicode-in-resource-files/</link>
		<comments>http://www.spreendigital.de/blog/2008/10/14/unicode-in-resource-files/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 15:20:22 +0000</pubDate>
		<dc:creator>Dennis Spreen</dc:creator>
				<category><![CDATA[Delphi 2009]]></category>
		<category><![CDATA[Delphi Programming]]></category>
		<category><![CDATA[Resource]]></category>
		<category><![CDATA[String]]></category>
		<category><![CDATA[Unicode]]></category>

		<guid isPermaLink="false">http://www.spreendigital.de/blog/?p=79</guid>
		<description><![CDATA[Ever tried to put a unicode string (Delphi 2009) in a resource (.rc) file and tried to compile it with brcc32 or rc32?
You&#8217;ll get this error:  Expecting resource name or resource type name
The Solution is very simple (though it kept me searching some hours  :

Use
cgrc.exe
(CodeGear Resource Compiler/Binder) instead!
]]></description>
			<content:encoded><![CDATA[<p>Ever tried to put a unicode string (Delphi 2009) in a resource (.rc) file and tried to compile it with brcc32 or rc32?</p>
<p>You&#8217;ll get this error:  Expecting resource name or resource type name</p>
<p>The Solution is very simple (though it kept me searching some hours <img src='http://www.spreendigital.de/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> :</p>
<p><span id="more-79"></span></p>
<p>Use</p>
<p><code>cgrc.exe</code></p>
<p>(CodeGear Resource Compiler/Binder) instead!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.spreendigital.de/blog/2008/10/14/unicode-in-resource-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Right To Left Forms support</title>
		<link>http://www.spreendigital.de/blog/2008/02/12/right-to-left-forms-support/</link>
		<comments>http://www.spreendigital.de/blog/2008/02/12/right-to-left-forms-support/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 15:49:06 +0000</pubDate>
		<dc:creator>Dennis Spreen</dc:creator>
				<category><![CDATA[Delphi Programming]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[arabic]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[RTL]]></category>

		<guid isPermaLink="false">http://www.spreendigital.de/blog/?p=98</guid>
		<description><![CDATA[How to enable Right To Left Forms (including icons and form captions) with Delphi:
 Override the CreateParams method and insert
procedure TForm1.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.ExStyle := Params.ExStyle or WS_EX_LEFT or WS_EX_RTLREADING or
    WS_EX_LEFTSCROLLBAR or WS_EX_LAYOUTRTL or WS_EX_NOINHERITLAYOUT;
end;
Now take a look at your BiDiMode settings &#8211; it may have the contrary effect [...]]]></description>
			<content:encoded><![CDATA[<p>How to enable Right To Left Forms (including icons and form captions) with Delphi:</p>
<p><span id="more-98"></span> Override the CreateParams method and insert</p>
<pre>procedure TForm1.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.ExStyle := Params.ExStyle or WS_EX_LEFT or WS_EX_RTLREADING or
    WS_EX_LEFTSCROLLBAR or WS_EX_LAYOUTRTL or WS_EX_NOINHERITLAYOUT;
end;</pre>
<p>Now take a look at your BiDiMode settings &#8211; it may have the contrary effect if set to &#8220;bdRightToLeft&#8221;&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.spreendigital.de/blog/2008/02/12/right-to-left-forms-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OnClick Event in TTreeView Objects</title>
		<link>http://www.spreendigital.de/blog/2007/06/10/onclick-event-in-ttreeview-objects/</link>
		<comments>http://www.spreendigital.de/blog/2007/06/10/onclick-event-in-ttreeview-objects/#comments</comments>
		<pubDate>Sun, 10 Jun 2007 14:23:49 +0000</pubDate>
		<dc:creator>Dennis Spreen</dc:creator>
				<category><![CDATA[Delphi Programming]]></category>
		<category><![CDATA[Delphi for PHP]]></category>
		<category><![CDATA[Event]]></category>
		<category><![CDATA[OnClick]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[TreeView]]></category>
		<category><![CDATA[TTreeview]]></category>

		<guid isPermaLink="false">http://www.spreendigital.de/blog/?p=60</guid>
		<description><![CDATA[This code returns the TAG of a clicked node in Delphi for PHP


function TreeView1JSClick($sender, $params)
{
?&#62;
//Add your javascript code here
tag=event.getTarget().tag;
alert(tag);
return(false);
&#60;?php
}
]]></description>
			<content:encoded><![CDATA[<p>This code returns the TAG of a clicked node in Delphi for PHP</p>
<p><span id="more-60"></span></p>
<p><code><br />
</code>function TreeView1JSClick($sender, $params)<br />
{</p>
<p>?&gt;<br />
//Add your javascript code here<br />
tag=event.getTarget().tag;<br />
alert(tag);</p>
<p>return(false);<br />
&lt;?php<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://www.spreendigital.de/blog/2007/06/10/onclick-event-in-ttreeview-objects/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
