Page 1 of 1

Suggestion for TToolTip component

PostPosted: June 4th, 2007, 11:57 am
by Ian Hinson
I've seen code examples on the web about how to use tool tips (balloon tips) in Delphi applications.

Although they were easy to use, they lacked the flexibility to easily set a range of options that tool tips can provide eg. choice of delay time, background colour, icon etc.
One example (first link below), although having better code, even uses global variables which would make it difficult to use that code for more than one tool tip, ie. different tips for different controls.

The example code I'm referring to is here:
http://www.delphipages.com/news/detaildocs.cfm?ID=90
http://www.swissdelphicenter.ch/en/showcode.php?id=1587

The ideal solution would be a "TToolTip" component that enables the programmer to select which TWinControl descendant on the form the tool tip is for, and provides easy selection of the possible options, and entry of its title & text etc.

I'm sure I'm not alone in feeling the Delphi's Hint property fails to "cut it" in modern applications, and does not provide programmers with enough control over the operation of or the appearance of the hint. Tool tips could overcome this.

Hopefully, Kambiz, this is something that you might consider having a look at for future development (someday?).

PostPosted: June 4th, 2007, 4:36 pm
by Kambiz
It's a good idea, thanks.

I'm busy now with some projects. But as soon as I get rid of them, I'll prepare a component for this purpose.

PostPosted: December 18th, 2007, 9:04 pm
by Kambiz
As promised, I developed the tooltip component.
http://delphiarea.com/products/tooltips/

Sorry for being so late.

PostPosted: December 18th, 2007, 9:53 pm
by HPW
The page does not display. Page not found.

The download seems to be:

http://delphiarea.com/products/tooltips/ttm.zip

PostPosted: December 18th, 2007, 9:57 pm
by Kambiz
I think it is like the last time. The page will appear in few hours.

PostPosted: December 19th, 2007, 1:20 pm
by HPW
Now it shows up correctly.

New Tooltip Component Causes AV

PostPosted: December 20th, 2007, 9:00 pm
by w2m
I tried out the new Tooltip component ion Delphi 2007 Update 3, on Vista and it causes an A when you try to delete the component from a form. I had to restart Delphi and manually edit the dfm file to remove it.

PostPosted: December 21st, 2007, 1:16 pm
by Kambiz
Thanks Bill.

I fixed the bug. In addition, added a new event and a read-only property.

PostPosted: December 26th, 2007, 9:02 am
by HPW
The download-hyperlink on the details page points to:

http://delphiarea.com/products/tooltips/profiler.zip

which results in a page not found.

PostPosted: December 26th, 2007, 9:11 am
by HPW
In the ReadMe.htm the Disclaimer is talking about 'TFindfile'.

PostPosted: December 26th, 2007, 9:42 am
by HPW
Testing it under D5 I can not get the CustomIcon to show up!
(I can load them in the IDE into the editor)
Any restrictions in using custom icons?

Edit: I set IconType to ttiCustom
Edit: The space for the icon is preserved, but empty.

Oops: I missed this in the doc:
Note: Shadow and custom icon of tooltips appear if the application has an XP manifest.


Edit: In D7 it works with the XP manifest.

PostPosted: December 26th, 2007, 3:34 pm
by Kambiz
I always make such a mistake on copy and paste. :-&

It is about time to get rid of static pages of delphiarea. I am too lazy for this task, but I have to pass this nightmare.

Thank you.

BTW, for D5 (and earlier) you just need to add the XP manifest resource to the application.

Any example?

PostPosted: May 12th, 2008, 7:25 pm
by vfopersonal
Hi everyone,

I'm wondering if there are any examples how to use TToolTipsManager? I'm a new Delphi user and I couldn't do it work.

Regards,

vfopersonal

How to fix tool tip for Combo Box

PostPosted: March 5th, 2009, 8:58 pm
by Ian Hinson
The tool tips do not pop up for combo boxes. The reason is that a combo box cannot itself activate a tool tip, but instead the combo box's associated edit box is needed to do this.

Below I provide an example of how to make a tool tip work properly for a combo box.
For this example I am using simple code to produce a tool tip taken from
http://www.delphipages.com/news/detaildocs.cfm?ID=90

Code: Select all
// see below for CreateToolTips and AddToolTip procedures from delphipages

procedure TForm1.FormCreate(Sender: TObject);
var
   hComboEdit: HWND;
begin
  CreateToolTips(Form1.Handle);
{ This line added by me makes the combo box tip work properly }
  hComboEdit := GetWindow(ComboBox1.Handle, GW_CHILD);
  AddToolTip(hComboEdit, @ti, 1, 'Tooltip text', 'Title');
{ But this line does (instead of using above) does not work }
// AddToolTip(ComboBox1.Handle, @ti, 1, 'Tooltip text'', 'Title');
end;

procedure CreateToolTips(hWnd: Cardinal);
begin
 hToolTip := CreateWindowEx(0, 'Tooltips_Class32', nil, TTS_ALWAYSTIP or TTS_BALLOON,
   Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT),Integer(CW_USEDEFAULT),
   Integer(CW_USEDEFAULT), hWnd, 0, hInstance, nil);
 if hToolTip <> 0 then
 begin
   SetWindowPos(hToolTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or
     SWP_NOSIZE or SWP_NOACTIVATE);
   ti.cbSize := SizeOf(TToolInfo);
   ti.uFlags := TTF_SUBCLASS;
   ti.hInst := hInstance;
 end;
end;

procedure AddToolTip(hwnd: dword; lpti: PToolInfo; IconType: Integer; Text, Title: PChar);
var
 Item: THandle;
 Rect: TRect;
begin
 Item := hWnd;
 if (Item <> 0) AND (GetClientRect(Item, Rect)) then
 begin
   lpti.hwnd := Item;
   lpti.Rect := Rect;
   lpti.lpszText := Text;
   SendMessage(hToolTip, TTM_ADDTOOL, 0, Integer(lpti));
   FillChar(buffer, sizeof(buffer), #0);
   lstrcpy(buffer, Title);
   if (IconType > 3) or (IconType < 0) then IconType := 0;
   SendMessage(hToolTip, TTM_SETTITLE, IconType, Integer(@buffer));
 end;
end;


Would it be possible Kambiz to correct TToolTipManager so that it can provide tool tips for combo boxes eg. by using a similar technique to that shown above?

Thanks for writing the TToolTipManager component. It's very nice.

Ian

Re: Suggestion for TToolTip component

PostPosted: March 6th, 2009, 5:57 am
by Kambiz
Thanks Ian for the information.

This could be a problem for any compound control. The component is updated with the fix.