Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tooltip alternative 1

Status
Not open for further replies.

gjbbroekhuis

Programmer
Jun 11, 2013
17
0
0
NL
Hi,

I'm looking for a native VFP alternative for the default tooltip handling. I need a (bigger / better) tooltip where I can use a chosen font and can use TAB's, spaces and ENTER to position text properly in the tooltip.
The tooltip will be used in a custom labelclass and all label events (like mousedown, mouseenter, mouseleave) should still be accessible and reaponding to mouse events when the tooltip is shown.

Any suggestions please?

Regards, Gerrit
 
I've also had this requirement. I found it quite easy to create what I call an "enhanced" tooltip. Unfortunately, I can't give you the code because it is proprietary to my client, but you should be able to create it for yourself without any difficulty.

Essentially, you create a form. Set its TitleBar to 0 and its Borderstyle also to 0. Add a couple of labels and optionally an image. Set one of the labels to be fairly large with FontBold set to .T. The other label smaller.

At run time, make the form initially invisible. In the MouseEnter event of the control for which you want to display the tooltip, set the captions of the two labels to some suitable text (a heading for the bold label and some further text for the other one), optionaly set the image to a suitable picture, and then make the form visible. In the MouseLeave, make the form invisible again.

I went a little further by maintaining a table that contained the text for the two labels. I gave each of the controls a custom property that held the ID of the corresponding text. So to create a new tooltip, I only had to add a row to the table and set the property in the control.

I suggest you try to do this yourself. It's not particularly difficult.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
As an alternative, you might like to consider this suggestion from Doug Hennig:


He describes a so-called BallonTip, which might meet your needs, but as far as I can see it is does not use native controls. Doug describes its use in conjunction with a listbox, but it should be possible to adapt the method to work with other controls.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike,

Thanks for your suggestions. First I will try your first alternative. Showing the previously hidden tooltipform with MouseEnter works fine.

But what next? The tooltipform has become active and moving the mouse back to the main form does nothing. MouseLeave is never activated because the main form is not active.
How do I get access to the main form's object MouseLeave event?

Regards, Gerrit
 
gjbbroekhuis,
We do something like this with our ribbon bar, which mimics the behavior you see in Office applications. (If you move the mouse into a control, a small box pops up below it, which give information about that control). The way we do this is:
1. We have a custom form, similar to as Mike describes: no border, no header, etc.
2. We have a small table associated with the form that will match the parent objects name to look up the entry in the table. We also take the parent objects icon (if it has one), and we populate that into the small form too. Then the text is split into 3 parts, one for the information, one for "additional details", and one for actions (Press F1 for help, or See <some other object> for additional.
3. When the mouse leaves, the window is hidden. (This is a trick Mike showed us). This way the window is always present, but not always visible. it makes for faster rendering and "deactivation" of the window.


Best Regards,
Scott
MSc ISM, MIET, MASHRAE, CDCP, CDCS, CDCE, CTDC, CTIA, ATS

"I try to be nice, but sometimes my mouth doesn't cooperate.
 
BTW, we don't do it as a tool-tip. We also don't create the object as a formset, rather just a form.
We have a class that we call "RibbonHelp", with one label, one image and 3 OLE fields (as we wanted to be able to use formatted text).

In the Init of the form we have:
LPARAMETERS lnTopWindow, lnLeftWindow, lcCalledFrom, lcButtonPicture, lcHelpString

This helps us position the help window, and passes in where it's called from (so we have the caption of the object), the image used in the object we've "mouseentered" into, and the help string (name of the object which is tied to the table we use for storing the individual help items).

This allows us to have a separate help form as well too, where we can edit/add new help items any time we want. The ONLY thing we have to know is the name of the object (as passed in by lcCalledFrom).

Then in the Got Focus of the object (in this case our ribbon button options), we call:

DO FORM RIBBONHELP WITH OBJTOCLIENT(This.Parent,1)+OBJTOCLIENT(This.Parent,4)+2, OBJTOCLIENT(This,2), This.Buttonlabel1.Caption, This.buttonimagebase1.Picture, (This.Name)

OR

DO FORM RIBBONHELP WITH OBJTOCLIENT(This.Parent,1)+ThisForm.Top+OBJTOCLIENT(This.Parent,4)+2, OBJTOCLIENT(This,2), This.Buttonlabel1.Caption, This.buttonimagebase1.Picture, (This.Name)

(This is braceted code that determins what "level" you're on, as this is all in a TOP LEVEL FORM, so may be there, or may be in a child form. So these two are needed to have the association correct, and the OBJTOCLIENT sets the orientation proximity to the object your "help" is on.

It takes a little patience, and a little cleverness in the process as a whole, but stick with it, and you'll have a nice looking tip help, instead of just the "Tooltip Help" text.

I've attached a screen shot, where the mouse is on the icon "Invoices" in the ribbon bar. (The mouse pointer doesn't appear in the screen shot, because Windows doesn't capture it, but it is there). The small window you see just below the ribbon bar is the result of the class "RibbonBarHelp" that takes the name of the object's caption (Uses it as the title bar in this case bold Invoices, the icon image from the button (uses it below the name as the image for the help), then looks up the objects name in the help table, and produces the 3 blocks of text you see there, based on what is in it. The second block is sometimes empty, so the form will resize when it's not there. If block 3 is empty, it will always show "F1 For Help" by default.



Best Regards,
Scott
MSc ISM, MIET, MASHRAE, CDCP, CDCS, CDCE, CTDC, CTIA, ATS

"I try to be nice, but sometimes my mouth doesn't cooperate.
 
 https://files.engineering.com/getfile.aspx?folder=ec3c41f0-0516-45a2-a9cb-530dfb0c1672&file=DCideTipHelpExample.jpg
Gerrit, it's not the main form's MouseLeave that you need to access. It's the MouseLeave of the control that generates the tooltip. The fact that the mian form doesn't become active is not relevant.

For example, suppose you want to show the tip when the mouse is over a label. In the label's MouseEnter you set the tip form to visible. In the label's MouseLeave you set it to not visible.

Mike







__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
And here is a shot of my own tooltip form.

Like Scott, I have a ribbon bar (very loosely based on the Microsoft Office ribbon). The tooltip form is associated with the buttons on the ribbon. But the idea would work just as well with other controls.

Enahnced_Tooltip_oi67n9.jpg


Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top