Delphi, WinXP and Password Edits

I’m still into making Delphi apps look more “native” when run under Windows XP. Now that I got the IE-Control working, I was looking into the password-edit case.

The Problem: When using the standard way for creating password edits (Drop a TEdit on the Form and set the PasswordChar property to ° ), this may look and work on in Win 9x, NT and 2000, but under XP, some features are missing:

  • In XP, password-edits cannot be read from other applications by sending the WM_GETTEXT message. Delphi’s TEdit can.
  • In XP, the edits have a nice bullet instead of a * to mark the entered characters
  • When CapsLock is active, a balloon-hint appears warning the user that maybe she is not doing what she expects

    How to fix this?

    Simple: Create a descendant of TEdit, override CreateParams and set the controls style to ES_PASSWORD. Provided you are supplying a valid Manifest for XP, you now have a fully fledged and nice working password-edit:

    procedure TPasswordEdit.CreateParams(var Params: TCreateParams);
      Params.Style := Params.Style or ES_PASSWORD;

    Oh. One thing is still missing: The dots look wrong. This is because Delphi does not use Windows’ standart font per default but overrides this with “MS Sans Serif” where “Tahoma” is the standard under XP. So Delphi-Apps generally look kind of foreign – even more so, when ClearType is enabled (MS Sans Serif is a bitmap font and cannot be antialiased).

    This can be fixed by setting each forms DesktopFont property to true. Note that it’s a protected property, so it must me called from withing the form.

    Now the bullets look right and the font’s in your application are proper anti-aliased (provided ParentFont is set to true in every component on the form).


Easier to use? Cheaper because of that? Dream on!

The Exchange Server I already had strange problems [read this and related postings there] with, today had another one of them. I had to give reading-permission to some public folder to some users (although the GUI to do that from within Outlook is really easy to use, some people rely on me doing that for them because that’s even easier).

The Exchange Server Manager threw a strange message at me whenever I tried to expand the folder-list in the tree. The text was useless as ever and nothing was posted to the event-logs – as ever. Why is there a logging-framework if it is not used? (besides, if it would have been used, the message would have been just as un-understandable as the one I was getting).

This time, I was lucky: I got an error number along with the message that was even known to the knowledgebase. The error was 80040e19 and the knowledgebase article was Q328659.

The problem was easy to fix and had something to do with some “security-tool” that got installed alongside the IIS-Lockdown tool which itself got installed alongside the common Windows-Update procedure. Nice to know that just updating the system via such an easy procedure can bring essential functions down without any warning.

Microsoft always emphasises the ease of use of their products and the better support you are getting when using their closed source solutions. Granted: The “ease of use”-thing can sometimes really be true (many things just work out-of-the box with not nearly as much work as I would have when using a common linux distribution), but when something does not work, fixing microsofts server software is much more difficult than fixing equivalent linux software as the fixes are un-obvious and the error messages are unusable.

The level of support for me is just the same as with comparable open-source software: Use google, enter the error message you get and pray someone had a fix for it posted somewhere. If not, I see virtually no solution in Microsoft land (besides paying a lot of money for support) whereas in the open-source land I would be able to fix the problem sometime later as I have readable error-messages and if that does not help I could try to understand the problem by reading the sourcecode.

That’s why I usually prefer open solutions. Or have you ever seen software working flawlessly?

Java and native libraries

As you may know, I am working with barcode scanners – actually it’s all about my companies product PopScan which is a software-tool for accessing a nice little barcode scanner which is essentially a barcode scanner and nothing more and thus quite inexpensive.

We have two similar products: One is the enterprise version which is sort of a framework for implementing custom made barcode solutions. Two quite big companies here in Switzerland are already using it (just visit PopScan’s webpage to learn more, I won’t make any more sales-pitches here).

The other product – PopScan SMB – is a out-of-the-box solution for small and medium businesses which allows them to provide a easy to use barcode ordering system to their customers (ok. now I’m really finished sales-pitching. I’m coming to the technical aspects…)

PopScan SMB is largely webbased: On the client side we have a very little application that does nothing but hanging there and wait for a scanner to be connected. When that happens, it reads the scanned codes and displays (using the IE ActiveX control) the webpage with the filled shoppingcart – very nice and simple.

The drawback so far was that we could only support Windows with this solution (written in Delphi – but as a reader of this blog, you may know that already). The point is that we got quite some requests to get this to work on the Mac and additionally we have some ideas involving Linux….

As I wanted to learn Java for quite some time now, I deceided to rework the thing as a Java-Thing (Applet, Webstart, see below).

The first Problem was accessing the serial port where the scanner is connected to. Possible? Yes. Sun has created a specification for accessing serial and paralell ports and provided a sample implementation for Windows and Solaris.

If you want support for all the other OSes and if you want a solution that is acutally working, I propose, you have a look at the library from SerialIO which is what I’m using. Works like a charm and is definitely worth the money.

