Re: Create Custom ToolTips using API
Hello,
I need your help on using the tooltip, for a Combo. In the sense when the Mouse moves over each of the ListItems in the Combo, a respective TootTip must trigger.
Say A,B,C are the listItems, then on mouseOver, a respective Tooltip needs to be displayed.
I guess as the Combo does not have a MouseOver event, will it be possible to establish this using some APIs.
Can you tell me on how to do this?
Thanks & Regards
Ramasubramanian Radhakkrishnan
Re: Create Custom ToolTips using API
You need to subclass the combo and then trap for the event that if fired when moving the mouse over the items. I am afraid I don't know what the exact windows msg is that you would have to handle.
If you look in the tooltips project there is a module called modMsgHook. This is used to subclass the tooptip window. This can also be used to subclass the combo box.
You can only set opne tooltip for each control, so once you handle the moveover event you need to change the entire tooltip for the combo. An example of this is shown in the demo app using the listview control...as the mouse moves over each listitem the listviews tooltip gets changed.
Hope this helps.
Woka
Re: Create Custom ToolTips using API
Just a thought, but any chance of adding code for clickable links in the tooltip?
Re: Create Custom ToolTips using API
That is perfectly possibe, however, I have not developed in VB6 for 2-3 years now and I have stopped maintaining and adding features to my VB6 source codes.
Feel free to give it a go yourself.
Woka
Re: Create Custom ToolTips using API
Hi,
I am using your code in my software and it is working 100% fine. But I would be really grateful if it will be applicable on the following conditions:
Is is possible to show tooltips on controls (having .text property) without mouse intervention. If I come straight to the point, can the tips be shown on control_change() event or control_gotfocus() event.
Re: Create Custom ToolTips using API
Yes. Just trap the msg in the message handler class and call the draw tooltip function.
Woka
Re: Create Custom ToolTips using API
Quote:
Originally Posted by Wokawidget
Yes. Just trap the msg in the message handler class and call the draw tooltip function.
Woka
Could you just show me how to handle the events cos' I have no idea. It would be thankful if you show both ways:
1. TextBox_Change()
2. TextBox_GotFocus()
Re: Create Custom ToolTips using API
Quote:
Originally Posted by Wokawidget
ths is because it uses the control name for a key, and the control name is the same for all controls in an array. U need to modify the code to change the key it's saving in the collection when adding a tooltip to a control.
Woka
Hi Woka ,
Thanks your work of this, Can you guide me how to save the control array to the collection ?
Thanks woka :-)
Re: Create Custom ToolTips using API
I dont have a machine with VB6 on it I am afraid, so can't test this.
But in the function that adds the control to the collection it uses the controls name as the key.
You need to modify that 1 line of code so that it:
a) Tests if the control is part of an arry
b) If so then get index of control and add that to the control name to get your unique key
c) You need to modify the code where it gets the control tooltip from the array in the same manner. it needs the index adding to the name.
Woka
Re: Create Custom ToolTips using API
Thanks woka,
I will try your suggested method..
NuFLaVoRs
Re: Create Custom ToolTips using API
Anyone know how to get the tooltip to work with a LABEL. It seems to work with most other controls...
Re: Create Custom ToolTips using API
This is because the code requires the control to have a handle, hWnd, which a label simply does not have.
You will need to create your own label usercontrol that has a hWnd property. This is simply a limitation of a VB6 label, nothing really you can do about it.
Do a search on google for this code.
Woka
Re: Create Custom ToolTips using API
Anyone know how to only bold a part of the text you want in the tooltip and not all of it?
Re: Create Custom ToolTips using API
I have tried this tooltip out and it works great. However, I ran into a problem if the tooltip is set on a button and the button launches a form. The tooltip doesn't appear for that button anymore.
In the "Stage 10" code, if you add an empty form and paste this code into one of the buttons click events:
Code:
Dim f As Form1
Set f = New Form1
f.Show vbModal
Set f = Nothing
If you hover over the button before clicking, the tip shows up. After clicking and dismissing the form it doesn't show up any more. Any ideas?
Thanks...
Re: Create Custom ToolTips using API
Quote:
Originally Posted by drag0n_45
Anyone know how to only bold a part of the text you want in the tooltip and not all of it?
This would be a lot more complex to handle...off the top of my head you could pass in text like: "This is <b>MY</b> tooltip", and then in the code that writes the message you would have to validate your text and write different bits out with different formatting.
The code does not handle this natively as it stands now.
Woka
Re: Create Custom ToolTips using API
Quote:
Originally Posted by fenrisW0lf
I have tried this tooltip out and it works great. However, I ran into a problem if the tooltip is set on a button and the button launches a form. The tooltip doesn't appear for that button anymore.
In the "Stage 10" code, if you add an empty form and paste this code into one of the buttons click events:
Code:
Dim f As Form1
Set f = New Form1
f.Show vbModal
Set f = Nothing
If you hover over the button before clicking, the tip shows up. After clicking and dismissing the form it doesn't show up any more. Any ideas?
Thanks...
This is because you used vbModal.
This locks the Form1 as the top most form in a windows app. The form below it does not receive mouse events.
I do not have VB6 installed on this PC anymore, but from what I can remember even a normal default vb6 tooltip would fail on this.
Woka
Try using vbModeless instead.
Re: Create Custom ToolTips using API
I found this thread very helpful and the code supplied here works perfectly, except one thing... From version 2 it doesn't work with non-English text... I try to print something in Greek and it doesn't work... Only the first version displays Greek correctly...
Anyone has an idea?
PS I know this is a very old thread and i probably won't get an answer...
Re: Create Custom ToolTips using API
this is good but does not support labels, has anyone modified it or knows of one similar that does labels as well