Custom title bars – reprise

It’s been several months, but as a small follow up to my Vista/Windows 7 custom title bar posts back last spring, I’ve finally been able to fix a bug that the code exhibited when running on 64 bit versions of Windows 7 (and quite possibly Vista too, though no one reported that) — for in short, you could quite easy get ‘ghost’ buttons appear:

Ghost button bug

The fix ended up being to amend the WM_NCHITTEST handler to never return HTMINBUTTON, HTMAXBUTTON or HTCLOSE, and I’ve edited my original post to reflect this. I’ve also fixed the small demo I wrote afterwards, adding to it an even smaller console application to patch an EXE to require Vista or later, which allows the full range of form border styles to be customised (the demo is downloadable here).

Advertisements

5 thoughts on “Custom title bars – reprise

  1. Thanks a lot!
    Now it works OK for me (Win7 64bit), can also add some text to the titlebar to the right:
    DrawGlassCaption(Self, ‘extra text’, R, True, taRightJustify);

    However, buttons and toolbars on titlebar do not work (painted transparent, outlined text, etc) but a speedbutton is painted OK but does not respond to click event. Do you know how to fix this?

      • Ah, I understand now, thanks. Have a read of my post on the topic of controls and glass: https://delphihaven.wordpress.com/2010/07/29/controls-and-glass/. The short version is that since controls like TButton and TToolBar simply wrap underlying widgets of the OS, and the OS’ native widgets don’t expect to be drawn on glass, they don’t work well. Nonetheless, check out the post I’ve just linked to for getting things better than you’ve so far achieved — do two small things, and the controls will be OK if you can stand an opaque background…

        The reason a text-only TSpeedButton (along with TLabel) works properly, in contrast, is because CodeGear (as then was) added code to make it so — while it uses the OS’ theming API (if available), TSpeedButton is not a native widget, and thus, is much easier to ‘make right’ when it comes to glass.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s