Mega Code Archive

 
Categories / Delphi / Examples
 

How to create an application hint like WinZip

Title: How to create an application hint like "WinZip" Question: When you points over an zip file with WinZip installed, Windows Explorer shows and window hint with Zip's information. Create an window hint like WinZip with this unit. Simple add this in your project manager and your application will be ready to show hints like WinZip. Answer: unit untHint; interface uses Windows, Controls, Forms, Graphics; type TAppHintWindow = class ( THintWindow ) protected procedure Paint; override; function CalcHintRect ( MaxWidth: Integer; const AHint: string; AData: Pointer ): TRect; override; end; implementation function TAppHintWindow.CalcHintRect; var r: TRect; begin r := inherited CalcHintRect ( MaxWidth, AHint, AData ); inflateRect ( r, 6, 3 ); result := r; end; procedure TAppHintWindow.Paint; var R: TRect; begin with Canvas do begin R := ClientRect; Brush.Color := $00EAFFFF; FillRect ( r ); Font.Name := 'Tahoma'; Inc ( R.Left, 7 ); Inc ( R.Top, 5 ); DrawText ( canvas.Handle, PChar ( Caption ), -1, R, DT_LEFT or DT_NOPREFIX or DT_WORDBREAK ); end; end; initialization HintWindowClass := TAppHintWindow; end.