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

Display Text in Tool Tip for Text and Combo Boxes

Tips & Tricks

Display Text in Tool Tip for Text and Combo Boxes

by  Imaginecorp  Posted    (Edited  )
The Code is bascially the same for both except for a few variations:

[Code Textbox]
***** VFP9 with SP 1
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


**************************************************
*-- Form: form1 (\imaginecorp\form11.scx)
*-- ParentClass: form
*-- BaseClass: form
*-- Time Stamp: 02/02/07 12:34:08 AM
*
DEFINE CLASS form1 AS form


Top = 3
Left = 48
Height = 100
Width = 375
DoCreate = .T.
ShowTips = .T.
Caption = "Display Value of TextBox..."
Name = "Form1"


ADD OBJECT command1 AS commandbutton WITH ;
Top = 67, ;
Left = 278, ;
Height = 27, ;
Width = 84, ;
Caption = "Close", ;
Name = "Command1"


ADD OBJECT text1 AS textbox WITH ;
ControlSource = "customer.company", ;
Height = 23, ;
Left = 125, ;
MousePointer = 14, ;
SelectOnEntry = .T., ;
Top = 21, ;
Width = 116, ;
Name = "Text1"


ADD OBJECT label1 AS label WITH ;
AutoSize = .T., ;
Caption = "Company", ;
Height = 17, ;
Left = 60, ;
Top = 25, ;
Width = 55, ;
Name = "Label1"


ADD OBJECT command2 AS commandbutton WITH ;
Top = 67, ;
Left = 182, ;
Height = 27, ;
Width = 84, ;
Caption = "Next", ;
Name = "Command2"


PROCEDURE Load
If Used("customer")
Use In customer
Endif
Select 0
Use Home()+"samples\data\customer.dbf"
ENDPROC


PROCEDURE command1.Click
USE IN customer
thisform.release
ENDPROC


PROCEDURE text1.MouseEnter
Lparameters nButton, nShift, nXCoord, nYCoord
If !Empty(This.Value) And Vartype(This.Value) = "C"
nSize = Fontmetric(6,This.FontName,This.FontSize)
If ((Len(Alltrim(This.Value))*nSize)+nSize) > This.Width
This.ToolTipText = Alltrim(This.Value)
Endif
Endif
ENDPROC


PROCEDURE text1.Init
With This
*set the input mask
If Vartype(.Value) = "C" And Empty(.InputMask)
.InputMask = Replicate("X",Fsize(Justext(.ControlSource)))
Endif
Endwith
ENDPROC


PROCEDURE command2.Click
Select customer
If Not Eof()
Skip 1
Endif
Thisform.Refresh
ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
[/code]

[Code Combobox]
***** VFP9 with SP 1
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


**************************************************
*-- Form: form1 (\imaginecorp\form11.scx)
*-- ParentClass: form
*-- BaseClass: form
*-- Time Stamp: 02/02/07 01:02:12 AM
*
DEFINE CLASS form1 AS form


Top = 3
Left = 48
Height = 100
Width = 375
DoCreate = .T.
ShowTips = .T.
Caption = "Display Value of ComboBox"
Name = "Form1"


ADD OBJECT command1 AS commandbutton WITH ;
Top = 67, ;
Left = 278, ;
Height = 27, ;
Width = 84, ;
Caption = "Close", ;
Name = "Command1"


ADD OBJECT label1 AS label WITH ;
AutoSize = .T., ;
Caption = "Company", ;
Height = 17, ;
Left = 60, ;
Top = 25, ;
Width = 55, ;
Name = "Label1"


ADD OBJECT combo1 AS combobox WITH ;
RowSourceType = 6, ;
RowSource = "customer.company", ;
Height = 24, ;
Left = 123, ;
Top = 21, ;
Width = 134, ;
Name = "Combo1"


PROCEDURE Init
this.combo1.Value = this.combo1.List(this.combo1.TopIndex)
ENDPROC


PROCEDURE Load
If Used("customer")
Use In customer
Endif
Select 0
Use Home()+"samples\data\customer.dbf"
ENDPROC


PROCEDURE command1.Click
Thisform.Release
ENDPROC


PROCEDURE combo1.MouseEnter
LPARAMETERS nButton, nShift, nXCoord, nYCoord
If !Empty(This.displayValue) And Vartype(This.ControlSource)="C"
nSize = Fontmetric(6,This.FontName,This.FontSize)
If ((Len(Alltrim(This.DisplayValue))*nSize)+30) > This.Width
This.ToolTipText = Alltrim(This.DisplayValue)
Endif
Endif
ENDPROC


PROCEDURE combo1.MouseLeave
LPARAMETERS nButton, nShift, nXCoord, nYCoord
This.ToolTipText = ""
ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
[/code]
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top