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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show tooltip of textbox without moving mouse over it

Status
Not open for further replies.

sergiogove

Programmer
Oct 17, 2002
19
MT
Hi

I want to show the tooltip of a textbox programatically (without moving the mouse over it). Can that be done ?

cheers
sergio.
 
sergiogove

You can programatically display/hide a label to simulate ToolTipText

See faq184-3121 and faq184-3064

FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
But for the ToolTipText itself, no. Tool Tips are by definition activated when the mouse is moved over the object.


Dave S.
[cheers]
 
Well, you certainly can display the ToolTipText of a control programmatically if that is what you wish to do.

wait thisform.txtFirstname.ToolTipText window timeout 10

will do to just test it.

Now you just have to have some means of indicating which control you wish to display the TooltipText for and how to trigger it.



Don
dond@csrinc.com

 
Well, he didn't specify that as a requirement. However, I believe you can indicate coordinates for a wait window.

And you could grab the location of the TOP/LEFT position of the control .... and ... well fool with that as a possibility. Sounds complicated to me.

Or, you could define additional properties for the textbox class .... maybe something like tooltiprow, tooltipcolumn and populate them with the coordinates you wish to use.

There are ways ... you just have to decide if the outcome is worth the effort.



Don
dond@csrinc.com

 
Thanks guys

that was helpful. I was thinking of having sort of a tooltip class and instatnstiate an object of it on each form. then i would have some parameters and pass it to it to show it.

i thought there was an easier way. no probs.

cheers
sergio.
 
Don,

you can indicate coordinates for a wait window.
And you could grab the location of the TOP/LEFT position of the control


Yes, I believe you're right about co-ordinates for the wait window. I expect it's a bit more complicated that you suggested, because the wait window co-ordinates are probably relative to the entire screen, whereas those of the control are relative to the form. Still, it should be do-able.

Mike


Mike Lewis
Edinburgh, Scotland
 
Off the top of my head, isn't it possible to programmatically move the mouse pointer?

If you moved it to be over the text box, wouldn't that trigger the Tool Tip? You could then programmatically move it back to where it should be.

Stewart
 
Well, I looked into it and ....

Yes, there is a MOUSE command which allows you to move the mouse to various locations.

However, I am not sure how the mouse coordinates relate to the TOP/LEFT values associated with the controls.

But it may work out fine. Another option never hurts.




Don
dond@csrinc.com

 
Good point. I probably wouldn't.



Don
dond@csrinc.com

 
Guys

How can i make an object show on top of all the other objects at runtime.

I do not have this object atdesign time so i cannot do it through the layout window

thanks
sergio.
 
sergiogove

You can make your own tooltip yellow messages appear at anytime any place you want. Although coding of it is probably beyond the scope of this forum. But I designed an application where the customer required (so he said), tooltips to appear near a textbox, but the mouse was not at the position, and the second requirement was that the tooltip was multiple lines (which was no available) with the version of VFP at the time and lastly, he required the background to be of a different shade, depending on the user's location in the application.
The API calls that I used for this was CreateRectRgn and CreateRoundRectRgn (for the tooltips to have a round edge instead of the standard square edge). It also use a container class and a timer (to kiil the tooltip after a few seconds). But honestly, after the amount of work involved in the creation, I would suggest you find a more generic alternative.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Ok thanks. I will take your advice and find a better way (possibly easier)

cheers
sergio
 
sergiogove

The following might get you started if you want to pursue the standard looking tooltips activated with something other than the mouse moving over it. This is a basic example that does not make use of the API calls. Copy the following into a program and run it to see the effect:
Code:
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN
DEFINE CLASS form1 AS form
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"
      ADD OBJECT text1 AS textbox WITH ;
		Height = 23, ;
		Left = 24, ;
		Top = 24, ;
		Width = 100, ;
		Name = "Text1"
	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 180, ;
		Left = 108, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Click me!", ;
		Name = "Command1"
	PROCEDURE command1.Click
		oTool=CREATEOBJECT("tooltip","This is the tooltip message...",thisform.text1.Top+thisform.text1.height+25,thisform.text1.Left+thisform.text1.Width)
		oTool.show(1)
	ENDPROC
ENDDEFINE
DEFINE CLASS tooltip AS form
	Top = 0
	Left = 0
	Height = 30
	Width = 312
	DoCreate = .T.
	BorderStyle = 0
	Caption = "Form"
	TitleBar = 0
	AlwaysOnTop = .T.
	BackColor = RGB(255,255,164)
	Name = "tooltip"
	ADD OBJECT shape1 AS shape WITH ;
		Top = 0, ;
		Left = 0, ;
		Height = 29, ;
		Width = 312, ;
		BackStyle = 0, ;
		Name = "Shape1"
	ADD OBJECT timer1 AS timer WITH ;
		Top = 12, ;
		Left = 36, ;
		Height = 23, ;
		Width = 23, ;
		Interval = 3000, ;
		Name = "Timer1"
	ADD OBJECT label1 AS label WITH ;
		BackStyle = 0, ;
		Caption = "Label1", ;
		autosize = .t.,;
		Height = 24, ;
		Left = 3, ;
		Top = 3, ;
		Width = 313, ;
		Name = "Label1"
	PROCEDURE Init
		LPARAMETERS cText,nTop,nLeft
		this.label1.Caption = cText
		this.top = nTop
		this.Left = nLeft
	ENDPROC
	PROCEDURE timer1.Timer
		thisform.Release()
	ENDPROC
ENDDEFINE


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top