home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / toolhelp / mdiform1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-07  |  5.7 KB  |  188 lines

  1. VERSION 2.00
  2. Begin MDIForm MDIForm1 
  3.    Caption         =   "Popup Help Demo"
  4.    ClientHeight    =   2670
  5.    ClientLeft      =   1980
  6.    ClientTop       =   2190
  7.    ClientWidth     =   5085
  8.    Height          =   3075
  9.    Left            =   1920
  10.    LinkTopic       =   "MDIForm1"
  11.    Top             =   1845
  12.    Width           =   5205
  13.    Begin PictureBox Picture1 
  14.       Align           =   2  'Align Bottom
  15.       BackColor       =   &H00C0C0C0&
  16.       Height          =   495
  17.       Left            =   0
  18.       ScaleHeight     =   465
  19.       ScaleWidth      =   5055
  20.       TabIndex        =   1
  21.       Top             =   2175
  22.       Width           =   5085
  23.       Begin Timer Timer1 
  24.          Enabled         =   0   'False
  25.          Interval        =   850
  26.          Left            =   6300
  27.          Top             =   30
  28.       End
  29.       Begin Timer Timer2 
  30.          Enabled         =   0   'False
  31.          Interval        =   50
  32.          Left            =   6825
  33.          Top             =   30
  34.       End
  35.       Begin Label Label4 
  36.          AutoSize        =   -1  'True
  37.          BackColor       =   &H00C0C0C0&
  38.          Caption         =   "hWnd:"
  39.          ForeColor       =   &H00000000&
  40.          Height          =   195
  41.          Left            =   120
  42.          TabIndex        =   2
  43.          Top             =   135
  44.          Width           =   570
  45.       End
  46.       Begin Label Label2 
  47.          BackColor       =   &H00C0C0C0&
  48.          Caption         =   "Label"
  49.          ForeColor       =   &H00800000&
  50.          Height          =   195
  51.          Left            =   765
  52.          TabIndex        =   3
  53.          Top             =   135
  54.          Width           =   1185
  55.       End
  56.    End
  57.    Begin PictureBox picToolbar 
  58.       Align           =   1  'Align Top
  59.       BackColor       =   &H00C0C0C0&
  60.       Height          =   510
  61.       Left            =   0
  62.       ScaleHeight     =   32
  63.       ScaleMode       =   3  'Pixel
  64.       ScaleWidth      =   337
  65.       TabIndex        =   0
  66.       Top             =   0
  67.       Width           =   5085
  68.       Begin PictureBox PicClip1 
  69.          Height          =   480
  70.          Left            =   0
  71.          Picture         =   MDIFORM1.FRX:0000
  72.          ScaleHeight     =   450
  73.          ScaleWidth      =   1170
  74.          TabIndex        =   4
  75.          Top             =   0
  76.          Width           =   1200
  77.       End
  78.       Begin PictureBox pshToolBtn 
  79.          Height          =   345
  80.          Index           =   0
  81.          Left            =   90
  82.          ScaleHeight     =   315
  83.          ScaleWidth      =   375
  84.          TabIndex        =   5
  85.          Top             =   60
  86.          Width           =   405
  87.       End
  88.    End
  89. Option Explicit
  90. ' This is used to keep account of windows that are
  91. ' the toolbar buttons
  92. Dim hWndTrack(0 To 10) As Integer
  93. Sub MDIForm_Load ()
  94.   Dim i As Integer
  95.   gNumBtns = picClip1.Cols
  96.   gCurrBtn = -1
  97.   ' load toolbar buttons
  98.   For i = 0 To gNumBtns - 1
  99.     If i > 0 Then
  100.        Load pshToolBtn(i)
  101.        pshToolBtn(i).Left = pshToolBtn(i - 1).Left + pshToolBtn(i - 1).Width - 1
  102.        pshToolBtn(i).Visible = True
  103.     End If
  104.     pshToolBtn(i).PictureUp = picClip1.GraphicCell(i)
  105.     hWndTrack(i) = pshToolBtn(i).hWnd
  106.   Next
  107.   ' use Tag to hold messages for each button
  108.   pshToolBtn(0).Tag = "Clear workspace"
  109.   pshToolBtn(1).Tag = "Open previous workspace"
  110.   pshToolBtn(2).Tag = "Save current workspace"
  111.   pshToolBtn(3).Tag = "Calculate"
  112.   pshToolBtn(4).Tag = "Cut to Clipboard"
  113.   pshToolBtn(5).Tag = "Insert Excel Object"
  114.   pshToolBtn(6).Tag = "Exit demo program"
  115. End Sub
  116. Sub pshToolBtn_Click (Index As Integer, Value As Integer)
  117.   ' pop button back up
  118.   pshToolBtn(Index).Value = False
  119.   ' the exit button really works <g>
  120.   If Index = gNumBtns - 1 Then End
  121. End Sub
  122. Sub pshToolBtn_MouseMove (Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
  123.   ' if help active and on a new button then show
  124.   ' new help message...
  125.   If gPopHelpActive And Index <> gCurrBtn Then
  126.     frmPopupHelp.Hide
  127.     gCurrBtn = Index
  128.     Call ShowHelpMess
  129.   Else
  130.     ' else if we moved over a new button...
  131.     If Index <> gCurrBtn Then
  132.       gCurrBtn = Index
  133.       ' cancel any old countdown
  134.       Timer1.Enabled = False
  135.       ' start counting down to popup help
  136.       Timer1.Enabled = True
  137.     End If
  138.   End If
  139. End Sub
  140. Sub Timer1_Timer ()
  141.   ' This timer is used to countdown time to activate
  142.   ' popup help
  143.   Dim t As Integer
  144.   Call GetCursorPos(gPoint)
  145.   t = WindowFromPoint(PointAPIToLong&(gPoint))
  146.   ' are we stil  on the button that triggered this timer?
  147.   If t = pshToolBtn(gCurrBtn).hWnd Then
  148.     gPopHelpActive = True
  149.     Call ShowHelpMess
  150.     ' start tracking cursor position
  151.     Timer2.Enabled = True
  152.   End If
  153.   ' kill countdown timer
  154.   Timer1.Enabled = False
  155.   gCurrBtn = -1
  156. End Sub
  157. Sub Timer2_Timer ()
  158.   ' This timer tracks mouse position once popup help
  159.   ' has been activated.  Once we move off the toolbar
  160.   ' area then popup help is canceled.
  161.   Dim i As Integer
  162.   Dim h As Integer
  163.   Dim Found As Integer
  164.   Call GetCursorPos(gPoint)
  165.   h = WindowFromPoint(PointAPIToLong&(gPoint))
  166.   Label2.Caption = h
  167.   ' see if we're on any of the toolbar buttons...
  168.   For i = 0 To gNumBtns - 1
  169.     If h = hWndTrack(i) Then
  170.       Found = True
  171.       Exit For
  172.     End If
  173.   Next
  174.   If Not Found Then
  175.     ' check the toolbar area as well...
  176.     If h = picToolBar.hWnd Then
  177.       frmPopupHelp.Hide
  178.       gCurrBtn = -1
  179.     Else
  180.       ' else cancel popup help
  181.       frmPopupHelp.Hide
  182.       gCurrBtn = -1
  183.       gPopHelpActive = False
  184.       Timer2.Enabled = False
  185.     End If
  186.   End If
  187. End Sub
  188.