Next problem: How do we install the thing on the clients and how do we keep it upgraded? Two solutions come to my mind:

  1. Java WebStart: Just put a JNLP-File somewhere on your server and link to it. The browser downloads it and Java WebStart does the rest, meaning installing and keeping the software updated. The big advantage: The mechanism has explicit support for native libraries (what this blog entry is about) and works quite nicely. The disadvantages: 1) I’m not sure whether does use appropriate preconfigured proxy servers which is a requirement for the solution to be usable (quite a lot of our possible customers have quite strict firewalls and forced proxies) and 2) it does not work on Mac OS < X which has only Java 1.1
  2. Java Applet: Put it on a wepage which the user opens and that’s it. No installation necessary, Proxy-Support, Java 1.1 support – you name it. The optimal solution if there were not that small little problem: No support for native libraries (which I have to install to access the serial port). Anyhow: The applet is what I did

    (actually there is a third solution: Create a “normal” application and a platform-specific installer and let the user install and run it. This would work, but would force me to again create a special auto-update-mechanism and it would require quite a lot of user-intervention.

    So it all can be broken down to the one question: How to handle native libraries with Java-Applets?`

    The answer is as simple as the question:

    1. Write your code
    2. When the library is accessed for the first time and can’t be loaded, a java.lang.UnsatisfiedLinkError is thrown. Catch it and…
    3. … download the required libraries to the local computer into the correct directory
    4. Tell the user to restart the browser

      Of course your applet has to be signed for this to work, but this can be done quite nicely in a Ant-Task.

      Where to download the file to?

      Into some directory in java.library.path, where each platform has its preferred location (which is – by the way not what the SerialIO-Documentation suggests):

      <table border=0>

      Windows {java.home}/bin OS X (Java 1.3) somewhere under /System which is bad OS X (Java 1.4) ~/Library/Java/Extensions

      (I must check OS 9 later)

      Safari uses Java 1.4, where both IE and Mozilla (Camino, Firebird and Mozilla itself) use 1.3.

      The problem with MacOS’es 1.3 library path is that it’s never writable by the user currently logged in (not even she’s in the admin group). To put a file there within the Finder, you must authenticate yourself as super-user (which calls sudo somewhere under the hood) which is not possible from within java.

      The solution: The current directory “.” is also in java.library.path. On Richards mac, . pointed to the root of the harddrive “Macintosh HD” (/), which is writable by users of the admin group. So for now installing the library under “.” when using the 1.3 VM does work as long as the current user is an administrator, which is the same requirement like under windows and can be explained somewhere in the handbook or on the webpage. Problem solved (Safari users have the advantage of being able to use the applet even without the admin installing the native library first as a directory in the users homedir is in the library path in 1.4)

      I really searched the web before writing this entry and I’ve not found anything about applets and native libraries (especially not under Mac OS). Maybe there is a simpler way to do what I am doing. I’d be glad to hear from you!

Keyboard review

This review of logitechs diNovo wireless desktop was slashdotted today. I wonder why the reviewer does not say anything about the stupid size of the delete key which actually spans both rows of this 2 by three row with the page-up/down, home and end keys. Insert is where you exspect scroll-lock to be which is missing.

You can’t believe how many times I mass-deleted some files in Total Commander instad of just marking them.

Then again, maybe this layout will be the new “standard”: Looking at the other reviewed desktops, the one from Microsoft also has this layout and because of the slashdot-effect I cannot check out the others.

By the way: Besides this delete-problem, the diNovo is the best keyboard I ever had so far: Great typing-feeling, great design and good access-technology (it you can live with this)

Delphi, Windows XP, Styles and embedded IE

Let’s say you have a delphi (delphi 7 – altough prior versions can use Mike Lischkes Theme Manager application which embedds the Microsoft Internet Explorer ActiveX Control. Let’s assume furhter that you have created your Manifest so the application appears in the themed style under Windows XP.

Unfortunatly, the embedded IE does not do that: Controls are still drawn in the old theme-less style. Why? How to tell the Control to use the themed style (which it certainly supports – just look at IE itself)?

For long I was looking for a solution which I’ve just found.

First, call SetThemeAppProperties (defined in UxTheme.pas), then send WM_THEMECANGED to your forms – at least to the one that uses the IE-Control. Example:

  SetThemeAppProperties( STAP_ALLOW_NONCLIENT OR
  PostMessage(frmBrowser.Handle, WM_THEMECHANGED, 0, 0);

Especially important is the flag STAP_ALLOW_WEBCONTENT

Then, in the form containing the browser, just add a message-procedure:


    procedure wmthemechanged (var msg: TMessage); message wm_themechanged;

Update: I’ve turned off the comment-feature as this entry somehow got listed in some spammers database. I’m currently deleting about 10 entries per day that are just there to provide links to some stange sites. I’ll post about this later.

Fun with Logitech

I recently bought the diNovo Media Desktop from Logitech: I really liked it’s design and the bluetooth-support as this is the only really usable way for wireless equipement (no problems with multiple devices per room, encryption, … you name it)

The problem was: The driver on the CD-ROM installed just another Widcomm Bluetooth-stack which despite being the same piece (down to the version) of software that was installed with my think pad’s internal bluetooth-adaptor (you will have to update to version 1.4 on IBM’s webpage to use the HID-profile), was not compatible with the prior Widcomm-Software (which is a political/legal problem and has no technical reasons at all).

So, when using the diNovo-drivers, the internal bluetooth-adaptor does not work (too bad when trying to use your cellphone to connect to the internet when other means of connectivity are not availabe), and when not using them, I cannot configure the special keys and the media-player support (which is stupid anyway as it does not support Winamp).

My final solution was to revert back to only IBM’s internal driver and pair the logitech devices whith that one (hint: the mouse uses the key 0000). Installing set point which would work perfectly well with IBM’s BT-stack (as it’s the same as logitechs), was not possible beacuse the logitech BT adaptor could not be found. Ergo: No media keys, but at least a really nice keyboard and mouse together with a working BT-support.

Talk about BT-interoperability…

I really look forward to the Windows-integrated BT-stack (which probably will be the widcomm one too – just look at the stack of Windows Mobile 2003)