<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-772164822749879307</atom:id><lastBuildDate>Mon, 27 Oct 2025 13:30:35 +0000</lastBuildDate><category>delphi</category><category>vcl patches</category><category>tips</category><category>user experience</category><category>django</category><category>google</category><category>hadoop</category><category>linux</category><category>math</category><category>sqoop</category><title>stanleyxu&#39;s area51</title><description></description><link>http://stanleyxu2005.blogspot.com/</link><managingEditor>noreply@blogger.com (stanleyxu (2nd))</managingEditor><generator>Blogger</generator><openSearch:totalResults>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-6030501050652873508</guid><pubDate>Sun, 11 Oct 2015 17:12:00 +0000</pubDate><atom:updated>2015-10-12T04:13:17.164+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">django</category><title>Be careful, Django&#39;s ORM might be a performance killer</title><description>I was hoping Django&#39;s ORM to save my day, until I found a &lt;a href=&quot;https://code.djangoproject.com/ticket/25470&quot;&gt;serious performance issue&lt;/a&gt;, which slow down a simply SQL query by 500x! Yes, this is not a typo, 500 times slower! It really took me &lt;a href=&quot;http://stackoverflow.com/questions/32795047/have-a-perforamance-issue-of-query-date-object-using-django-queryset/32797463#32797463&quot;&gt;couple of hours&lt;/a&gt; to find the issue. The reason is that Django will do an unnecessary data type conversion behind the scene. I guess this must be a workaround for some wired bug before. But holy, when you have over 1 million records, you can imagine how slow Django ORM can be (in some cases). &lt;br /&gt;
&lt;br /&gt;
Now I&#39;m getting a bit upset, after seeing the core developer team seems want me to handle the issue. Come on! I&#39;m not a free man power, everybody has their things to do. I&#39;m not a unreasonable person, but database related bug will definitively need test cases for dozen db engines. How the hell do have I the time to checkout the whole develop environment and study django&#39;s develop/test process? I&#39;m afraid such aptitude of making software will sooner or later kill the project.</description><link>http://stanleyxu2005.blogspot.com/2015/10/be-careful-djangos-orm-might-be.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-6891165680021471352</guid><pubDate>Tue, 11 Nov 2014 03:34:00 +0000</pubDate><atom:updated>2014-11-11T04:38:21.328+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">hadoop</category><category domain="http://www.blogger.com/atom/ns#">sqoop</category><title>Data integration made easy</title><description>I&#39;m focusing on Hadoop Sqoop recently. Here is &lt;a href=&quot;http://ingest.tips/2014/11/10/parquet-support-arriving-in-sqoop/&quot;&gt;an intro&lt;/a&gt; of my recent work on Parquet support.</description><link>http://stanleyxu2005.blogspot.com/2014/11/data-integration-made-easy.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-5498987056783160378</guid><pubDate>Fri, 16 May 2014 05:41:00 +0000</pubDate><atom:updated>2014-05-16T07:41:46.985+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">delphi</category><title>TDelphiChromeTabs Project</title><description>I&#39;m now a committer of &lt;a href=&quot;https://code.google.com/p/delphi-chrome-tabs/&quot;&gt;TDelphiChromeTabs project&lt;/a&gt;. Thanks Paul to grant me the access. </description><link>http://stanleyxu2005.blogspot.com/2014/05/tdelphichrometabs-project.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-4930955150354159900</guid><pubDate>Fri, 31 Jan 2014 08:12:00 +0000</pubDate><atom:updated>2014-11-20T14:29:20.095+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">delphi</category><title>Change the look and feel of Delphi&#39;s Code Insight </title><description>Finally I found a way to make the font of Code Insight looks comfortable.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0F-nSNgpcyr72GI0IWjm09e-Z9uzUVCVM6QBVXQ2hD3M7ZnWZGpf_byEKmhsKYK-C1kH8EC2yOWlmMahdyVew4Z5ZWHq04CcdzKofT-Yh3tqEGae2vOIwV8UavpK8QMUj3ZtJEbXkI4hV/s1600/CodeInsight.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0F-nSNgpcyr72GI0IWjm09e-Z9uzUVCVM6QBVXQ2hD3M7ZnWZGpf_byEKmhsKYK-C1kH8EC2yOWlmMahdyVew4Z5ZWHq04CcdzKofT-Yh3tqEGae2vOIwV8UavpK8QMUj3ZtJEbXkI4hV/s1600/CodeInsight.png&quot; height=&quot;132&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Open &quot;C:\Program Files (x86)\Embarcadero\RAD Studio\11.0\ObjRepos\en\HelpInsight.css&quot;&lt;/div&gt;&lt;ol&gt;&lt;li&gt;Remove all &quot;font-family&quot; definition except the first and the last occurrences.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Prepend &quot;segoe ui,&quot; to the first &quot;font-family&quot; occurrence&lt;/li&gt;
&lt;li&gt;Prepend &quot;veramono,consolas,&quot; to the last &quot;font-family&quot; occurrence&lt;/li&gt;
&lt;/ol&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;i&gt;AD: My &quot;dutil&quot; project is now hosted at&amp;nbsp;&lt;a href=&quot;https://github.com/stanleyxu2005/dutil&quot;&gt;https://github.com/stanleyxu2005/dutil&lt;/a&gt;&lt;/i&gt;&lt;/div&gt;</description><link>http://stanleyxu2005.blogspot.com/2014/01/change-look-and-feel-of-delphis-code.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0F-nSNgpcyr72GI0IWjm09e-Z9uzUVCVM6QBVXQ2hD3M7ZnWZGpf_byEKmhsKYK-C1kH8EC2yOWlmMahdyVew4Z5ZWHq04CcdzKofT-Yh3tqEGae2vOIwV8UavpK8QMUj3ZtJEbXkI4hV/s72-c/CodeInsight.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-7977744725028889376</guid><pubDate>Thu, 12 Apr 2012 09:09:00 +0000</pubDate><atom:updated>2012-04-12T11:09:10.040+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">delphi</category><title>DUtil Project Started</title><description>I started a new &lt;a href=&quot;http://code.google.com/p/delphi-dutil/&quot;&gt;open source project dutil&lt;/a&gt; on google code.&amp;nbsp;dutil (currently 21 units) is aimed to be a cohesive and comprehensive library for general purpose usage. We write code based on Design by Contract principle. We use many pre- and post-conditions to assure the code works properly as expected. We also raise and capture exceptions in code, which makes the logic of code looks perfectly clear. Please feel free to use it and to share it.</description><link>http://stanleyxu2005.blogspot.com/2012/04/dutil-project-started.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-3993749868376419501</guid><pubDate>Mon, 26 Sep 2011 05:33:00 +0000</pubDate><atom:updated>2011-09-26T07:33:48.650+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">delphi</category><category domain="http://www.blogger.com/atom/ns#">vcl patches</category><title>Native Look VCL Project Started</title><description>I posted some articles to discuss the&amp;nbsp;differences&amp;nbsp;between Delphi visual components and native Windows controls. I think it is worth to make a project rather than share them as attachments here. Now I started an &lt;a href=&quot;http://code.google.com/p/native-look-vcl&quot;&gt;open source project&lt;/a&gt;.&amp;nbsp;The project aims to restore the native Windows control look and feel.&amp;nbsp;Please feel free to use it and to share it.&lt;br /&gt;
&lt;br /&gt;
BTW: Due to Internet censorship of China, it is quite difficult to access blogspot.com and blogger.com. If you mail me for technical support, please leave&amp;nbsp;&lt;b&gt;a reply address&lt;/b&gt; as well.</description><link>http://stanleyxu2005.blogspot.com/2011/09/native-look-vcl-project-started.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><thr:total>2</thr:total><georss:featurename>Shanghai, China</georss:featurename><georss:point>31.230393 121.473704</georss:point><georss:box>30.3614965 120.21027649999999 32.0992895 122.7371315</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-4616917014257610289</guid><pubDate>Fri, 22 Apr 2011 11:07:00 +0000</pubDate><atom:updated>2011-04-22T13:07:25.278+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">linux</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>Appearance Preferences Interface Tab</title><description>Unfortunately, icons are gone in all Context Menu by default since openSUSE 11.3. Even worse is that the Interface has been removed from the Appearance&amp;nbsp;Preferences&amp;nbsp;Window.&lt;br /&gt;
&lt;br /&gt;
I think i am not the only people, who would rather remember the menu item position than search for its label. So I became very unproductive when I have to face a very long context menu of Eclipse without any icons.&lt;br /&gt;
&lt;br /&gt;
Here is the way to give it back:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;In the terminal, call up gconf-editor&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Navigate to desktop/gnome/interface&lt;/li&gt;
&lt;li&gt;Scroll down and check the menus_have_icons box.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Have fun ;-)&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;</description><link>http://stanleyxu2005.blogspot.com/2011/04/appearance-preferences-interface-tab.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-7430368575046355496</guid><pubDate>Sun, 10 Apr 2011 15:47:00 +0000</pubDate><atom:updated>2011-04-10T17:47:19.357+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">tips</category><title>Finally get back all 4GB memory</title><description>HP is so ridiculous to send me a 64-bit quad-core &lt;a href=&quot;http://www.shopping.hp.com/webapp/shopping/series_can.do?storeName=computer_store&amp;amp;landing=desktops&amp;amp;a1=Category&amp;amp;v1=Slim%20and%20sleek&amp;amp;jumpid=in_R329_prodexp/hhoslp/psg/lateralnav_slim_sleek_desktops&quot;&gt;HP Pavilion s5235&lt;/a&gt; but a 32-bit Windows 7. Only one thing troubles me, that only 3.25GB (4GB memory is installed) memory is usable. So I called HP customer service, but they cannot give me a 64-bit Windows due to some 64-bit hardware driver problems They also said that I am lucky, because on some devices only 2.99GB memory can be recognized.&lt;br /&gt;
&lt;br /&gt;
Generally speaking, 3.25GB memory is significant for me. And I believed that this is a hardware limitation for a 32-bit operating system, until I read&lt;a href=&quot;http://www.geoffchappell.com/viewer.htm?doc=notes/windows/license/memory.htm&quot;&gt; this article&lt;/a&gt;. 

