Sunday, April 27, 2008

A not cool thing of TCoolBar

There is a demo project "coolstuf" 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. "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." I call this as a "TCoolBar Bands' Position Problem". If you do not get it, please look at the snapshot.

Snapshot (Red rectangle is the extra area)

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'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)


I have reported this issue to QualityCentral [1]. Not like other patches I have made, this time, the solution is not clean enough.

You have to:
  1. Copy ComCtrls.pas to your project folder,
  2. find and replace with the following code,
  3. and then recompile your project again.

procedure TCoolBar.CNNotify(var Message: TWMNotify);
I, FID: Integer;
RBBI: TReBarBandInfo;
if (Message.NMHdr^.code = RBN_HEIGHTCHANGE) then
if IsAutoSized and (ComponentState * [csLoading, csDestroying] = [])
then begin
for I := 0 to Bands.Count - 1 do
if Bands[I].FixedSize then
FillChar(RBBI, SizeOfReBarBandInfo, 0);
RBBI.cbSize := SizeOfReBarBandInfo;
FID := Bands[I].FID;
Perform(RB_GETBANDINFO, FID and IDMask, Integer(@RBBI));
Perform(RB_SETBANDINFO, FID and IDMask, Integer(@RBBI));

if AutoSize then AdjustSize;
else if IsBackgroundDirty then


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...

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.


  1. Related discuss at QualityCentral
  2. The Chinese version of this article (on my blog @csdn)

Wednesday, April 9, 2008

Why Safari?

Why so many people love Mac OS? Is it really fantastic or just the way to express their /unique/ 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...

"A good name is a good start for a product." After couple of days' testing, my word was proved: Just like its name, Safari is "suffering". (If I am wrong, please correct me.)

First of all, there are two good things I mentioned:

  1. 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.
  2. 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.

All other experiences of Safari are really nightmares:
  1. There is no "New Tab" 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?
  2. The user interface looks material silver. All buttons especially the close tab "X" 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 "Reopen Last Closed Window" 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.
  3. 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.
  4. 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.


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.