INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Tips & Tricks

Display Text in Tool Tip for Text and Combo Boxes by Imaginecorp
Posted: 4 Feb 07

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 --> 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

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close