Now I&#39;d like to share you a very simple way to use 4GB memory on a 32-bit Windows 7.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Disable your anti-virus program&amp;nbsp;temporarily.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Download the software &lt;b&gt;&lt;a href=&quot;http://zh-deepxw.blogspot.com/2009/04/readyfor4gb.html&quot;&gt;ReadyFor4GB&lt;/a&gt;&lt;/b&gt; from&amp;nbsp;&lt;a href=&quot;http://filekeeper.org/download/deepxw/ReadyFor4GB/ReadyFor4GB_20090422.zip&quot;&gt;here&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a href=&quot;http://fileden.com/files/2009/4/13/2401634/ReadyFor4GB_20090422.zip&quot;&gt;here&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Apply the patch and reboot your system&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
It works perfect but you will see a &quot;Test mode ...&quot; watermark on the right bottom of every screen. Because the patch instructs you to add &quot;testsigning on&quot; to the startup script, which you cannot bypass. The correct thing you should do is:&lt;div&gt;
&lt;br /&gt;&lt;ol&gt;
&lt;li&gt;Download the software &lt;b&gt;&lt;a href=&quot;http://zh-deepxw.blogspot.com/2009/04/remove-watermark.html&quot;&gt;RemoveWatermark&lt;/a&gt;&lt;/b&gt; from&amp;nbsp;&lt;a href=&quot;http://soft3.wmzhe.com/download/deepxw/RemoveWatermark_20090509.zip&quot;&gt;here&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://soft2.wmzhe.com/download/deepxw/RemoveWatermark_20090509.zip&quot;&gt;here&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a href=&quot;http://filekeeper.org/download/deepxw/RemoveWatermark/RemoveWatermark_20090509.zip&quot;&gt;here&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Apply the patch by pressing &#39;Y&#39; and reboot your system&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
Now you can use full 4GB memory!&lt;/div&gt;</description><link>http://stanleyxu2005.blogspot.com/2011/04/finally-get-back-all-4gb-memory.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-7613996020577843067</guid><pubDate>Sun, 19 Dec 2010 07:42:00 +0000</pubDate><atom:updated>2010-12-19T08:42:56.819+01:00</atom:updated><title>Introducing Word Lens</title><description>&lt;iframe width=&quot;480&quot; height=&quot;295&quot; src=&quot;http://www.youtube.com/embed/h2OfQdYrHRs?fs=1&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;</description><link>http://stanleyxu2005.blogspot.com/2010/12/introducing-word-lens.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/h2OfQdYrHRs/default.jpg" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-3750688831512107457</guid><pubDate>Sun, 10 Oct 2010 14:43:00 +0000</pubDate><atom:updated>2010-10-10T16:43:24.095+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">math</category><title>Use the magic number</title><description>Here is a very interesting article &lt;a href=&quot;http://www.matrix67.com/data/InvSqrt.pdf&quot;&gt;http://www.matrix67.com/data/InvSqrt.pdf&lt;/a&gt;</description><link>http://stanleyxu2005.blogspot.com/2010/10/use-magic-number.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-6046098750925745308</guid><pubDate>Thu, 23 Apr 2009 18:25:00 +0000</pubDate><atom:updated>2009-12-05T01:41:04.972+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">delphi</category><title>Potential memory leaks by initializing a record (revised)</title><description>Currently I am involved in some D projects. Language D has nothing to do with Delphi. It has a lot of great features: Design by Contract, Templates, immutable, Array-Slicing, etc. My teammates give me a lot of advices on software design. One thing just inspired me. so I revised my old article &lt;a href=&#39;http://stanleyxu2005.blogspot.com/2008/01/potential-memory-leak-by-initializing.html&#39;&gt;&quot;Potential memory leaks by initializing a record&quot;&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The main point is that FillChar() looks more like an abuse of initializing a record. I suggest declare a const record (eg. EmptyRecord) instead of using FillChar(). If you are an expert, you will NOT make such a mistake, but it is still worth to tell the rest Delphi developers.&lt;br /&gt;&amp;nbsp;</description><link>http://stanleyxu2005.blogspot.com/2009/04/potential-memory-leaks-by-initializing.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-7327878564216922836</guid><pubDate>Thu, 23 Oct 2008 16:15:00 +0000</pubDate><atom:updated>2009-12-05T22:51:45.460+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">tips</category><title>LIKE is not case insensitive?</title><description>I was stuck by understanding the following SQL query:&lt;br /&gt;&lt;br /&gt;&lt;!-- code begin --&gt;&lt;pre name=&quot;code_li&quot; class=&quot;sql&quot;&gt;&lt;br /&gt;SELECT name &lt;br /&gt;FROM my_table&lt;br /&gt;WHERE name LIKE &#39;%Jack%&#39;&lt;/pre&gt;&lt;!-- code end --&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;http://mmjd.com/blog/sh/shCore.js&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;http://mmjd.com/blog/sh/shBrushSql.js&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;dp.sh.BloggerMode();dp.SyntaxHighlighter.ClipboardSwf = &#39;http://mmjd.com/blog/sh/clipboard.swf&#39;;dp.SyntaxHighlighter.HighlightAll(&#39;code_li&#39;);&lt;/script&gt;&lt;br /&gt;There is nothing special. It just tries to pick up all &quot;names&quot; of &quot;my_table&quot;, those values contain the word &quot;Jack&quot; (case sensitive). However, &quot;jack&quot; is also in the result. I cannot believe my eyes. &lt;br /&gt;&lt;br /&gt;I googled &quot;&lt;strong&gt;LIKE case insensitive&lt;/strong&gt;&quot; and got the answer: &lt;br /&gt;The problem is caused by the collation of the database. The default collation of my database is &quot;latin1_swedish_ci&quot;. The trailing &quot;_ci&quot; stands for case insensitive. I changed it to &quot;utf8_bin&quot;, the problem has been solved.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Here are some useful links:&lt;/strong&gt;&lt;br /&gt;&lt;a href=&quot;http://forums.mysql.com/read.php?20,202839,202839&quot;&gt;http://forums.mysql.com/read.php?20,202839,202839&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://dev.mysql.com/doc/refman/5.0/en/pattern-matching.html&quot;&gt;http://dev.mysql.com/doc/refman/5.0/en/pattern-matching.html&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://dev.mysql.com/doc/refman/5.0/en/charset-charsets.html&quot;&gt;http://dev.mysql.com/doc/refman/5.0/en/charset-charsets.html&lt;/a&gt;</description><link>http://stanleyxu2005.blogspot.com/2008/10/like-is-not-case-insensitive.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-7195490625075348164</guid><pubDate>Wed, 10 Sep 2008 06:08:00 +0000</pubDate><atom:updated>2009-12-05T22:54:19.038+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">tips</category><title>require_once()</title><description>If you used &lt;b&gt;require_once()&lt;/b&gt;, you may have known one big issue of it: &quot;If you give a relative path to the file you want to require, PHP will use the working directory as root, not the directory where this file is located.&quot; Your code won&#39;t have any problem, except the file to be required, requires some other files as well and unfortunately they are not in a same directory.&lt;br /&gt;&lt;br /&gt;There are several solutions on the Internet.&lt;ol&gt;&lt;li&gt;Put all PHP files into one folder. This works for tiny projects, but a flat folder structure is really ugly.&lt;/li&gt;&lt;li&gt;Use a PHP framework, like Zend, CodeIgniter, CakePHP. They provide a certain function like $this-&gt;load() to find the correct path of these files and load them.&lt;/li&gt;&lt;li&gt;If your code is not based on a framework, you can simply use &lt;br /&gt;&quot;&lt;b&gt;require_once(dirname(__FILE__).&#39;/path_to_file&#39;)&lt;/b&gt;&quot; instead of &lt;br /&gt;&quot;&lt;b&gt;require_once(&#39;path_to_file&#39;)&lt;/b&gt;&quot;. However this does not work on my xampp environment. My code hangs up when executing this line. (The problem seems not to be on the slash or backslash. Really no idea)&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;h2&gt;My Solution&lt;/h2&gt;Write a function to calculate the relative path from file directory to working directory. If you previously use &quot;&lt;b&gt;require_once(&#39;path_to_file&#39;)&lt;/b&gt;&quot;, now you write &lt;br /&gt;&quot;&lt;b&gt;require_once(cp(&#39;path_to_file&#39;))&lt;/b&gt;&quot;. It has been tested on Windows.&lt;br /&gt;&lt;br /&gt;&lt;!-- code begin --&gt;&lt;pre name=&quot;code_fd&quot; class=&quot;php&quot;&gt;if (!function_exists(&#39;cp&#39;))&lt;br /&gt;{&lt;br /&gt;    function cp($f) // change_path&lt;br /&gt;    {&lt;br /&gt;        if (($wp = getcwd()) === ($fp = dirname(__FILE__))) { return $f; }&lt;br /&gt;        $wp = explode(&#39;\\&#39;, $wp);&lt;br /&gt;        $fp = array_merge(explode(&#39;\\&#39;, $fp), explode(&#39;/&#39;, $f));&lt;br /&gt;        for ($i = 0, $p = min(count($wp), count($fp)); $i &lt; $p; $i++)&lt;br /&gt;        {&lt;br /&gt;            if ($wp[$i] === $fp[$i])&lt;br /&gt;            {&lt;br /&gt;                array_shift($wp);&lt;br /&gt;                array_shift($fp);&lt;br /&gt;                $i--; $p--;&lt;br /&gt;                continue;&lt;br /&gt;            }&lt;br /&gt;            break;&lt;br /&gt;        }&lt;br /&gt;        $p = &#39;&#39;; foreach ($wp as $k) { $p .= &#39;../&#39;; }&lt;br /&gt;        return $p.implode(&#39;/&#39;, $fp);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;!-- code end --&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;http://mmjd.com/blog/sh/shCore.js&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;http://mmjd.com/blog/sh/shBrushPhp.js&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;dp.sh.BloggerMode();dp.SyntaxHighlighter.ClipboardSwf = &#39;http://mmjd.com/blog/sh/clipboard.swf&#39;;dp.SyntaxHighlighter.HighlightAll(&#39;code_fd&#39;);&lt;/script&gt;</description><link>http://stanleyxu2005.blogspot.com/2008/09/requireonce-let-me-use-at-least-once.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-453381577095142677</guid><pubDate>Sat, 09 Aug 2008 08:36:00 +0000</pubDate><atom:updated>2009-04-10T20:15:43.421+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">delphi</category><title>Quick note on UnicodeString</title><description>Jan Goyvaerts has introduced some key information about Unicode in Delphi 2009.&lt;br /&gt;&lt;a href=&quot;http://www.micro-isv.asia/2008/08/get-ready-for-delphi-2009-and-unicode/&quot;&gt;http://www.micro-isv.asia/2008/08/get-ready-for-delphi-2009-and-unicode/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Marco Cantu has made a performance comparison between AnsiString and UnicodeString.&lt;br /&gt;&lt;a href=&quot;http://blog.marcocantu.com/blog/tiburon_unicode_video_5.html&quot;&gt;http://blog.marcocantu.com/blog/tiburon_unicode_video_5.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Conclusion&lt;/h2&gt;According to the information, so much I have collected in the past a few months, I summarized them as the following points:&lt;ol&gt;&lt;li&gt;Simple projects can be upgraded to Delphi 2009 without any modifications. Projects with heavy string operations or file operations could be compiled as well. But they should be tested completely before release.&lt;/li&gt;&lt;li&gt;UnicodeString is based on the same concept as AnsiString. So it is very fast and efficient, although it is a little bit slower than AnsiString.&lt;/li&gt;&lt;li&gt;In compare with WideString much less memory will be allocated for UnicodeString. If it is not necessary, you had better switch WideStrings to UnicodeStrings for a performance boost.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;strong&gt;UPDATE 1&lt;/strong&gt;: &lt;a href=&quot;http://www.deltics.co.nz/blog/?p=349&quot;&gt;Here&lt;/a&gt; and &lt;a href=&quot;http://www.deltics.co.nz/blog/?p=375&quot;&gt;here&lt;/a&gt; are detailed performance tests&lt;br /&gt;&amp;nbsp;</description><link>http://stanleyxu2005.blogspot.com/2008/08/delphi-2009-and-unicode-are-coming.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-7355880917756977973</guid><pubDate>Tue, 03 Jun 2008 12:13:00 +0000</pubDate><atom:updated>2009-12-05T23:00:46.499+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">google</category><title>Google features in a shell</title><description>Just found an interesting site &lt;a href=&quot;http://goosh.org/&quot;&gt;http://goosh.org/&lt;/a&gt;. It is powered by Google APIs.&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxfgP9eUF_syxOcVnHI8eOVyz4Bt0N8gWyvlJK5UASoIqI-_cAyWZ9lMTSlTrxg7aCqAPeoMkLlqye8zeKM9gkaB79xbYU-Ml7sVf3pVba9LAMwLfhFNolHczJjipwZSeKi5lm40tKGBDa/s1600-h/goosh.png&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxfgP9eUF_syxOcVnHI8eOVyz4Bt0N8gWyvlJK5UASoIqI-_cAyWZ9lMTSlTrxg7aCqAPeoMkLlqye8zeKM9gkaB79xbYU-Ml7sVf3pVba9LAMwLfhFNolHczJjipwZSeKi5lm40tKGBDa/s400/goosh.png&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5207629867759208050&quot; /&gt;&lt;/a&gt;&amp;nbsp;</description><link>http://stanleyxu2005.blogspot.com/2008/06/google-features-in-shell.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxfgP9eUF_syxOcVnHI8eOVyz4Bt0N8gWyvlJK5UASoIqI-_cAyWZ9lMTSlTrxg7aCqAPeoMkLlqye8zeKM9gkaB79xbYU-Ml7sVf3pVba9LAMwLfhFNolHczJjipwZSeKi5lm40tKGBDa/s72-c/goosh.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-1575509115443416852</guid><pubDate>Tue, 27 May 2008 18:45:00 +0000</pubDate><atom:updated>2008-08-12T15:30:54.850+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">user experience</category><title>Do not give the OK button a keyboard accelerator</title><description>Raymond Chen, a well-known developer on the Windows Shell team at Microsoft, mentioned a principle about dialog design in his blog: &lt;span style=&quot;font-weight:bold;&quot;&gt;Do not give the OK button a keyboard accelerator&lt;/span&gt; [1].&lt;br /&gt;
&lt;br /&gt;
But it is funny, that even their own products do not follow this principle strictly. A remarkable example is the &quot;Restart Prompt Dialog of Automatic Updates&quot; in WindowsXP. Both buttons &quot;Restart &lt;span style=&quot;text-decoration:underline&quot;&gt;N&lt;/span&gt;ow&quot; and &quot;Restart &lt;span style=&quot;text-decoration:underline&quot;&gt;L&lt;/span&gt;ater&quot; have a keyboard accelerator. If this dialog pops up, while I am pressing ALT+N, the current Windows session will be terminated immediately. And there is no Postpone button either. This button appears in Windows Vista, but there is no option &quot;Do not prompt me again, I will restart my computer later.&quot;. If I do not intend to restart my computer very soon, I have to press &quot;Postpone&quot; in every 4 hours. It is really annoying! Not only the unfriendly design, but also infinite critical Windows updates. The only one option for me is to turn off &quot;Automatic Updates&quot;.&lt;br /&gt;
&lt;br /&gt;
According to the great design principles [2]: I suggest remove those keyboard accelerators and add a 10-second-delay before restarting Windows, so that user can cancel this action. This is called user experience!&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;References&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;&lt;a href=&quot;http://blogs.msdn.com/oldnewthing/archive/2008/05/08/8467905.aspx&quot;&gt;Gentle reminder: On a dialog box, do not give OK and Cancel accelerators&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/aa511335.aspx&quot;&gt;How to Design a Great User Experience&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&amp;nbsp;</description><link>http://stanleyxu2005.blogspot.com/2008/05/raymond-chen-well-known-developer-on.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-8424771591517290001</guid><pubDate>Mon, 26 May 2008 04:04:00 +0000</pubDate><atom:updated>2009-12-05T22:55:44.446+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">delphi</category><category domain="http://www.blogger.com/atom/ns#">vcl patches</category><title>Form disappeared</title><description>After I started working on dual monitors, I have found another interesting issue:&lt;ol&gt;&lt;li&gt;Create a new application with a main form and a sub-form.&lt;/li&gt;&lt;li&gt;Set the property &lt;strong&gt;Position&lt;/strong&gt; of the sub-form to &lt;strong&gt;poMainFormCenter&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;Create a button &quot;Show Sub-Form&quot; on main form.&lt;/li&gt;&lt;li&gt;Move more than 50% area of the main form out of the main screen.&lt;/li&gt;&lt;li&gt;Click the button, we created.&lt;/li&gt;&lt;/ol&gt;The sub-form disappeared! Because the popup position of sub-form is out of the screen. I did a similar test with Internet Explorer. Its dialog will be shown at the corner of the screen. It can be regarded as a bug, so I have reported this issue to QualityCentral [1] as well. &lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Solution&lt;/h2&gt;This time you have to modify Forms.pas&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Copy Forms.pas to your project folder,&lt;li&gt;find and replace with the following code,&lt;li&gt;and then recompile your project again.&lt;/ol&gt;&lt;br /&gt;&lt;!-- code begin --&gt;&lt;pre name=&quot;code_fd&quot; class=&quot;delphi&quot;&gt;{$IFDEF FIXUP_FORM_POPUP_POSITION}&lt;br /&gt;function GetPrimaryMonitor: TMonitor;&lt;br /&gt;var&lt;br /&gt;  I: Integer;&lt;br /&gt;begin&lt;br /&gt;  for I := 0 to Screen.MonitorCount - 1 do&lt;br /&gt;  begin&lt;br /&gt;    Result := Screen.Monitors[I];&lt;br /&gt;    if Result.Primary then&lt;br /&gt;      Exit;&lt;br /&gt;  end;&lt;br /&gt;  Result := Screen.Monitors[0];&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;procedure CenterFormToPrimaryMonitorCenter(var X, Y: Integer; &lt;br /&gt;  AForm: TCustomForm);&lt;br /&gt;var&lt;br /&gt;  R: TRect;&lt;br /&gt;begin&lt;br /&gt;  R := GetPrimaryMonitor.WorkareaRect;&lt;br /&gt;  X := R.Left + (R.Right - R.Left - AForm.Width) div 2;&lt;br /&gt;  Y := R.Top + (R.Bottom - R.Top - AForm.Height) div 2;&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;procedure SnapFormToMonitorEdgeOnDemand(var X, Y: Integer; &lt;br /&gt;  AForm: TCustomForm);&lt;br /&gt;var&lt;br /&gt;  DistanceLeft, DistanceRight: Integer;&lt;br /&gt;  CenterMon: TMonitor;&lt;br /&gt;  R: TRect;&lt;br /&gt;begin&lt;br /&gt;  CenterMon := Screen.MonitorFromPoint(&lt;br /&gt;    Point(X + AForm.Width div 2, Screen.DesktopHeight div 2));&lt;br /&gt;  R := CenterMon.WorkareaRect;&lt;br /&gt;  // Adjust X-pos&lt;br /&gt;  DistanceLeft  := X - R.Left;&lt;br /&gt;  DistanceRight := R.Right - (X + AForm.Width);&lt;br /&gt;  if (DistanceLeft &lt; 0) and (DistanceRight &lt; 0) then&lt;br /&gt;  begin&lt;br /&gt;    if DistanceLeft &gt;= DistanceRight then&lt;br /&gt;         X := R.Left // Snap to left edge&lt;br /&gt;    else X := R.Right - AForm.Width; // Snap to right edge&lt;br /&gt;  end&lt;br /&gt;  else if (DistanceLeft &lt; 0) or (DistanceRight &lt; 0) then&lt;br /&gt;  begin&lt;br /&gt;    if DistanceLeft &lt; 0 then&lt;br /&gt;         X := R.Left // Snap to left edge&lt;br /&gt;    else X := R.Right - AForm.Width; // Snap to right edge&lt;br /&gt;  end;&lt;br /&gt;  // Adjust Y-pos&lt;br /&gt;  if Y &lt; R.Top then&lt;br /&gt;    Y := R.Top&lt;br /&gt;  else if Y &gt; R.Bottom - AForm.Height then&lt;br /&gt;    Y := R.Bottom - AForm.Height;&lt;br /&gt;end;&lt;br /&gt;{$ENDIF}&lt;br /&gt;&lt;br /&gt;procedure TCustomForm.CMShowingChanged(var Message: TMessage);&lt;br /&gt;// ...&lt;br /&gt;    if (FPosition = poScreenCenter) or&lt;br /&gt;       ((FPosition = poMainFormCenter) and (FormStyle = fsMDIChild)) then&lt;br /&gt;    begin&lt;br /&gt;      if FormStyle = fsMDIChild then&lt;br /&gt;      begin&lt;br /&gt;        X := (Application.MainForm.ClientWidth - Width) div 2;&lt;br /&gt;        Y := (Application.MainForm.ClientHeight - Height) div 2;&lt;br /&gt;      end else&lt;br /&gt;      begin&lt;br /&gt;      {$IFDEF FIXUP_FORM_POPUP_POSITION}&lt;br /&gt;        CenterFormToPrimaryMonitorCenter(X, Y, Self);&lt;br /&gt;      {$ELSE}&lt;br /&gt;        X := (Screen.Width - Width) div 2;&lt;br /&gt;        Y := (Screen.Height - Height) div 2;&lt;br /&gt;      {$ENDIF}&lt;br /&gt;      end;&lt;br /&gt;    {$IFDEF FIXUP_FORM_POPUP_POSITION}&lt;br /&gt;      SnapFormToMonitorEdgeOnDemand(X, Y, Self);&lt;br /&gt;      SetBounds(X, Y, Width, Height);&lt;br /&gt;      //SetWindowToMonitor() will cause unexpected popup position change!&lt;br /&gt;    {$ELSE}&lt;br /&gt;      if X &lt; Screen.DesktopLeft then&lt;br /&gt;        X := Screen.DesktopLeft;&lt;br /&gt;      if Y &lt; Screen.DesktopTop then&lt;br /&gt;        Y := Screen.DesktopTop;&lt;br /&gt;      SetBounds(X, Y, Width, Height);&lt;br /&gt;      if Visible then SetWindowToMonitor;&lt;br /&gt;    {$ENDIF}&lt;br /&gt;    end&lt;br /&gt;    else if FPosition in [poMainFormCenter, poOwnerFormCenter] then&lt;br /&gt;    begin&lt;br /&gt;      CenterForm := Application.MainForm;&lt;br /&gt;      if (FPosition = poOwnerFormCenter) and (Owner is TCustomForm) then&lt;br /&gt;        CenterForm := TCustomForm(Owner);&lt;br /&gt;      if Assigned(CenterForm) then&lt;br /&gt;      begin&lt;br /&gt;        X := ((CenterForm.Width - Width) div 2) + CenterForm.Left;&lt;br /&gt;        Y := ((CenterForm.Height - Height) div 2) + CenterForm.Top;&lt;br /&gt;      end else&lt;br /&gt;      begin&lt;br /&gt;      {$IFDEF FIXUP_FORM_POPUP_POSITION}&lt;br /&gt;        CenterFormToPrimaryMonitorCenter(X, Y, Self);&lt;br /&gt;      {$ELSE}&lt;br /&gt;        X := (Screen.Width - Width) div 2;&lt;br /&gt;        Y := (Screen.Height - Height) div 2;&lt;br /&gt;      {$ENDIF}&lt;br /&gt;      end;&lt;br /&gt;    {$IFDEF FIXUP_FORM_POPUP_POSITION}&lt;br /&gt;      SnapFormToMonitorEdgeOnDemand(X, Y, Self);&lt;br /&gt;      SetBounds(X, Y, Width, Height);&lt;br /&gt;      //SetWindowToMonitor() will cause unexpected popup position change!&lt;br /&gt;    {$ELSE}&lt;br /&gt;      if X &lt; Screen.DesktopLeft then&lt;br /&gt;        X := Screen.DesktopLeft;&lt;br /&gt;      if Y &lt; Screen.DesktopTop then&lt;br /&gt;        Y := Screen.DesktopTop;&lt;br /&gt;      SetBounds(X, Y, Width, Height);&lt;br /&gt;      if Visible then SetWindowToMonitor;&lt;br /&gt;    {$ENDIF}&lt;br /&gt;    end&lt;br /&gt;    else if FPosition = poDesktopCenter then&lt;br /&gt;// ...&lt;br /&gt;end;&lt;/pre&gt;&lt;!-- code end --&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;http://mmjd.com/blog/sh/shCore.js&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;http://mmjd.com/blog/sh/shBrushDelphi.js&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;dp.sh.BloggerMode();dp.SyntaxHighlighter.ClipboardSwf = &#39;http://mmjd.com/blog/sh/clipboard.swf&#39;;dp.SyntaxHighlighter.HighlightAll(&#39;code_fd&#39;);&lt;/script&gt;&lt;br /&gt;&lt;h2&gt;Conclusion&lt;/h2&gt;This issue is nothing. The motivation of this article [2] is to suggest you figure out the differences among DesktopRect, BoundsRect and WorkAreaRect. They are almost the same on one monitor environment. But they are totally different on dual monitors, especially when TaskBar is not at its default position.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;References&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;&lt;a href=&quot;http://qc.codegear.com/wc/qcmain.aspx?d=61539&quot;&gt;Related discuss at QualityCentral.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://blog.csdn.net/Stanley_Xu/archive/2007/02/07/1504745.aspx&quot;&gt;The Chinese version of this article (on my blog @csdn)&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&amp;nbsp;</description><link>http://stanleyxu2005.blogspot.com/2008/05/disappeared-form.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-6248587181589817070</guid><pubDate>Sun, 27 Apr 2008 08:59:00 +0000</pubDate><atom:updated>2009-12-05T22:45:32.096+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">delphi</category><category domain="http://www.blogger.com/atom/ns#">vcl patches</category><title>A not cool thing of TCoolBar</title><description>There is a demo project &quot;coolstuf&quot; in Delphi folder. It demonstrates how to build your own web browser with Delphi. Unfortunately it shows you how to re-procedure an issue of TCoolBar as well. &quot;Just drag the (third) Links toolbar to top and then to bottom, repeat it for several times, you will see an extra area (roughly 40px) at bottom of TCoolBar.&quot; I call this as a &quot;TCoolBar Bands&#39; Position Problem&quot;. If you do not get it, please look at the snapshot.&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;width:100%;text-align:center&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIRv3Ag4gt2gU5YJASkpTuU-7zsb2ZtKAmTsSBhLq8ALL2Dn5BagSHVOtE3DEmaOLBaUZWCQKpBSfO5xAgUYTmfxcbpZVB90gOhaIBP6FWHST3vaKNAq0sfL_PL_uvq_gr5Qzs_IIpsjgf/s1600-h/CoolBar_Problem.png&quot;&gt;&lt;img style=&quot;cursor:pointer; cursor:hand;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIRv3Ag4gt2gU5YJASkpTuU-7zsb2ZtKAmTsSBhLq8ALL2Dn5BagSHVOtE3DEmaOLBaUZWCQKpBSfO5xAgUYTmfxcbpZVB90gOhaIBP6FWHST3vaKNAq0sfL_PL_uvq_gr5Qzs_IIpsjgf/s400/CoolBar_Problem.png&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5193864307418837058&quot; /&gt;&lt;/a&gt;&lt;br/&gt;Snapshot (Red rectangle is the extra area)&lt;/div&gt;&lt;br /&gt;If you have read other posts in my blog, you might know, that I am very uncomfortable with such UI problems. So I did some investigation: This issue take place, when one or more bands have a fixed size. (TCoolBand.FixedSize is True) I suppose, that the height of this (fixed-size) band was not updated, when TCoolBar&#39;s height was changed. Actually, this is not the only one issue of REBAR controls. For instance: No chevron support, no whole dropdown button support, flickering problem, etc. (I will talk about them later in another post)&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Solution&lt;/h2&gt;I have reported this issue to QualityCentral [1]. Not like other patches I have made, this time, the solution is not clean enough. &lt;br /&gt;&lt;br /&gt;You have to:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Copy ComCtrls.pas to your project folder,&lt;li&gt;find and replace with the following code,&lt;li&gt;and then recompile your project again.&lt;/ol&gt;&lt;br /&gt;&lt;!-- code begin --&gt;&lt;pre name=&quot;code_anctot&quot; class=&quot;delphi&quot;&gt;&lt;br /&gt;procedure TCoolBar.CNNotify(var Message: TWMNotify);&lt;br /&gt;//PATCH-BEGIN&lt;br /&gt;var&lt;br /&gt;  I, FID: Integer;&lt;br /&gt;  RBBI: TReBarBandInfo;&lt;br /&gt;//PATCH-END&lt;br /&gt;begin&lt;br /&gt;  if (Message.NMHdr^.code = RBN_HEIGHTCHANGE) then&lt;br /&gt;    if IsAutoSized and (ComponentState * [csLoading, csDestroying] = [])&lt;br /&gt;    then begin&lt;br /&gt;      //PATCH-BEGIN&lt;br /&gt;      for I := 0 to Bands.Count - 1 do&lt;br /&gt;        if Bands[I].FixedSize then&lt;br /&gt;        begin&lt;br /&gt;          FillChar(RBBI, SizeOfReBarBandInfo, 0);&lt;br /&gt;          RBBI.cbSize := SizeOfReBarBandInfo;&lt;br /&gt;          RBBI.fMask := RBBIM_STYLE;&lt;br /&gt;          FID := Bands[I].FID;&lt;br /&gt;          Perform(RB_GETBANDINFO, FID and IDMask, Integer(@RBBI));&lt;br /&gt;          Perform(RB_SETBANDINFO, FID and IDMask, Integer(@RBBI));&lt;br /&gt;        end;&lt;br /&gt;      //PATCH-END&lt;br /&gt;&lt;br /&gt;      ReadBands;&lt;br /&gt;      BeginUpdate;&lt;br /&gt;      try&lt;br /&gt;        if AutoSize then AdjustSize;&lt;br /&gt;      finally&lt;br /&gt;        EndUpdate;&lt;br /&gt;      end;&lt;br /&gt;    end&lt;br /&gt;    else if IsBackgroundDirty then&lt;br /&gt;      Invalidate;&lt;br /&gt;end;&lt;/pre&gt;&lt;!-- code end --&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;http://mmjd.com/blog/sh/shCore.js&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;http://mmjd.com/blog/sh/shBrushDelphi.js&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;dp.sh.BloggerMode();dp.SyntaxHighlighter.ClipboardSwf = &#39;http://mmjd.com/blog/sh/clipboard.swf&#39;;dp.SyntaxHighlighter.HighlightAll(&#39;code_anctot&#39;);&lt;/script&gt;&lt;br /&gt;&lt;h2&gt;Conclusion&lt;/h2&gt;As I mentioned before, REBAR controls (TCoolBar, TCoolBand, TToolBar and TToolButton) have not been implemented correctly as they should be. I did some experiments and made couple of patches. This article [2] is only the part one. There will be part two, part three...&lt;br /&gt;&lt;br /&gt;To note that some patches must modify interface declaration and implementation both. Unfortunately Delphi cannot re-compile those modified units, when their interface declaration has been changed. The only one solution, so far as I known, is to create a copy of the whole REBAR control set and modify the new set. I will be appreciated, if someone can suggest any better ways.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;References&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;&lt;a href=&quot;http://qc.codegear.com/wc/qcmain.aspx?d=61536&quot;&gt;Related discuss at QualityCentral&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://blog.csdn.net/Stanley_Xu/archive/2005/02/11/285743.aspx&quot;&gt;The Chinese version of this article (on my blog @csdn)&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&amp;nbsp;</description><link>http://stanleyxu2005.blogspot.com/2008/04/not-cool-thing-of-tcoolbar.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIRv3Ag4gt2gU5YJASkpTuU-7zsb2ZtKAmTsSBhLq8ALL2Dn5BagSHVOtE3DEmaOLBaUZWCQKpBSfO5xAgUYTmfxcbpZVB90gOhaIBP6FWHST3vaKNAq0sfL_PL_uvq_gr5Qzs_IIpsjgf/s72-c/CoolBar_Problem.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-2658540186258672509</guid><pubDate>Wed, 09 Apr 2008 15:49:00 +0000</pubDate><atom:updated>2008-06-03T14:29:53.968+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">user experience</category><title>Why Safari?</title><description>Why so many people love Mac OS? Is it really fantastic or just the way to express their /&lt;span style=&quot;font-style:italic;font-weight:bold&quot;&gt;unique&lt;/span&gt;/ personality? These years I struggled with myself for buying a Mac or not. As I do not have deep pockets, a simple start can be trying its browser Safari on my windows box...&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;&quot;A good name is a good start for a product.&quot;&lt;/span&gt; After couple of days&#39; testing, my word was proved: Just like its name, Safari is &quot;suffering&quot;. (If I am wrong, please correct me.)&lt;br /&gt;&lt;br /&gt;First of all, there are two good things I mentioned:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;The fonts (except Chinese fonts) are perfect, especially the anti-aliasing effect has impacted me deeply. Text on web pages looks more crisper and easier to read. Although I saw one similar tool to increase the anti-aliasing for Windows, but I prefer to the results of Safari.&lt;/li&gt;&lt;li&gt;When I search some text in a Web page, all matches will be highlighted with an extra large size and in a high contrast color, so that you can find your target easily.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;All other experiences of Safari are really nightmares:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;There is no &quot;New Tab&quot; button on toolbar. Although user can double click on empty area of tab bar, like other browsers. But by default, when there is only one tab opened, tab bar is invisible. Shall I always stick my fingers on keyboard (to press CTRL+T)? Alternatively, user can also open a tab by middle-button clicking on a link. But it is not handy, why so complicated?&lt;/li&gt;&lt;li&gt;The user interface looks material silver. All buttons especially the close tab &quot;X&quot; on each tab are not easy to be identified. By switching tabs I often close a web page by mistake. Even worse is the function &quot;Reopen Last Closed Window&quot; is belt in menu. I get really nervous while switching tabs. One thing to be noted: When multiple Safari instances are running, it might recover the last closed web page of previous instance, not the current.&lt;/li&gt;&lt;li&gt;There is no drop-down button on address bar. When I try to open a frequently visited website, I have to type several chars and then select it from the list. Hui, my fingers will be permanently damaged after using Safari for one month.&lt;/li&gt;&lt;li&gt;The memory usage is huge. Just run Safari will manipulate ca. 40MB memory. After navigating several simple websites, the usage will increase to 100MB-200MB or more. I did the same test in MSIE or FireFox. They use less.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;h2&gt;Conclusion&lt;/h2&gt;Safari is suffering. Most problems (I regard as) are related to usability. Apple is proud of its design. But at least Safari disappointed me. I did not see too many highlights on it. I will still keep this toy for web page compatibility tests and hope something really exciting in next major release.&lt;br /&gt;&amp;nbsp;</description><link>http://stanleyxu2005.blogspot.com/2008/04/why-safari.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-884684681962349745</guid><pubDate>Thu, 24 Jan 2008 02:06:00 +0000</pubDate><atom:updated>2018-09-01T15:11:45.967+02:00</atom:updated><title>Theme updated</title><description>The width of the current theme is fixed. I have updated the css and extend the width from 760px to 900px. &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;DO NOT DELETE THE FOLLOWING THREE IMAGES.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhD7aLWQp0HQikv9bB4hIDrpK2Nxq9DleGKAR4czGcjPtI7Tr2-I1-SG4_gq4-dZkt5nCmvdIoEEgF841ahypWkGV2tZBLyyN9JD3OQAy5xGN7Gjsep4LduUKRrzLcCXbomtO96hk6RVByE/s1600-h/bg_footer_top.gif&quot;&gt;&lt;img style=&quot;cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhD7aLWQp0HQikv9bB4hIDrpK2Nxq9DleGKAR4czGcjPtI7Tr2-I1-SG4_gq4-dZkt5nCmvdIoEEgF841ahypWkGV2tZBLyyN9JD3OQAy5xGN7Gjsep4LduUKRrzLcCXbomtO96hk6RVByE/s400/bg_footer_top.gif&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5158858952386327074&quot; border=&quot;0&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGEDNnn43Ig2fvQ_p-67VzjVEJrf-AHIiV1cTxpWgmLowBaYiiExJ-0mWwV6Iqczjb75X5u7JjVU0zMS949DlR2zqdg5cK57cM1tmm4vVAVXf6LJLlr76w24V-EoJm0NSREEzRFgHeaOMW/s1600-h/bg_header_bottom.gif&quot;&gt;&lt;img style=&quot;cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGEDNnn43Ig2fvQ_p-67VzjVEJrf-AHIiV1cTxpWgmLowBaYiiExJ-0mWwV6Iqczjb75X5u7JjVU0zMS949DlR2zqdg5cK57cM1tmm4vVAVXf6LJLlr76w24V-EoJm0NSREEzRFgHeaOMW/s400/bg_header_bottom.gif&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5158858952386327090&quot; border=&quot;0&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjabOkrHBZjUpevzsWUy5Op4bqI3bmjsq6G_RFJCOJUX2Nz8FdaVTVSpjiYDViS4iVVPAgF6x4IKuMgNyYNL5vDPSoUudQsh6FPVcgREkrSpemRVAFEZ03J99_OJkJ9tyICAWbiBkVejmhw/s1600-h/bg_main_wrapper2.gif&quot;&gt;&lt;img style=&quot;cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjabOkrHBZjUpevzsWUy5Op4bqI3bmjsq6G_RFJCOJUX2Nz8FdaVTVSpjiYDViS4iVVPAgF6x4IKuMgNyYNL5vDPSoUudQsh6FPVcgREkrSpemRVAFEZ03J99_OJkJ9tyICAWbiBkVejmhw/s400/bg_main_wrapper2.gif&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5158858960976261698&quot; border=&quot;0&quot;&gt;&lt;/a&gt;</description><link>http://stanleyxu2005.blogspot.com/2008/01/theme-updated.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhD7aLWQp0HQikv9bB4hIDrpK2Nxq9DleGKAR4czGcjPtI7Tr2-I1-SG4_gq4-dZkt5nCmvdIoEEgF841ahypWkGV2tZBLyyN9JD3OQAy5xGN7Gjsep4LduUKRrzLcCXbomtO96hk6RVByE/s72-c/bg_footer_top.gif" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-7571594833108644978</guid><pubDate>Thu, 10 Jan 2008 17:57:00 +0000</pubDate><atom:updated>2008-06-03T14:30:18.941+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">delphi</category><title>Random thoughts on Unicode</title><description>Recently CodeGear engineers started to talk about Unicode support [1][2][3][4][5] in the next major release of Delphi (codenamed Tiburon [6]). I am still so excited to hear about that, although it should have been done ten years ago.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Is Unicode support a NP-problem?&lt;/h2&gt;You might ask the same question. In fact, a set of Wide-string types have been introduced for many years. But their RTL, VCL and IDE stay in Ansi-version stage. Why not update? IMO: 50% is because of technical issues and 50% is because of their market focus and operative issues. On one hand, a smooth migration is a big challenge, which must be tested completely and seriously. On another hand, their human resource might be limited, so that Unicode support has been shifted several times.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;How about the days without Unicode support?&lt;/h2&gt;Fortunately, some nice guys have created some nice components for us in the most difficult days. The TntControls [7], a collection of basic Unicode enabled RTL and VCL, is one of them. The concept behind TntControls is to override all Ansi-version of string properties and routines with wide-versions. For Win9x platforms, all Wide-something will be casted to Ansi-something at runtime, so that everything works fine for all Windows platforms. But you have to create Wide-version of components and functions one by one. This is time intensive, boring and sometimes a little bit difficult. Furthermore, WideString is not reference counted. It performs /much more/ slower [8] than AnsiString. Unfortunately, nowadays there are few options... &lt;br /&gt;&lt;br /&gt;&lt;h2&gt;What will be done to next Delphi?&lt;/h2&gt;First, a reference-counted new string type UnicodeString will be introduced. Second, all type aliases and function aliases  will be switched from Ansi-version to Wide-version. So that most existed projects can be upgraded to Unicode stage without difficulties or performance lost. It sounds very simple, doesn&#39;t it? Thanks for those genies in advance. &lt;br /&gt;&lt;br /&gt;But there are also two things I do not like:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;The new type name is inconsistent with existed types. AnsiString is equivalent to UnicodeString, but AnsiChar is equivalent to WideChar. I suggest deprecating WideChar as well and introducing a new type UnicodeChar.&lt;li&gt;Type aliases and function aliases are not switchable, which means, that you have to make sure that UnicodeString will NOT break your code. Unfortunately, if your project is not test driven, it is very hard to say...&lt;/ol&gt;&lt;br /&gt;&lt;h2&gt;Conclusion&lt;/h2&gt;So many questions, discusses and requests about the new UnicodeString. No doubt, CodeGear engineers will be quite busy this year. The fully Unicode support is a big challenge to everyone. Are you ready? [9]&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;References&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;&lt;a href=&quot;http://chrisbensen.blogspot.com/2007/11/unicode.html&quot;&gt;Chris Bensen: Unicode&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://chrisbensen.blogspot.com/2007/11/unicode-sizeof-is-different-than-length_15.html&quot;&gt;Chris Bensen: Unicode: SizeOf is Different than Length Part II&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://chrisbensen.blogspot.com/2007/11/unicode-sizeof-is-different-than-length.html&quot;&gt;Chris Bensen: Unicode: SizeOf is Different than Length&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://blogs.codegear.com/abauer/2008/01/09/38845&quot;&gt;The Oracle at Delphi: DPL &amp;amp; Unicode - a toss up&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://blogs.codegear.com/abauer/2008/01/09/38846&quot;&gt;The Oracle at Delphi: More FAQs about Unicode in Tiburón&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://dn.codegear.com/article/36620&quot;&gt;Delphi and C++ Builder Roadmap&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.tmssoftware.com/tmsuni.htm&quot;&gt;TMSUnicode Components (formal TntControls)&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://tobias.feedian.com/2007/05/24/whats-wrong-with-delphis-widestring/&quot;&gt;Tobias Gurock: What’s wrong with Delphi’s WideString?&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://blog.csdn.net/Stanley_Xu/archive/2008/01/11/2035925.aspx&quot;&gt;The Chinese version of this article (on my blog @csdn)&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&amp;nbsp;</description><link>http://stanleyxu2005.blogspot.com/2008/01/random-thoughts-on-unicode_10.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-6546631791284582249</guid><pubDate>Thu, 10 Jan 2008 13:37:00 +0000</pubDate><atom:updated>2009-12-05T22:40:50.739+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">delphi</category><title>Potential memory leaks by initializing a record</title><description>Delphi uses reference-counting with copy-on-write semantics [1][2] to reduce memory allocation for strings (not for WideString). A kind of memory leak was found by accident. Let us first look the following example:&lt;br /&gt;&lt;br /&gt;&lt;!-- code begin --&gt;&lt;pre name=&quot;code_pmlbiar&quot; class=&quot;delphi&quot;&gt;type&lt;br /&gt;  TFoo = record&lt;br /&gt;    StringField: string;&lt;br /&gt;  end;&lt;br /&gt;&lt;br /&gt;procedure CreateLeakTest;&lt;br /&gt;var&lt;br /&gt;  Foo: TFoo;&lt;br /&gt;begin&lt;br /&gt;  FillChar(Foo, SizeOf(Foo), 0);&lt;br /&gt;  Foo.StringField := &#39;Leak Test&#39;;&lt;br /&gt;  FillChar(Foo, SizeOf(Foo), 0); //&lt;--- A leak!&lt;br /&gt;end;&lt;/pre&gt;&lt;!-- code end --&gt;&lt;br /&gt;Initializing records with FillChar() is quite common in Delphi. By calling FillChar() twice, you might create a memory leak. &lt;span style=&quot;color:red&quot;&gt;Note that no leaks on ShortString.&lt;/span&gt; My assumption: FillChar() is unsafe to cleanup records with ref-counted fields. &lt;br /&gt;&lt;br /&gt;&lt;!-- code begin --&gt;&lt;pre name=&quot;code_pmlbiar&quot; class=&quot;delphi&quot;&gt;function StringStatus(const S: string): string;&lt;br /&gt;begin&lt;br /&gt;  Result := Format(&#39;Addr: %p, Refc: %d, Val: %s&#39;,&lt;br /&gt;    [Pointer(S), PInteger(Integer(S) - 8)^, S]);&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;procedure Diagnose;&lt;br /&gt;var&lt;br /&gt;  S: string;&lt;br /&gt;  Foo: TFoo;&lt;br /&gt;begin&lt;br /&gt;  S := Copy(&#39;Leak Test&#39;, 1, 5); // Force to allocate a new string&lt;br /&gt;  WriteLn(StringStatus(S));&lt;br /&gt;  Foo.StringField := S;&lt;br /&gt;  WriteLn(StringStatus(Foo.StringField));&lt;br /&gt;  FillChar(Foo, SizeOf(Foo), 0);&lt;br /&gt;  WriteLn(StringStatus(S));&lt;br /&gt;end;&lt;/pre&gt;&lt;!-- code end--&gt;&lt;br /&gt;The output of the above code looks as follows:&lt;br /&gt;&lt;!-- code begin --&gt;&lt;div class=&quot;codeBlock&quot;&gt;Addr: 00E249E8, Refc: 1, Val: Leak Test &lt;span class=&quot;codeComment&quot;&gt; // A string buffer is allocated&lt;/span&gt;&lt;br /&gt;Addr: 00E249E8, Refc: 2, Val: Leak Test &lt;span class=&quot;codeComment&quot;&gt; // Its Refc is incremented&lt;/span&gt;&lt;br /&gt;Addr: 00E249E8, Refc: 2, Val: Leak Test &lt;span class=&quot;codeComment&quot;&gt; // Its Refc should equal 1 (unexpected)&lt;/span&gt;&lt;/div&gt;&lt;!-- code end --&gt;&lt;br /&gt;After calling FillChar(), the StringField is pointed to nil. However the reference count of its previous string buffer hasn&#39;t been decremented, so that its reference count will NEVER go back to 0. In other words, this string buffer will not be deallocated before your program is terminated. This is a leak.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;How to initialize a record in a safe way?&lt;/h2&gt;As ref-counted fields are not handled correctly by using FillChar(). The default way of initializing a record looks more like an abuse of FillChar. I suggest declare a const record with initial values instead of using FillChar. &lt;br /&gt;&lt;br /&gt;&lt;!-- code begin --&gt;&lt;pre name=&quot;code_pmlbiar&quot; class=&quot;delphi&quot;&gt;const&lt;br /&gt;  EmptyRecordX: TRecordX = (&lt;br /&gt;    Field1: InitVal1;&lt;br /&gt;    Field2: InitVal2;&lt;br /&gt;    ...&lt;br /&gt;    FidldN: InitValN&lt;br /&gt;  );&lt;br /&gt;&lt;br /&gt;// In your application&lt;br /&gt;var&lt;br /&gt;  Foo: TRecordX;&lt;br /&gt;begin&lt;br /&gt;  Foo := EmptyRecordX; // instead of FillChar(Foo, SizeOf(Foo), 0);&lt;br /&gt;  //...&lt;/pre&gt;&lt;!-- code end --&gt;&lt;br /&gt;It is quite safe to initialize a record in this way, isn&#39;t it?&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Alternative Solution&lt;/h2&gt;If you are too lazy to declare such empty record constants. The following function can help you as well. Note that it is a little bit tricky. &lt;br /&gt;&lt;br /&gt;&lt;!-- code begin --&gt;&lt;pre name=&quot;code_pmlbiar&quot; class=&quot;delphi&quot;&gt;procedure InitRecord(out R; RecordSize: Integer);&lt;br /&gt;begin&lt;br /&gt;  FillChar(R, RecordSize, 0);&lt;br /&gt;end;&lt;/pre&gt;&lt;!-- code end --&gt;&lt;br /&gt;Thanks for the magic word &quot;&lt;span style=&quot;font-weight:bold&quot;&gt;out&lt;/span&gt;&quot;. As it is in Help described &quot;An out parameter, like a variable parameter, is passed by reference. With an out parameter, however, the initial value of the referenced variable is discarded by the routine it is passed to. The out parameter is for output only; that is, it tells the function or procedure where to store output, but doesn&#39;t provide any input. &quot; &lt;br /&gt;&lt;br /&gt;Let us see what the code actually has done to a record.&lt;br /&gt;&lt;br /&gt;&lt;!-- code begin --&gt;&lt;pre name=&quot;code_pmlbiar&quot; class=&quot;delphi&quot;&gt;mov edx,[$0040c904]&lt;br /&gt;mov eax,ebx&lt;br /&gt;call @FinalizeRecord  //&lt;----- cleanup&lt;br /&gt;mov edx,$0000000c&lt;br /&gt;call InitializeRecord&lt;/pre&gt;&lt;!-- code end --&gt;&lt;br /&gt;Compile calls procedure FinalizeRecord(), so that a record will be completely finalized.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold&quot;&gt;UPDATE #1:&lt;/span&gt; As Jonas Maebe recently described: &quot;If you have local record which was declared but not yet used, a simple fillchar(rec,sizeof(rec),0) will set everything to 0/nil/empty. If it may have been used earlier and contains ref-counted fields, you first have to call finalize(rec). &quot;[3] His argument is more understandable and closer to the point of the issue.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;References&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Copy-on-write&quot;&gt;Wikipedia: Copy-on-write&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.codexterity.com/delphistrings.htm&quot;&gt;A Brief History of Strings&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.mail-archive.com/fpc-pascal@lists.freepascal.org/msg12219.html&quot;&gt;fpc-pascal maillist&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&amp;nbsp;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;http://mmjd.com/blog/sh/shCore.js&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;http://mmjd.com/blog/sh/shBrushDelphi.js&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;dp.sh.BloggerMode();dp.SyntaxHighlighter.ClipboardSwf = &#39;http://mmjd.com/blog/sh/clipboard.swf&#39;;dp.SyntaxHighlighter.HighlightAll(&#39;code_pmlbiar&#39;);&lt;/script&gt;</description><link>http://stanleyxu2005.blogspot.com/2008/01/potential-memory-leak-by-initializing.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><thr:total>7</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-4993644940416557857</guid><pubDate>Thu, 10 Jan 2008 13:31:00 +0000</pubDate><atom:updated>2014-04-07T06:06:08.952+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">delphi</category><category domain="http://www.blogger.com/atom/ns#">vcl patches</category><title>Way back into native: Tooltip</title><description>I love Delphi because of its components, I hate Delphi also because of its components. If you really care about user interface, you might find many minor differences between a standard Windows application and a Delphi application. For instance: All shortcuts of menu items are right aligned, when the menu is associated with an image list. When you press ALT, the first button on menubar should be selected. Missing support of chevron on toolbar. The tooltip (known as HintWindow in Delphi) looks different from the native tooltip. In this article I will started with tooltip and tell you how to make it nicer.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;Background&lt;/h2&gt;In WindowsXP, even you are very careful, you might probably not mention the difference. A Delphi styled tooltip has a gray edge. (Actually it should be black) And there is no shadow under a tooltip either. This issue was not a real issue, until you upgrade to Windows Vista. A native tooltip in Vista [1][2] has rounded corners. Its background is gradient filled. (See the picture below)&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center; width: 100%;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyu26ePeCPZwL70ak-4yXe3bivjx3avUw2qrhP5u_RGJmcAXcIFLHTLv4wRuGoRZyp3zrxG3yslRYYHqqTEvjvqXFdG9TEGQ_iDQlZgy5R1J9tYVtMvkaTpyCRiI1NN2UzBF5wRUhAavEI/s1600-h/tooltip_compare.png&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyu26ePeCPZwL70ak-4yXe3bivjx3avUw2qrhP5u_RGJmcAXcIFLHTLv4wRuGoRZyp3zrxG3yslRYYHqqTEvjvqXFdG9TEGQ_iDQlZgy5R1J9tYVtMvkaTpyCRiI1NN2UzBF5wRUhAavEI/s400/tooltip_compare.png&quot; id=&quot;BLOGGER_PHOTO_ID_5155752874350927090&quot; style=&quot;cursor: pointer; padding-bottom: 2px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
Delphi style &amp;nbsp; &lt;span style=&quot;font-weight: bold;&quot;&gt;vs.&lt;/span&gt; &amp;nbsp; Windows native style&lt;/div&gt;&lt;br /&gt;
No matter there is a manifest or not, you cannot change a tooltip to its native style. Why? I suppose, that Delphi engineers want to make the HintWindow more customizable, but it is quite difficult to start with the standard TOOLTIPS_CLASS, so they created a HintWindow as a WS_EX_TOOLWINDOW. Now it is easy to build your own styled tooltips, but it is also difficult to reproduce the native style, isn&#39;t it?&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;Solution&lt;/h2&gt;The idea is simple: if you do not intend to customize your tooltip, you can replace WS_EX_TOOLWINDOW with TOOLTIPS_CLASS. I have made a patch. You just have to include the NativeHintWindow.pas in your application and build your project again. Done, your nice tooltip is back. If you are using TntControls (or TMSUnicode Controls), there is an extra editon for you. &lt;a href=&quot;https://code.google.com/p/native-look-vcl/&quot;&gt;Click here to download&lt;/a&gt;. It has been reported to QualityCentral [3] as well.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;In this article [4], I have shown a visibility&#39;s issue of tooltip control (THintWindow) and have also implemented a patch to fix it. I hope Delphi engineers could pay more attention on such kind of issues. More posts about inconsistencies of user interface are coming soon. So stay tuned ;-) &lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;References&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/aa511495.aspx&quot;&gt;MSDN: Tooltips and Infotips&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/aa511331.aspx&quot;&gt;MSDN: Top Guidelines Violations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://qc.codegear.com/wc/qcmain.aspx?d=61537&quot;&gt;Related discuss at QualityCentral&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://blog.csdn.net/Stanley_Xu/archive/2007/02/18/1511572.aspx&quot;&gt;The Chinese version of this article (on my blog @csdn)&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;</description><link>http://stanleyxu2005.blogspot.com/2008/01/native-hint-window-class.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyu26ePeCPZwL70ak-4yXe3bivjx3avUw2qrhP5u_RGJmcAXcIFLHTLv4wRuGoRZyp3zrxG3yslRYYHqqTEvjvqXFdG9TEGQ_iDQlZgy5R1J9tYVtMvkaTpyCRiI1NN2UzBF5wRUhAavEI/s72-c/tooltip_compare.png" height="72" width="72"/><thr:total>8</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-772164822749879307.post-1509937458666751025</guid><pubDate>Thu, 10 Jan 2008 09:23:00 +0000</pubDate><atom:updated>2009-12-05T22:26:50.934+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">delphi</category><category domain="http://www.blogger.com/atom/ns#">vcl patches</category><title>Performance issue of TAction</title><description>If you have never heard about TAction or used it, you are definitely not a Delphi developer ^^)  This component simplifies the UI work. I mentioned once accidentally, that the CPU usage became abnormally high, when mouse was moved quickly on the main form. Spy++ tells, that massive WM_UPDATE message were sent, when mouse was moving fast over the main form. So I took a closer look into the details and found out that TContainedAction.Update() was executed many times by the TActionManager. As it is described in Help &quot;this method triggers the OnUpdate event handler. ... When the application is idle, the OnUpdate event occurs for every action.&quot; The idle status will be changed very frequently. I have more than 100 TAction controls on the main form, which means TContainedAction.Update() was executed more than 100 times in a very short time. This explains, why my application became a CPU usage monster.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Solution&lt;/h2&gt;If your application does not handle any OnUpdate events, it really makes sense to accelerate TContrainedAction.Update().&lt;br /&gt;&lt;br /&gt;My solution is to replace the original method is an empty method.&lt;br /&gt;&lt;br /&gt;&lt;!-- code begin --&gt;&lt;pre name=&quot;code_piot&quot; class=&quot;delphi&quot;&gt;uses&lt;br /&gt;  FastcodePatch {MPL http://fastcode.sourceforge.net/};&lt;br /&gt;&lt;br /&gt;procedure TContainedActionUpdateStub;&lt;br /&gt;asm&lt;br /&gt;  call TContainedAction.Update;&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;type&lt;br /&gt;  TContainedActionPatch = class(TContainedAction)&lt;br /&gt;  public&lt;br /&gt;    function Update: Boolean; override;&lt;br /&gt;  end;&lt;br /&gt;&lt;br /&gt;function TContainedActionPatch.Update: Boolean;&lt;br /&gt;begin&lt;br /&gt;  Result := False;&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;// Disallows the TContainedAction.Update to trigger TAction.OnUpdate()&lt;br /&gt;procedure DisableTContainedActionUpdate;&lt;br /&gt;begin&lt;br /&gt;  FastcodeAddressPatch(&lt;br /&gt;    FastcodeGetAddress(@TContainedActionUpdateStub),&lt;br /&gt;    @TContainedActionPatch.Update);&lt;br /&gt;end;&lt;br /&gt;&lt;/pre&gt;&lt;!-- code end --&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;http://mmjd.com/blog/sh/shCore.js&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;http://mmjd.com/blog/sh/shBrushDelphi.js&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;dp.sh.BloggerMode();dp.SyntaxHighlighter.ClipboardSwf = &#39;http://mmjd.com/blog/sh/clipboard.swf&#39;;dp.SyntaxHighlighter.HighlightAll(&#39;code_piot&#39;);&lt;/script&gt;&lt;br /&gt;The best place to run this patch is in YourForm.OnCreate() event. If you want to make a permanent patch, you can either modify TContainedAction.Update in ActnList.pas directly, or submit it to CodeGear&#39;s quality center.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Conclusion&lt;/h2&gt;In this article [1], I have shown a potential performance issue by using massive TxxxxAction components. I have also implemented a patch to fix this issue. &lt;a href=&quot;http://mmjd.com/blog/code/ActnListPatch.zip&quot;&gt;Here is the patch&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;References&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;&lt;a href=&quot;http://blog.csdn.net/Stanley_Xu/archive/2004/09/10/99874.aspx&quot;&gt;The Chinese version of this article (on my blog @csdn)&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&amp;nbsp;</description><link>http://stanleyxu2005.blogspot.com/2008/01/performance-issue-of-taction.html</link><author>noreply@blogger.com (stanleyxu (2nd))</author><thr:total>1</thr:total></item></channel></rss>