Delphi: draw title text for Vista using aero like window 7

How to make text (with onClick event) in title bar on Vista with aero How is Windows 7?

alt text http://img529.imageshack.us/img529/3643/immaginembl.jpg

The example in delphi.about.com does not work with Vista with aero. Do you have any ideas?

Thanks to everyone.

Sorry for my bad english.

+6
delphi aero
source share
6 answers

When drawing in a non-client area, the glass automatically turns off. What MS Office does is expand the client region to cover borders. Have a look at the “Drawing in the CNC Glass” section of this WPF article for suggestions. I'm afraid you have to convert API calls to Delphi.

+4
source share

The key is the DwmExtendFrameIntoClientArea API

You can announce this and get the following:

DwmExtendFrameIntoClientAreaFunc = function(destWnd: HWND; const pMarInset: PMargins): HRESULT; stdcall; @fDwmExtendFrameIntoClientArea := GetProcAddress(hDWMDLL, 'DwmExtendFrameIntoClientArea'); 

You also have code already ported here: Transparent windows with Aero

To avoid frames, you name it:

 DWM_ExtendFrameIntoClientArea(Form1.Handle, -1, -1, -1, -1); 

With all this, it should not be difficult to achieve what you want.

+3
source share

In Delphi 2009, TLabel has a new property called "GlowSize" ( see the help ). The effect of setting a positive value for this property is very close to what you seem to be looking for (a glow around the label text).

0
source share

A frame extension is one thing, and drawing Vista thematic (glowing) text is another. With Canvas.TextOut or DrawText, the output is confused with alpha, which will give the effect you got. You need to use DrawThemeTextEx. Here is the correct procedure for drawing text on glass:

 uses Themes, UxTheme; procedure DrawTextOnGlass(Canvas: TCanvas; Text: String; R: TRect); var memoryHdc: HDC; b: TBitmap; dttOpts: TDTTOpts; DR: TRect; bf: TBlendFunction; begin b := TBitmap.Create; try memoryHdc := CreateCompatibleDC(Canvas.Handle); b.Handle := memoryHdc; b.HandleType := bmDIB; b.PixelFormat := pf32bit; b.SetSize(R.Right - R.Left, R.Top - R.Bottom); b.Canvas.Font := Canvas.Font; DR := R; OffsetRect(DR, -DR.Left, -DR.Top); Inflaterect(dr, -5, -5); b.Canvas.Brush.Color := clBlack; b.Canvas.FillRect(DR); dttOpts.dwSize := SizeOf(TDTTOpts); dttOpts.iGlowSize := 8; dttOpts.dwFlags := DTT_COMPOSITED or DTT_GLOWSIZE or DTT_TEXTCOLOR; DrawThemeTextEx(ThemeServices.Theme[teWindow], b.Handle, WP_CAPTION, CS_ACTIVE, Text, -1, DT_CENTER or DT_VCENTER or DT_SINGLELINE or DT_NOPREFIX, DR, dttOpts); if GetLastError <> 0 then RaiseLastOSError; bf.BlendOp := AC_SRC_OVER; bf.BlendFlags := 0; bf.SourceConstantAlpha := 255; bf.AlphaFormat := AC_SRC_ALPHA; AlphaBlend(Canvas.Handle, R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top, b.Canvas.Handle, 0, 0, R.Right - R.Left, R.Bottom - R.Top, bf); finally b.Free; end; end; 
0
source share

Thanks for the DrawTextOnGlass code. But to work, as expected, I needed to replace b.handle b.canvas.handle with DrawThemeTextEx

0
source share

You need one call to DwmSetWindowAttribute, after which everything will be quite simple. Check out this article and especially the comments :) http://delphihaven.wordpress.com/2010/04/22/setting-up-a-custom-title-bar-reprise/

0
source share

All Articles