home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / source / chap22 / tooltip.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-24  |  3.0 KB  |  98 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   2730
  5.    ClientLeft      =   6705
  6.    ClientTop       =   4920
  7.    ClientWidth     =   3885
  8.    Height          =   3135
  9.    Left            =   6645
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   2730
  12.    ScaleWidth      =   3885
  13.    Top             =   4575
  14.    Width           =   4005
  15.    Begin VB.Timer Timer1 
  16.       Left            =   120
  17.       Top             =   120
  18.    End
  19.    Begin VB.PictureBox Picture1 
  20.       BeginProperty Font 
  21.          name            =   "MS Sans Serif"
  22.          charset         =   0
  23.          weight          =   400
  24.          size            =   9.75
  25.          underline       =   0   'False
  26.          italic          =   -1  'True
  27.          strikethrough   =   0   'False
  28.       EndProperty
  29.       Height          =   495
  30.       Left            =   360
  31.       ScaleHeight     =   435
  32.       ScaleWidth      =   1155
  33.       TabIndex        =   2
  34.       Top             =   120
  35.       Width           =   1215
  36.    End
  37.    Begin VB.CommandButton Command2 
  38.       Caption         =   "Command2"
  39.       Height          =   495
  40.       Left            =   1560
  41.       TabIndex        =   1
  42.       Top             =   1680
  43.       Width           =   1215
  44.    End
  45.    Begin VB.CommandButton Command1 
  46.       Caption         =   "Command1"
  47.       Height          =   495
  48.       Left            =   240
  49.       TabIndex        =   0
  50.       Top             =   1680
  51.       Width           =   1215
  52.    End
  53. Attribute VB_Name = "Form1"
  54. Attribute VB_Creatable = False
  55. Attribute VB_Exposed = False
  56. Option Explicit
  57. Private Declare Function SetCapture Lib "user32" _
  58.     (ByVal hwnd As Long) As Long
  59. Private Declare Function ReleaseCapture Lib "user32" () As Long
  60. Private Sub Command1_Click()
  61.     Timer1.Enabled = False
  62.     ReleaseCapture
  63.     Picture1.Visible = False
  64. End Sub
  65. Private Sub Command1_MouseMove(Button As Integer, _
  66.     Shift As Integer, x As Single, y As Single)
  67.     If x > Command1.Width Or x < 0 Or y > Command1.Height Or y < 0 Then
  68.         Timer1.Enabled = False
  69.         ReleaseCapture
  70.         Picture1.Visible = False
  71.     Else
  72.         If Not Picture1.Visible Then
  73.             Timer1.Enabled = True
  74.             SetCapture Command1.hwnd
  75.         End If
  76.     End If
  77. End Sub
  78. Private Sub Form_Load()
  79.     Picture1.BackColor = Form1.BackColor
  80.     Picture1.Visible = False
  81.     Timer1.Interval = 250
  82.     Timer1.Enabled = False
  83. End Sub
  84. Private Sub Timer1_Timer()
  85.     Dim font As New ROTATEFONT
  86.     Dim hlpText As String
  87.     hlpText = "Help me!"
  88.     Picture1.Width = Picture1.TextWidth(hlpText) + 100
  89.     Picture1.Height = Picture1.TextHeight(hlpText) + 100
  90.     Picture1.TOP = Command1.TOP + Command1.Height + 20
  91.     Picture1.Left = Command1.Left + (Command1.Width / 2)
  92.     Picture1.Visible = True
  93.     Picture1.Cls
  94.     font.setPointSize 14
  95.     font.dispText Picture1.hDC, hlpText, 2, 2
  96.     Timer1.Enabled = False
  97. End Sub
  98.