<?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>GSaraiva&#039;s Projects &#187; articles</title>
	<atom:link href="http://projects.pro.br/gsaraiva/category/articles/feed/" rel="self" type="application/rss+xml" />
	<link>http://projects.pro.br/gsaraiva</link>
	<description>Step by step</description>
	<lastBuildDate>Tue, 01 Sep 2009 13:14:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Delphi: Utils :: AppRunningCount</title>
		<link>http://projects.pro.br/gsaraiva/2009/07/delphi-utils-apprunningcount/</link>
		<comments>http://projects.pro.br/gsaraiva/2009/07/delphi-utils-apprunningcount/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 20:13:38 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[AppRunningCount]]></category>
		<category><![CDATA[CreateToolhelp32Snapshot]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Process32First]]></category>
		<category><![CDATA[Process32Next]]></category>
		<category><![CDATA[TH32CS_SNAPPROCESS]]></category>
		<category><![CDATA[TProcessEntry32]]></category>
		<category><![CDATA[Usefull Function]]></category>

		<guid isPermaLink="false">http://projects.pro.br/gsaraiva/?p=470</guid>
		<description><![CDATA[Folks,
For everybody thats need to limit the instance number of your application:
uses SysUtils, TLHelp32;&#160;function AppRunningCount&#40;const AExeName: string&#41;: integer;var&#160;&#160;hSnap: THandle;&#160;&#160;p32: TProcessEntry32;begin&#160;&#160;Result := 0;&#160;&#160;hSnap := CreateToolHelp32SnapShot&#40;TH32CS_SNAPPROCESS, 0&#41;;&#160;&#160;p32.dwSize := Sizeof&#40;TProcessEntry32&#41;;&#160;&#160;Process32First&#40;hSnap, p32&#41;;&#160;&#160;repeat&#160;&#160;&#160;&#160;if SameText&#40;AExeName, ExtractFileName&#40;p32.szExeFile&#41;&#41; then&#160;&#160;&#160;&#160;&#160;&#160;inc&#40;Result&#41;;&#160;&#160;until not Process32Next&#40;hSnap, p32&#41;;&#160;&#160;CloseHandle&#40;hSnap&#41;;end;
Use:
// On DPR// Limit to 1 instancebegin &#160;&#160;if AppRunningCount&#40;ExtractFileName&#40;ParamStr&#40;0&#41;&#41;&#41; = 1 then&#160;&#160;begin&#160;&#160;// Application codes&#160;&#160;end;end.
Explaining more about this approach:
In a situation of multiples [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Folks,</strong></p>
<p>For everybody thats need to limit the instance number of your application:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">uses</span> SysUtils<span style="color: #000066;">,</span> TLHelp32<span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> AppRunningCount<span style="color: #000066;">&#40;</span><span style="color: #000000; font-weight: bold;">const</span> AExeName<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><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></li><li><span style="color: #000000; font-weight: bold;">var</span></li><li>&nbsp;&nbsp;hSnap<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">THandle</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;p32<span style="color: #000066;">:</span> TProcessEntry32<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;hSnap <span style="color: #000066;">:</span><span style="color: #000066;">=</span> CreateToolHelp32SnapShot<span style="color: #000066;">&#40;</span>TH32CS_SNAPPROCESS<span style="color: #000066;">,</span> 0<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;p32<span style="color: #000066;">.</span><span style="color: #006600;">dwSize</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">Sizeof</span><span style="color: #000066;">&#40;</span>TProcessEntry32<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Process32First<span style="color: #000066;">&#40;</span>hSnap<span style="color: #000066;">,</span> p32<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">repeat</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000066;">SameText</span><span style="color: #000066;">&#40;</span>AExeName<span style="color: #000066;">,</span> <span style="color: #000066;">ExtractFileName</span><span style="color: #000066;">&#40;</span>p32<span style="color: #000066;">.</span><span style="color: #006600;">szExeFile</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">inc</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">until</span> <span style="color: #000000; font-weight: bold;">not</span> Process32Next<span style="color: #000066;">&#40;</span>hSnap<span style="color: #000066;">,</span> p32<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;CloseHandle<span style="color: #000066;">&#40;</span>hSnap<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Use:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #808080; font-style: italic;">// On DPR</span></li><li><span style="color: #808080; font-style: italic;">// Limit to 1 instance</span></li><li><span style="color: #000000; font-weight: bold;">begin</span> </li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> AppRunningCount<span style="color: #000066;">&#40;</span><span style="color: #000066;">ExtractFileName</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">ParamStr</span><span style="color: #000066;">&#40;</span>0<span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">=</span> 1 <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;<span style="color: #808080; font-style: italic;">// Application codes</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">.</span></li><li></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Explaining more about this approach:<br />
In a situation of multiples logons at the same machine the Mutex cannot provide a correctly singleton structure because the mutex handle still only under the local scope of the user. So the way to control the instance number is counting the number of times the process appear on the process list of the machine.</p>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2009/07/delphi-utils-apprunningcount/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi: Chained List</title>
		<link>http://projects.pro.br/gsaraiva/2009/06/delphi-chained-list/</link>
		<comments>http://projects.pro.br/gsaraiva/2009/06/delphi-chained-list/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 13:54:10 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[Chain List]]></category>
		<category><![CDATA[Chained list]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[TChainedList]]></category>

		<guid isPermaLink="false">http://gsaraiva.projects.pro.br/?p=418</guid>
		<description><![CDATA[Folks,
Some times when we need to hold stripped informations, like socket or audio buffers, we need to create a chained list that control all the information sequentially and provide a navigation on the holded data only by stepping forward(next) or stepping back(prior).
A structure of a Chained List is divided on 2 main variables: Data and [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Folks,</strong></p>
<p>Some times when we need to hold stripped informations, like socket or audio buffers, we need to create a chained list that control all the information sequentially and provide a navigation on the holded data only by stepping forward(next) or stepping back(prior).</p>
<p>A structure of a Chained List is divided on 2 main variables: Data and Next(or Prior, as needed), for every Item on the Chain you have the Data(Pointer, value or someting you have to hold) and a reference for the next or prior item on the list. Chained list don&#8217;t provide a direct access for items, so you can&#8217;t access a item without navigate on others. Chained Lists can be improved, but the main goal is provide a near infinite list that have the best performance of all others techniques.</p>
<p>As you know now, Chained lists don&#8217;t hold indexs for items (don&#8217;t have a direct access) and that avoid re-index procedures that consume a big time when you&#8217;ve a large list. When you need to remove a item in a Chained list that have a predecessor and a antecessor, you&#8217;ll have to make the first improvement on the chain structure to hold the Prior and the Next item for each Item you have, and thats provide you a confortable way to manipulate items without writing a lot of code and variables.</p>
<p><a href="http://gsaraiva.projects.pro.br/?p=417">A basic structure of a Chained List on Delphi</a></p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">uses</span> ChainedListCtrl<span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">type</span></li><li>&nbsp;&nbsp;TfrmMain <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #000066;">&#40;</span>TForm<span style="color: #000066;">&#41;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;edtWord<span style="color: #000066;">:</span> TEdit<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;btnAdd<span style="color: #000066;">:</span> TButton<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;lblPhrase<span style="color: #000066;">:</span> TLabel<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;btnClean<span style="color: #000066;">:</span> TButton<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">procedure</span> FormCreate<span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">procedure</span> FormDestroy<span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">procedure</span> btnAddClick<span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">procedure</span> btnCleanClick<span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">private</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #808080; font-style: italic;">{ Private declarations }</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Phrase<span style="color: #000066;">:</span> TChainedList<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">procedure</span> UpdateList<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">var</span></li><li>&nbsp;&nbsp;frmMain<span style="color: #000066;">:</span> TfrmMain<span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">implementation</span></li><li>&nbsp;</li><li><span style="color: #008000; font-style: italic;">{$R *.dfm}</span></li><li>&nbsp;</li><li><span style="color: #808080; font-style: italic;">{ Note: Create the Chain List Control Object</span></li><li><span style="color: #808080; font-style: italic;">}</span></li><li><span style="color: #000000; font-weight: bold;">procedure</span> TfrmMain<span style="color: #000066;">.</span><span style="color: #006600;">FormCreate</span><span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;Phrase <span style="color: #000066;">:</span><span style="color: #000066;">=</span> TChainedList<span style="color: #000066;">.</span><span style="color: #006600;">Create</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #808080; font-style: italic;">{ Note: Destroy the Chain Object</span></li><li><span style="color: #808080; font-style: italic;">}</span></li><li><span style="color: #000000; font-weight: bold;">procedure</span> TfrmMain<span style="color: #000066;">.</span><span style="color: #006600;">FormDestroy</span><span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;Phrase<span style="color: #000066;">.</span><span style="color: #006600;">Free</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #808080; font-style: italic;">{ Note: Update the Label to hold all the words</span></li><li><span style="color: #808080; font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; included on the Chained list</span></li><li><span style="color: #808080; font-style: italic;">}</span></li><li><span style="color: #000000; font-weight: bold;">procedure</span> TfrmMain<span style="color: #000066;">.</span><span style="color: #006600;">UpdateList</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">var</span></li><li>&nbsp;&nbsp;sPhrase<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;sPhrase <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #ff0000;">''</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Phrase<span style="color: #000066;">.</span><span style="color: #006600;">First</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">while</span> Phrase<span style="color: #000066;">.</span><span style="color: #006600;">Current</span> &lt;&gt; <span style="color: #000000; font-weight: bold;">nil</span> <span style="color: #000000; font-weight: bold;">do</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> sPhrase &lt;&gt; <span style="color: #ff0000;">''</span> <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sPhrase <span style="color: #000066;">:</span><span style="color: #000066;">=</span> sPhrase <span style="color: #000066;">+</span> <span style="color: #ff0000;">' '</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;sPhrase <span style="color: #000066;">:</span><span style="color: #000066;">=</span> sPhrase <span style="color: #000066;">+</span> <span style="color: #000066; font-weight: bold;">PChar</span><span style="color: #000066;">&#40;</span>Phrase<span style="color: #000066;">.</span><span style="color: #006600;">Current</span><span style="color: #000066;">^</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Phrase<span style="color: #000066;">.</span><span style="color: #006600;">Next</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;lblPhrase<span style="color: #000066;">.</span><span style="color: #006600;">Caption</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> sPhrase<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #808080; font-style: italic;">{ Note: Add the text on the Chain</span></li><li><span style="color: #808080; font-style: italic;">&nbsp;&nbsp;&nbsp;p.s: StrNew create a copy of the string that will be managed</span></li><li><span style="color: #808080; font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out of the garbage collector(str refcount structure)</span></li><li><span style="color: #808080; font-style: italic;">}</span></li><li><span style="color: #000000; font-weight: bold;">procedure</span> TfrmMain<span style="color: #000066;">.</span><span style="color: #006600;">btnAddClick</span><span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;Phrase<span style="color: #000066;">.</span><span style="color: #006600;">Add</span><span style="color: #000066;">.</span><span style="color: #006600;">Current</span><span style="color: #000066;">^</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">StrNew</span><span style="color: #000066;">&#40;</span><span style="color: #000066; font-weight: bold;">PChar</span><span style="color: #000066;">&#40;</span>edtWord<span style="color: #000066;">.</span><span style="color: #006600;">Text</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;UpdateList<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #808080; font-style: italic;">{ Note: Clean the Chain list</span></li><li><span style="color: #808080; font-style: italic;">&nbsp;&nbsp;&nbsp;p.s: StrDispose release the memory of the create string</span></li><li><span style="color: #808080; font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; to avoid memory leaks</span></li><li><span style="color: #808080; font-style: italic;">}</span></li><li><span style="color: #000000; font-weight: bold;">procedure</span> TfrmMain<span style="color: #000066;">.</span><span style="color: #006600;">btnCleanClick</span><span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;Phrase<span style="color: #000066;">.</span><span style="color: #006600;">Last</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">while</span> Phrase<span style="color: #000066;">.</span><span style="color: #006600;">Current</span> &lt;&gt; <span style="color: #000000; font-weight: bold;">nil</span> <span style="color: #000000; font-weight: bold;">do</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Phrase<span style="color: #000066;">.</span><span style="color: #006600;">Remove</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">@</span><span style="color: #000066;">StrDispose</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;UpdateList<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>I wrote some comments on the code to refers the goals of each method, but some things have to be said:<br />
  <strong>1st.</strong> Many improviments can be done on a Chained List, but some times a improvement can be bad to the performance result so keep it on the mind when you change some thing.<br />
  <strong>2nd.</strong> Chained List as the name says, chained, so don&#8217;t try to put a index control on it because can be a big mistake.<br />
  <strong>3rd.</strong> Use it when you need a great performance, not when you only need to hold some common data. A Indexed List control will be better and easy to manipulate then a Chained List.</p>
<p>Feel free to use and ask some thing.</p>
<p>Hugs for all</p>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2009/06/delphi-chained-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi: Utils :: TChainedList</title>
		<link>http://projects.pro.br/gsaraiva/2009/06/delphi-utils-tchainedlist/</link>
		<comments>http://projects.pro.br/gsaraiva/2009/06/delphi-utils-tchainedlist/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 13:54:08 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[Chain List]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[TChainedList]]></category>
		<category><![CDATA[Usefull functions]]></category>

		<guid isPermaLink="false">http://gsaraiva.projects.pro.br/?p=417</guid>
		<description><![CDATA[Folks,
For everybody thats use a lot Chained lists on your projects:
uses SysUtils;&#160;type&#160;&#160;PPointer = ^Pointer;&#160;&#160;&#160;TChainedList = class&#160;&#160;private&#160;&#160;&#160;&#160;FFirst&#160;&#160; : Pointer;&#160;&#160;&#160;&#160;FLast&#160;&#160;&#160;&#160;: Pointer;&#160;&#160;&#160;&#160;FCurrent : Pointer;&#160;&#160;&#160;&#160;FCount&#160;&#160; : Integer;&#160;&#160;&#160;&#160;function GetCurrent: PPointer;&#160;&#160;public&#160;&#160;&#160;&#160;constructor Create;&#160;&#160;&#160;&#160;destructor Destroy; override;&#160;&#160;&#160;&#160;&#160;function First : TChainedList;&#160;&#160;&#160;&#160;function Last&#160;&#160;: TChainedList;&#160;&#160;&#160;&#160;function Prior : TChainedList;&#160;&#160;&#160;&#160;function Next&#160;&#160;: TChainedList;&#160;&#160;&#160;&#160;&#160;function Add: TChainedList;&#160;&#160;&#160;&#160;function Remove: TChainedList; overload;&#160;&#160;&#160;&#160;function Remove&#40;AChainedReleaser: Pointer&#41;: TChainedList; overload;&#160;&#160;&#160;&#160;&#160;property Current: PPointer read GetCurrent;&#160;&#160;&#160;&#160;property Count: Integer read FCount;&#160;&#160;end;&#160;implementation&#160;type&#160;&#160;PChainedItem [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Folks,</strong></p>
<p>For everybody thats use a lot Chained lists on your projects:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">uses</span> SysUtils<span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">type</span></li><li>&nbsp;&nbsp;<span style="color: #000066; font-weight: bold;">PPointer</span> <span style="color: #000066;">=</span> <span style="color: #000066;">^</span>Pointer<span style="color: #000066;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;TChainedList <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">class</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">private</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;FFirst&nbsp;&nbsp; <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Pointer</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;FLast&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Pointer</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;FCurrent <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Pointer</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;FCount&nbsp;&nbsp; <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">function</span> GetCurrent<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">PPointer</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">constructor</span> Create<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">destructor</span> Destroy<span style="color: #000066;">;</span> <span style="color: #000000; font-weight: bold;">override</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">function</span> First <span style="color: #000066;">:</span> TChainedList<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">function</span> Last&nbsp;&nbsp;<span style="color: #000066;">:</span> TChainedList<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">function</span> Prior <span style="color: #000066;">:</span> TChainedList<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">function</span> Next&nbsp;&nbsp;<span style="color: #000066;">:</span> TChainedList<span style="color: #000066;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">function</span> Add<span style="color: #000066;">:</span> TChainedList<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">function</span> Remove<span style="color: #000066;">:</span> TChainedList<span style="color: #000066;">;</span> <span style="color: #000000; font-weight: bold;">overload</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">function</span> Remove<span style="color: #000066;">&#40;</span>AChainedReleaser<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Pointer</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span> TChainedList<span style="color: #000066;">;</span> <span style="color: #000000; font-weight: bold;">overload</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">property</span> Current<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">PPointer</span> <span style="color: #000066;">read</span> GetCurrent<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">property</span> Count<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span> <span style="color: #000066;">read</span> FCount<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">implementation</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">type</span></li><li>&nbsp;&nbsp;PChainedItem <span style="color: #000066;">=</span> <span style="color: #000066;">^</span>TChainedItem<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;TChainedItem <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">record</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Prior<span style="color: #000066;">,</span> Next<span style="color: #000066;">:</span> PChainedItem<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Data<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Pointer</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #808080; font-style: italic;">{ TChainedList }</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">constructor</span> TChainedList<span style="color: #000066;">.</span><span style="color: #006600;">Create</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;FCount <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;FFirst <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;FLast <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;FCurrent <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">destructor</span> TChainedList<span style="color: #000066;">.</span><span style="color: #006600;">Destroy</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;First<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">while</span> Current &lt;&gt; <span style="color: #000000; font-weight: bold;">nil</span> <span style="color: #000000; font-weight: bold;">do</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Remove<span style="color: #000066;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">inherited</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> TChainedList<span style="color: #000066;">.</span><span style="color: #006600;">GetCurrent</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">PPointer</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> FCurrent &lt;&gt; <span style="color: #000000; font-weight: bold;">nil</span> <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">@</span>PChainedItem<span style="color: #000066;">&#40;</span>FCurrent<span style="color: #000066;">&#41;</span><span style="color: #000066;">.</span><span style="color: #006600;">Data</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">else</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> TChainedList<span style="color: #000066;">.</span><span style="color: #006600;">First</span><span style="color: #000066;">:</span> TChainedList<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;FCurrent <span style="color: #000066;">:</span><span style="color: #000066;">=</span> FFirst<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">Self</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> TChainedList<span style="color: #000066;">.</span><span style="color: #006600;">Last</span><span style="color: #000066;">:</span> TChainedList<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;FCurrent <span style="color: #000066;">:</span><span style="color: #000066;">=</span> FLast<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">Self</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> TChainedList<span style="color: #000066;">.</span><span style="color: #006600;">Prior</span><span style="color: #000066;">:</span> TChainedList<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> FCurrent &lt;&gt; <span style="color: #000000; font-weight: bold;">nil</span> <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;FCurrent <span style="color: #000066;">:</span><span style="color: #000066;">=</span> PChainedItem<span style="color: #000066;">&#40;</span>FCurrent<span style="color: #000066;">&#41;</span><span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Prior</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">else</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;FCurrent <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">Self</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> TChainedList<span style="color: #000066;">.</span><span style="color: #006600;">Next</span><span style="color: #000066;">:</span> TChainedList<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> FCurrent &lt;&gt; <span style="color: #000000; font-weight: bold;">nil</span> <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;FCurrent <span style="color: #000066;">:</span><span style="color: #000066;">=</span> PChainedItem<span style="color: #000066;">&#40;</span>FCurrent<span style="color: #000066;">&#41;</span><span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Next</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">else</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;FCurrent <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">Self</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> TChainedList<span style="color: #000066;">.</span><span style="color: #006600;">Add</span><span style="color: #000066;">:</span> TChainedList<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">var</span></li><li>&nbsp;&nbsp;pNew<span style="color: #000066;">:</span> PChainedItem<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;<span style="color: #000066;">New</span><span style="color: #000066;">&#40;</span>pNew<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;pNew<span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Prior</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;pNew<span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Next</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;pNew<span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Data</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> FFirst <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">nil</span> <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;FFirst <span style="color: #000066;">:</span><span style="color: #000066;">=</span> pNew<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;FLast <span style="color: #000066;">:</span><span style="color: #000066;">=</span> pNew<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span> <span style="color: #000000; font-weight: bold;">else</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;pNew<span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Prior</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> PChainedItem<span style="color: #000066;">&#40;</span>FLast<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;PChainedItem<span style="color: #000066;">&#40;</span>FLast<span style="color: #000066;">&#41;</span><span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Next</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> pNew<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;FLast <span style="color: #000066;">:</span><span style="color: #000066;">=</span> pNew<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;FCurrent <span style="color: #000066;">:</span><span style="color: #000066;">=</span> FLast<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">Self</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000066;">Inc</span><span style="color: #000066;">&#40;</span>FCount<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> TChainedList<span style="color: #000066;">.</span><span style="color: #006600;">Remove</span><span style="color: #000066;">:</span> TChainedList<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">var</span></li><li>&nbsp;&nbsp;pCur<span style="color: #000066;">:</span> PChainedItem<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;pCur <span style="color: #000066;">:</span><span style="color: #000066;">=</span> FCurrent<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> pCur<span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Data</span> &lt;&gt; <span style="color: #000000; font-weight: bold;">nil</span> <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">raise</span> Exception<span style="color: #000066;">.</span><span style="color: #006600;">Create</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Current item memory leak detected.'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> pCur<span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Next</span> &lt;&gt; <span style="color: #000000; font-weight: bold;">nil</span> <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;pCur<span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Next</span><span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Prior</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> pCur<span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Prior</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> pCur<span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Prior</span> &lt;&gt; <span style="color: #000000; font-weight: bold;">nil</span> <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;pCur<span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Prior</span><span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Next</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> pCur<span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Next</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> pCur <span style="color: #000066;">=</span> FFirst <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;FFirst <span style="color: #000066;">:</span><span style="color: #000066;">=</span> pCur<span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Next</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;FCurrent <span style="color: #000066;">:</span><span style="color: #000066;">=</span> FFirst<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> pCur <span style="color: #000066;">=</span> FLast <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;FLast <span style="color: #000066;">:</span><span style="color: #000066;">=</span> pCur<span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Prior</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;FCurrent <span style="color: #000066;">:</span><span style="color: #000066;">=</span> FLast<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span> <span style="color: #000000; font-weight: bold;">else</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;FCurrent <span style="color: #000066;">:</span><span style="color: #000066;">=</span> pCur<span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Next</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">Self</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000066;">Dispose</span><span style="color: #000066;">&#40;</span>pCur<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000066;">Dec</span><span style="color: #000066;">&#40;</span>FCount<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> TChainedList<span style="color: #000066;">.</span><span style="color: #006600;">Remove</span><span style="color: #000066;">&#40;</span>AChainedReleaser<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Pointer</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span> TChainedList<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">type</span></li><li>&nbsp;&nbsp;TRelease <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">procedure</span><span style="color: #000066;">&#40;</span>APointer<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Pointer</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">var</span></li><li>&nbsp;&nbsp;PdrRelease<span style="color: #000066;">:</span> TRelease<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;<span style="color: #000066;">@</span>PdrRelease <span style="color: #000066;">:</span><span style="color: #000066;">=</span> AChainedReleaser<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;PdrRelease<span style="color: #000066;">&#40;</span>PChainedItem<span style="color: #000066;">&#40;</span>FCurrent<span style="color: #000066;">&#41;</span><span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Data</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;PChainedItem<span style="color: #000066;">&#40;</span>FCurrent<span style="color: #000066;">&#41;</span><span style="color: #000066;">^</span><span style="color: #000066;">.</span><span style="color: #006600;">Data</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> Remove<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>See how to use it here: <a href="http://gsaraiva.projects.pro.br/?p=418">Delphi: Chained List</a></p>
<p>Hugs!</p>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2009/06/delphi-utils-tchainedlist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi: Utils :: ToolButtonScreenPos</title>
		<link>http://projects.pro.br/gsaraiva/2008/09/delphi-utils-toolbuttonscreenpos/</link>
		<comments>http://projects.pro.br/gsaraiva/2008/09/delphi-utils-toolbuttonscreenpos/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 23:26:16 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[GetDCOrgEx]]></category>
		<category><![CDATA[ToolButtonScreenPos]]></category>
		<category><![CDATA[Usefull functions]]></category>

		<guid isPermaLink="false">http://gsaraiva.projects.pro.br/?p=341</guid>
		<description><![CDATA[Folks,
For everybody that needs the ToolButton position:
type&#160;&#160;TToolButtonAccess = class&#40;TToolButton&#41;;&#160;function ToolButtonScreenPos&#40;AToolButton: TToolButton&#41;: TPoint;begin&#160;&#160;GetDCOrgEx&#40;TToolButtonAccess&#40;AToolButton&#41;.Canvas.Handle, Result&#41;;&#160;&#160;Inc&#40;Result.X, AToolButton.Left&#41;;&#160;&#160;Inc&#40;Result.Y, AToolButton.Top&#41;;end;
Hugs!
]]></description>
			<content:encoded><![CDATA[<p><strong>Folks,</strong></p>
<p>For everybody that needs the ToolButton position:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">type</span></li><li>&nbsp;&nbsp;TToolButtonAccess <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #000066;">&#40;</span>TToolButton<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> ToolButtonScreenPos<span style="color: #000066;">&#40;</span>AToolButton<span style="color: #000066;">:</span> TToolButton<span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span> TPoint<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;GetDCOrgEx<span style="color: #000066;">&#40;</span>TToolButtonAccess<span style="color: #000066;">&#40;</span>AToolButton<span style="color: #000066;">&#41;</span><span style="color: #000066;">.</span><span style="color: #006600;">Canvas</span><span style="color: #000066;">.</span><span style="color: #006600;">Handle</span><span style="color: #000066;">,</span> Result<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000066;">Inc</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">.</span><span style="color: #006600;">X</span><span style="color: #000066;">,</span> AToolButton<span style="color: #000066;">.</span><span style="color: #006600;">Left</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000066;">Inc</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">.</span><span style="color: #006600;">Y</span><span style="color: #000066;">,</span> AToolButton<span style="color: #000066;">.</span><span style="color: #006600;">Top</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Hugs!</p>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2008/09/delphi-utils-toolbuttonscreenpos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi: Utils :: SpeedButtonScreenPos</title>
		<link>http://projects.pro.br/gsaraiva/2008/09/delphi-utils-speedbuttonscreenpos/</link>
		<comments>http://projects.pro.br/gsaraiva/2008/09/delphi-utils-speedbuttonscreenpos/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 23:24:54 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[GetDCOrgEx]]></category>
		<category><![CDATA[SpeedButtonScreenPos]]></category>
		<category><![CDATA[Usefull functions]]></category>

		<guid isPermaLink="false">http://gsaraiva.projects.pro.br/?p=339</guid>
		<description><![CDATA[Folks,
For everybody that needs the Speedbutton position:
type&#160;&#160;TSpeedButtonAccess = class&#40;TSpeedButton&#41;;&#160;function SpeedButtonScreenPos&#40;ASpeedButton: TSpeedButton&#41;: TPoint;begin&#160;&#160;GetDCOrgEx&#40;TSpeedButtonAccess&#40;ASpeedButton&#41;.Canvas.Handle, Result&#41;;&#160;&#160;Inc&#40;Result.X, ASpeedButton.Left&#41;;&#160;&#160;Inc&#40;Result.Y, ASpeedButton.Top&#41;;end;
Hugs!
]]></description>
			<content:encoded><![CDATA[<p><strong>Folks,</strong></p>
<p>For everybody that needs the Speedbutton position:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">type</span></li><li>&nbsp;&nbsp;TSpeedButtonAccess <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #000066;">&#40;</span>TSpeedButton<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> SpeedButtonScreenPos<span style="color: #000066;">&#40;</span>ASpeedButton<span style="color: #000066;">:</span> TSpeedButton<span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span> TPoint<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;GetDCOrgEx<span style="color: #000066;">&#40;</span>TSpeedButtonAccess<span style="color: #000066;">&#40;</span>ASpeedButton<span style="color: #000066;">&#41;</span><span style="color: #000066;">.</span><span style="color: #006600;">Canvas</span><span style="color: #000066;">.</span><span style="color: #006600;">Handle</span><span style="color: #000066;">,</span> Result<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000066;">Inc</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">.</span><span style="color: #006600;">X</span><span style="color: #000066;">,</span> ASpeedButton<span style="color: #000066;">.</span><span style="color: #006600;">Left</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000066;">Inc</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">.</span><span style="color: #006600;">Y</span><span style="color: #000066;">,</span> ASpeedButton<span style="color: #000066;">.</span><span style="color: #006600;">Top</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Hugs!</p>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2008/09/delphi-utils-speedbuttonscreenpos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi: Utils :: DesktopArea</title>
		<link>http://projects.pro.br/gsaraiva/2008/09/delphi-utils-desktoparea/</link>
		<comments>http://projects.pro.br/gsaraiva/2008/09/delphi-utils-desktoparea/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 23:12:43 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[DesktopArea]]></category>
		<category><![CDATA[FindWindow]]></category>
		<category><![CDATA[GetDesktopWindow]]></category>
		<category><![CDATA[GetWindowRect]]></category>
		<category><![CDATA[Shell_TrayWnd]]></category>
		<category><![CDATA[SubtractRect]]></category>
		<category><![CDATA[Usefull functions]]></category>

		<guid isPermaLink="false">http://gsaraiva.projects.pro.br/?p=334</guid>
		<description><![CDATA[Folks,
For everybody that need to show something only on the useful area of the desktop I wrote this function:
function DesktopClientArea: TRect;var&#160;&#160;rDesktop, rWinBar: TRect;begin&#160;&#160;Windows.GetWindowRect&#40;GetDesktopWindow, rDesktop&#41;;&#160;&#160;Windows.GetWindowRect&#40;FindWindow&#40;'Shell_TrayWnd', nil&#41;, rWinBar&#41;;&#160;&#160;SubtractRect&#40;Result, rDesktop, rWinBar&#41;;end;
Hugs!
]]></description>
			<content:encoded><![CDATA[<p><strong>Folks,</strong></p>
<p>For everybody that need to show something only on the useful area of the desktop I wrote this function:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">function</span> DesktopClientArea<span style="color: #000066;">:</span> TRect<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">var</span></li><li>&nbsp;&nbsp;rDesktop<span style="color: #000066;">,</span> rWinBar<span style="color: #000066;">:</span> TRect<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;Windows<span style="color: #000066;">.</span><span style="color: #006600;">GetWindowRect</span><span style="color: #000066;">&#40;</span>GetDesktopWindow<span style="color: #000066;">,</span> rDesktop<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Windows<span style="color: #000066;">.</span><span style="color: #006600;">GetWindowRect</span><span style="color: #000066;">&#40;</span>FindWindow<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Shell_TrayWnd'</span><span style="color: #000066;">,</span> <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span> rWinBar<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;SubtractRect<span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">,</span> rDesktop<span style="color: #000066;">,</span> rWinBar<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Hugs!</p>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2008/09/delphi-utils-desktoparea/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi: Utils :: PNG for Delphi</title>
		<link>http://projects.pro.br/gsaraiva/2008/08/delphi-utils-png-for-delphi/</link>
		<comments>http://projects.pro.br/gsaraiva/2008/08/delphi-utils-png-for-delphi/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 22:32:58 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>

		<guid isPermaLink="false">http://gsaraiva.projects.pro.br/?p=306</guid>
		<description><![CDATA[Folks,
Let me provide this good library of PNG for Delphi, as I see that is hard to get a copy searching on the web I&#8217;ll provide it here.
Component: PNG Delphi
Component Author: Gustavo Huffenbacher Daud
Lastest version: 2002
Download it here:
Its very easy to use, and came with a help ( PngDelphi.chm under the .zip )
Hugs
]]></description>
			<content:encoded><![CDATA[<p><strong>Folks,</strong></p>
<p>Let me provide this good library of PNG for Delphi, as I see that is hard to get a copy searching on the web I&#8217;ll provide it here.</p>
<p>Component: PNG Delphi<br />
Component Author: Gustavo Huffenbacher Daud<br />
Lastest version: 2002<br />
<strong>Download it here:</strong> <a href="http://projects.pro.br/gsaraiva/downloads/7" title="Downloaded 315 times">pngimagelib (354.42 KB) - 315 hits</a></p>
<p>Its very easy to use, and came with a help ( PngDelphi.chm under the .zip )</p>
<p>Hugs</p>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2008/08/delphi-utils-png-for-delphi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi: Utils :: ChangeDropShadow</title>
		<link>http://projects.pro.br/gsaraiva/2008/07/delphi-utils-changedropshadow/</link>
		<comments>http://projects.pro.br/gsaraiva/2008/07/delphi-utils-changedropshadow/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 14:21:38 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[ChangeDropShadow]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[ReadBinaryData]]></category>
		<category><![CDATA[SystemParametersInfo]]></category>
		<category><![CDATA[Usefull functions]]></category>
		<category><![CDATA[UserPreferencesMask]]></category>
		<category><![CDATA[WriteBinaryData]]></category>

		<guid isPermaLink="false">http://gsaraiva.projects.pro.br/?p=220</guid>
		<description><![CDATA[Folks,
With this procedure you can change the Drop Shadow effect provided by windows XP/Vista on all windows without need to reset the computer.
procedure ChangeDropShadow&#40;AActive: boolean&#41;;var&#160;&#160;Buff: Cardinal;&#160;&#160;Param: Pointer;&#160;&#160;DevMode: TDeviceMode;begin&#160;&#160;with TRegistry.Create do&#160;&#160;begin&#160;&#160;&#160;&#160;RootKey := HKEY_CURRENT_USER;&#160;&#160;&#160;&#160;if OpenKey&#40;'\Control Panel\Desktop\', false&#41; then&#160;&#160;&#160;&#160;begin&#160;&#160;&#160;&#160;&#160;&#160;ReadBinaryData&#40;'UserPreferencesMask', Buff, 4&#41;;&#160;&#160;&#160;&#160;&#160;&#160;if AActive then&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Buff := Buff or &#40;1 shl 18&#41;&#160;&#160;&#160;&#160;&#160;&#160;else&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Buff := Buff xor &#40;Buff and &#40;1 shl 18&#41;&#41;;&#160;&#160;&#160;&#160;&#160;&#160;WriteBinaryData&#40;'UserPreferencesMask', Buff, [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Folks,</strong></p>
<p>With this procedure you can change the Drop Shadow effect provided by windows XP/Vista on all windows without need to reset the computer.</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">procedure</span> ChangeDropShadow<span style="color: #000066;">&#40;</span>AActive<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">boolean</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">var</span></li><li>&nbsp;&nbsp;Buff<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Cardinal</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Param<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Pointer</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;DevMode<span style="color: #000066;">:</span> TDeviceMode<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">with</span> TRegistry<span style="color: #000066;">.</span><span style="color: #006600;">Create</span> <span style="color: #000000; font-weight: bold;">do</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;RootKey <span style="color: #000066;">:</span><span style="color: #000066;">=</span> HKEY_CURRENT_USER<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> OpenKey<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'\Control Panel\Desktop\'</span><span style="color: #000066;">,</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ReadBinaryData<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'UserPreferencesMask'</span><span style="color: #000066;">,</span> Buff<span style="color: #000066;">,</span> 4<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> AActive <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Buff <span style="color: #000066;">:</span><span style="color: #000066;">=</span> Buff <span style="color: #000000; font-weight: bold;">or</span> <span style="color: #000066;">&#40;</span>1 <span style="color: #000000; font-weight: bold;">shl</span> 18<span style="color: #000066;">&#41;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">else</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Buff <span style="color: #000066;">:</span><span style="color: #000066;">=</span> Buff <span style="color: #000000; font-weight: bold;">xor</span> <span style="color: #000066;">&#40;</span>Buff <span style="color: #000000; font-weight: bold;">and</span> <span style="color: #000066;">&#40;</span>1 <span style="color: #000000; font-weight: bold;">shl</span> 18<span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WriteBinaryData<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'UserPreferencesMask'</span><span style="color: #000066;">,</span> Buff<span style="color: #000066;">,</span> 4<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Param <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> AActive <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Param <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">@</span>AActive<span style="color: #000066;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SystemParametersInfo<span style="color: #000066;">&#40;</span>SPI_SETDROPSHADOW<span style="color: #000066;">,</span> 0<span style="color: #000066;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Param<span style="color: #000066;">,</span> SPIF_SENDWININICHANGE<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Free<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Hugs!</p>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2008/07/delphi-utils-changedropshadow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Benchmark: Como utilizar?</title>
		<link>http://projects.pro.br/gsaraiva/2008/07/benchmark-como-utilizar/</link>
		<comments>http://projects.pro.br/gsaraiva/2008/07/benchmark-como-utilizar/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 16:22:43 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[Benchmark]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[EndBenchmarking]]></category>
		<category><![CDATA[StartBenchmarking]]></category>

		<guid isPermaLink="false">http://gsaraiva.projects.pro.br/?p=210</guid>
		<description><![CDATA[Camaradas,
Vou falar um pouco sobre o projeto Benchmark que está disponível no fórum da DevPartners.
Para que serve o projeto Benchmark?

O projeto começou de uma brincadeira entre amigos para desenvolver o algoritmo mais rápido de criação de arranjos, então surgiu a necessidade de termos um sistema de quantificação de tempo utilizado, um benchmark, foi ai que [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Camaradas,</strong></p>
<p>Vou falar um pouco sobre o projeto Benchmark que está disponível no <a href="http://devpartners.projects.pro.br/forum/">fórum da DevPartners</a>.</p>
<p><strong>Para que serve o projeto Benchmark?</strong>
<dl>
O projeto começou de uma brincadeira entre amigos para desenvolver o algoritmo mais rápido de criação de arranjos, então surgiu a necessidade de termos um sistema de quantificação de tempo utilizado, um benchmark, foi ai que eu comecei a escrever o projeto Benchamark.</p>
<p>Um Benchmark serve para medir uma grandeza matemática que servirá para comparação ou avaliação.<br />
Exemplo:<br />
Frames por segundo em um jogo de computador, a grande maioria dos benchmarks são feitos para comparar o desempenho entre duas ou mais placas de vídeo.
</dl>
<p><strong>O projeto Benchmark servirá no meu aplicativo?</strong>
<dl>
Claro, o projeto Benchmark foi feito para não ser dependente de nada, é só colocar no seu projeto e utilizar quando necessário.
</dl>
<p><strong>Como faço para fazer um Benchmark de uma processo dentro do meu aplicativo?</strong>
<dl>
Primeiro você deve baixar o código-fonte do projeto Benchmark para sua máquina, acessando o fórum do projeto, <a href="http://devpartners.projects.pro.br/forum/?board=4">http://devpartners.projects.pro.br/forum/?board=4</a>.</p>
<p>Uma pequena ajuda foi escrita para você que não conhece bem o Subversion:<br />
<a href="http://devpartners.projects.pro.br/forum/?topic=20">Como baixar um projeto pelo Subversion.</a></p>
<p>Logo que tiver o código do Benchmark na sua máquina, acesse a pasta do Benchmark e copie o arquivo pasBenchmark.pas ( <em>Benchmark\source\</em> ) para o diretorio de Lib do seu Delphi ( essa dica é para facilitar a implementação em outros projetos também, se você entende um pouco mais do esquema de diretórios do Delphi você poderá adicionar a Unit como uma biblioteca ), o diretório Lib do Delphi 7 é o:<br />
<em>C:\Arquivos de programas\Borland\Delphi7\Lib</em></p>
<p>Feito isso, você deve editar seu projeto em apenas 2 partes:</p>
<li>Adicionar o Benchmark no Uses da Unit do processo:<br />
Exemplo:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li></li><li><span style="color: #000000; font-weight: bold;">unit</span> Unit1<span style="color: #000066;">;</span></li><li><span style="color: #808080; font-style: italic;">{ ... }</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">var</span></li><li>&nbsp;&nbsp;Form1<span style="color: #000066;">:</span> TForm1<span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">implementation</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">uses</span> pasBenchmark<span style="color: #000066;">;</span></li><li></li></ol></div></pre><!--END_DEVFMTCODE-->
</li>
<li>Antes de iniciar o processo que deseja fazer o Benchmark:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">procedure</span> TForm1<span style="color: #000066;">.</span><span style="color: #006600;">ConnectToServer</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;<span style="color: #808080; font-style: italic;">{ ... processo que conecta em um servidor de dados ... }</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">procedure</span> TForm1<span style="color: #000066;">.</span><span style="color: #006600;">btnRunClick</span><span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;Benchmark<span style="color: #000066;">.</span><span style="color: #006600;">StartBenchmarking</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Benchmark de conexão com o servidor'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">try</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;ConnectToServer<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">except</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Benchmark<span style="color: #000066;">.</span><span style="color: #006600;">EndBenchmarking</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li></ol></div></pre><!--END_DEVFMTCODE-->
</li>
<p>Ao executar o aplicativo e executar o processo, você verá que uma janela abrirá, exibindo as informações do Benchmark, com um resultado semelhante ao exemplificado abaixo:<br />
<code>  1º Benchmark de conexão com o servidor<br />
  Benchmark start at : 26/07/2008 11:54:26<br />
      \___ runned under 550.587,964276 ms</code></p>
<p>O que nos informa que a conexão com o servidor de dados demorou 550.587 milisegundos, algo en torno de 0,5 segundos.
</dl>
<p><strong>Aonde posso obter mais exemplos de como usar?</strong>
<dl>
Logo que você copiar os arquivos do projeto para sua máquina atravez do Subversion, você poderá acessar as demonstrações que acompanham o projeto na pasta <em>Benchmark\demos</em>
</dl>
<p>Espero que o projeto ajude mais gente como já me ajudou algumas vezes.</p>
<p>Abraço a todos</p>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2008/07/benchmark-como-utilizar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL: Database Dump tricks</title>
		<link>http://projects.pro.br/gsaraiva/2008/07/mysql-database-dump-tricks/</link>
		<comments>http://projects.pro.br/gsaraiva/2008/07/mysql-database-dump-tricks/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 17:56:30 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[MySQLDump]]></category>

		<guid isPermaLink="false">http://gsaraiva.projects.pro.br/?p=195</guid>
		<description><![CDATA[Folks,
Let me relate this:
Sometimes when you are dumping a database to another host your connection can down, and you will lost all your job and start again? No, no, no, you can make some tricks to continue where you stopped.
So let me enumarate the tricks:

MySQLDump commands:
Use &#8211;add-drop-table
For don&#8217;t lose what you already done, you can [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Folks,</strong></p>
<p>Let me relate this:</p>
<p>Sometimes when you are dumping a database to another host your connection can down, and you will lost all your job and start again? No, no, no, you can make some tricks to continue where you stopped.</p>
<p>So let me enumarate the tricks:
<dl>
<h4>MySQLDump commands:</h4>
<li><strong>Use &#8211;add-drop-table</strong><br />
For don&#8217;t lose what you already done, you can config dump to don&#8217;t drop the table you are transfering.<br />
Command: <!--DEVFMTCODE--><pre class="devcodeblock" title="DOS"><div class="devcodeoverflow"><ol><li>--add-drop-table=FALSE</li></ol></div></pre><!--END_DEVFMTCODE-->
</li>
<li><strong>Use &#8211;no-create-info</strong><br />
To avoid the creation of the table, you need to set this option as true.<br />
Command: <!--DEVFMTCODE--><pre class="devcodeblock" title="DOS"><div class="devcodeoverflow"><ol><li>--no-create-info=TRUE</li></ol></div></pre><!--END_DEVFMTCODE-->
</li>
<li><strong>Use &#8211;where option</strong><br />
the &#8211;where option will work as a SQL filter for you, so if you have a indexed table you can<br />
Command: <!--DEVFMTCODE--><pre class="devcodeblock" title="DOS"><div class="devcodeoverflow"><ol><li>--where=&quot;ID &gt; <span style="color: #cc66cc;">300</span>&quot;</li></ol></div></pre><!--END_DEVFMTCODE-->
</li>
<h4>MySQL commands:</h4>
<li><strong>Use &#8211;force</strong><br />
To avoid a break on the processing if the dump post a SQL that can cause a error, you need to Force to MySQL continue even with a SQL error and it will keep the rest of the process working.<br />
Command: <!--DEVFMTCODE--><pre class="devcodeblock" title="DOS"><div class="devcodeoverflow"><ol><li>--force</li></ol></div></pre><!--END_DEVFMTCODE-->
</li>
</dl>
<p>So, now you know what the commands do and can create a full command line like this one:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="DOS"><div class="devcodeoverflow"><ol><li></li><li>C:\MySQL\Bin&gt;mysqldump -h 10.0.0.1 -u root -p123456 --add-drop-table=FALSE --no-create-info=TRUE --where=&quot;ID &gt; 300&quot; MyDatabase MyTable | mysql -h www.mysite.com -u MyWebUser -p123456 --force MyWebDatabase</li><li></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Piece of cake, uhm?</p>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2008/07/mysql-database-dump-tricks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
