Suggestion for TToolTip component

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

Suggestion for TToolTip component

Postby Ian Hinson » June 4th, 2007, 11:57 am

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
Active Member
 
Posts: 9
Joined: June 20th, 2004, 12:31 pm
Location: Melbourne, Australia

Postby Kambiz » June 4th, 2007, 4:36 pm

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
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby Kambiz » December 18th, 2007, 9:04 pm

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

Sorry for being so late.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby HPW » December 18th, 2007, 9:53 pm

The page does not display. Page not found.

The download seems to be:

http://delphiarea.com/products/tooltips/ttm.zip
Hans-Peter
HPW
Moderator
Moderator
 
Posts: 230
Joined: February 25th, 2006, 10:19 am
Location: Germany

Postby Kambiz » December 18th, 2007, 9:57 pm

I think it is like the last time. The page will appear in few hours.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby HPW » December 19th, 2007, 1:20 pm

Now it shows up correctly.
Hans-Peter
HPW
Moderator
Moderator
 
Posts: 230
Joined: February 25th, 2006, 10:19 am
Location: Germany

New Tooltip Component Causes AV

Postby w2m » December 20th, 2007, 9:00 pm

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
Senior Member
 
Posts: 76
Joined: March 8th, 2003, 7:11 pm
Location: New York, USA

Postby Kambiz » December 21st, 2007, 1:16 pm

Thanks Bill.

I fixed the bug. In addition, added a new event and a read-only property.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby HPW » December 26th, 2007, 9:02 am

The download-hyperlink on the details page points to:

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

which results in a page not found.
Hans-Peter
HPW
Moderator
Moderator
 
Posts: 230
Joined: February 25th, 2006, 10:19 am
Location: Germany

Postby HPW » December 26th, 2007, 9:11 am

In the ReadMe.htm the Disclaimer is talking about 'TFindfile'.
Hans-Peter
HPW
Moderator
Moderator
 
Posts: 230
Joined: February 25th, 2006, 10:19 am
Location: Germany

Postby HPW » December 26th, 2007, 9:42 am

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
Moderator
 
Posts: 230
Joined: February 25th, 2006, 10:19 am
Location: Germany

Postby Kambiz » December 26th, 2007, 3:34 pm

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
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Any example?

Postby vfopersonal » May 12th, 2008, 7:25 pm

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
Member
 
Posts: 1
Joined: May 12th, 2008, 7:21 pm

How to fix tool tip for Combo Box

Postby Ian Hinson » March 5th, 2009, 8:58 pm

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
Ian Hinson
Active Member
Active Member
 
Posts: 9
Joined: June 20th, 2004, 12:31 pm
Location: Melbourne, Australia

Re: Suggestion for TToolTip component

Postby Kambiz » March 6th, 2009, 5:57 am

Thanks Ian for the information.

This could be a problem for any compound control. The component is updated with the fix.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 1 guest

cron