## Suggestion for TToolTip component

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

### Suggestion for TToolTip component

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?).
Ian Hinson
Active Member

Posts: 9
Joined: June 20th, 2004, 12:31 pm
Location: Melbourne, Australia

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.
Kambiz

Kambiz

Posts: 2424
Joined: March 7th, 2003, 7:10 pm

As promised, I developed the tooltip component.
http://delphiarea.com/products/tooltips/

Sorry for being so late.
Kambiz

Kambiz

Posts: 2424
Joined: March 7th, 2003, 7:10 pm

http://delphiarea.com/products/tooltips/ttm.zip
Hans-Peter
HPW
Moderator

Posts: 236
Joined: February 25th, 2006, 10:19 am
Location: Germany

I think it is like the last time. The page will appear in few hours.
Kambiz

Kambiz

Posts: 2424
Joined: March 7th, 2003, 7:10 pm

Now it shows up correctly.
Hans-Peter
HPW
Moderator

Posts: 236
Joined: February 25th, 2006, 10:19 am
Location: Germany

### New Tooltip Component Causes AV

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.
w2m
w2m
Senior Member

Posts: 76
Joined: March 8th, 2003, 7:11 pm
Location: New York, USA

Thanks Bill.

Kambiz

Kambiz

Posts: 2424
Joined: March 7th, 2003, 7:10 pm

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

Hans-Peter
HPW
Moderator

Posts: 236
Joined: February 25th, 2006, 10:19 am
Location: Germany

Hans-Peter
HPW
Moderator

Posts: 236
Joined: February 25th, 2006, 10:19 am
Location: Germany

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.
Hans-Peter
HPW
Moderator

Posts: 236
Joined: February 25th, 2006, 10:19 am
Location: Germany

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.
Kambiz

Kambiz

Posts: 2424
Joined: March 7th, 2003, 7:10 pm

### Any example?

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
vfopersonal
Member

Posts: 1
Joined: May 12th, 2008, 7:21 pm

### How to fix tool tip for Combo Box

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 delphipagesprocedure 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
Ian Hinson
Active Member

Posts: 9
Joined: June 20th, 2004, 12:31 pm
Location: Melbourne, Australia

### Re: Suggestion for TToolTip component

Thanks Ian for the information.

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

Kambiz