home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / tool_wnd / mainwnd.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-05-25  |  6.2 KB  |  204 lines

  1. VERSION 2.00
  2. Begin Form MainWnd 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Toolbar Demonstration"
  5.    ClientHeight    =   765
  6.    ClientLeft      =   1125
  7.    ClientTop       =   2010
  8.    ClientWidth     =   7245
  9.    Height          =   1455
  10.    Icon            =   MAINWND.FRX:0000
  11.    Left            =   1065
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    ScaleHeight     =   765
  15.    ScaleWidth      =   7245
  16.    Top             =   1380
  17.    Width           =   7365
  18.    Begin PictureBox ToolBar 
  19.       Align           =   1  'Align Top
  20.       BackColor       =   &H00C0C0C0&
  21.       BorderStyle     =   0  'None
  22.       Height          =   405
  23.       Left            =   0
  24.       ScaleHeight     =   27
  25.       ScaleMode       =   3  'Pixel
  26.       ScaleWidth      =   483
  27.       TabIndex        =   0
  28.       TabStop         =   0   'False
  29.       Top             =   0
  30.       Width           =   7245
  31.       Begin Label Status 
  32.          AutoSize        =   -1  'True
  33.          BackStyle       =   0  'Transparent
  34.          Caption         =   "Ready"
  35.          FontBold        =   0   'False
  36.          FontItalic      =   0   'False
  37.          FontName        =   "MS Sans Serif"
  38.          FontSize        =   8.25
  39.          FontStrikethru  =   0   'False
  40.          FontUnderline   =   0   'False
  41.          Height          =   195
  42.          Left            =   3060
  43.          TabIndex        =   1
  44.          Top             =   105
  45.          Width           =   465
  46.       End
  47.    End
  48.    Begin Menu Menu_Fil 
  49.       Caption         =   "&Files"
  50.       Begin Menu MenuF_New 
  51.          Caption         =   "&New"
  52.          Shortcut        =   ^N
  53.       End
  54.       Begin Menu MenuF_Ope 
  55.          Caption         =   "&Open..."
  56.          Shortcut        =   ^O
  57.       End
  58.       Begin Menu MenuF_Pri 
  59.          Caption         =   "&Print..."
  60.          Shortcut        =   ^P
  61.       End
  62.       Begin Menu zd1 
  63.          Caption         =   "-"
  64.       End
  65.       Begin Menu MenuF_End 
  66.          Caption         =   "&End"
  67.          HelpContextID   =   1003
  68.       End
  69.    End
  70.    Begin Menu Menu_Opt 
  71.       Caption         =   "&Options"
  72.       Begin Menu MenuO_Qui 
  73.          Caption         =   "&QuickHelp"
  74.          Checked         =   -1  'True
  75.       End
  76.    End
  77.    Begin Menu MenuA_Abo 
  78.       Caption         =   "&About..."
  79.    End
  80. Option Explicit
  81. Sub Form_Load ()
  82. Dim HSysMenu As Integer, rc As Integer
  83. Dim temp$
  84.     stppx = 15
  85.     stppy = 15
  86.     QuickInfo = True
  87.     For rc = 0 To 6
  88.         vbCopyTool ToolWnd.Tool(rc), ToolBar, vbQHTrue
  89.     Next rc
  90.     temp$ = "Toolbartext 1|QuickInfo 1"
  91.     vbQHPutString 0, temp$
  92.     temp$ = "Toolbartext 2|QuickInfo 2"
  93.     vbQHPutString 1, temp$
  94.     temp$ = "Toolbartext 3|QuickInfo 3"
  95.     vbQHPutString 2, temp$
  96.     temp$ = "Toolbartext 4|QuickInfo 4"
  97.     vbQHPutString 3, temp$
  98.     temp$ = "Toolbartext 5|QuickInfo 5"
  99.     vbQHPutString 4, temp$
  100.     temp$ = "Toolbartext 6|QuickInfo 6"
  101.     vbQHPutString 5, temp$
  102.     temp$ = "Toolbartext 7|QuickInfo 7"
  103.     vbQHPutString 6, temp$
  104.     Unload ToolWnd
  105.     HSysMenu = GetSystemMenu(Me.hWnd, 0)
  106.     rc = RemoveMenu(HSysMenu, 2, MF_BYPOSITION)
  107.     Me.Height = 1080
  108.     ToolBar.AutoRedraw = True
  109.     ToolBar.Line (201, 5)-(477, 5), RGB(128, 128, 128)
  110.     ToolBar.Line (201, 5)-(201, 21), RGB(128, 128, 128)
  111.     ToolBar.Line (477, 5)-(477, 21), RGB(255, 255, 255)
  112.     ToolBar.Line (201, 21)-(478, 21), RGB(255, 255, 255)
  113.     ToolBar.AutoRedraw = False
  114.     MenuRight MenuA_Abo
  115. End Sub
  116. Sub Form_Resize ()
  117. Static tw As Integer
  118.     If Me.WindowState = 1 Then
  119.         If ToolhWnd Then
  120.             tw = True
  121.             Unload ToolWnd
  122.         End If
  123.     Else
  124.         If tw Then
  125.             ToolWnd.Show
  126.         End If
  127.         'FloatingWindow Me.hWnd, False
  128.     End If
  129. End Sub
  130. Sub Form_Unload (Cancel As Integer)
  131.     If Me.WindowState = 1 Then WindowState = 0
  132.     If ToolhWnd Then Unload ToolWnd
  133. End Sub
  134. Sub MenuA_Abo_Click ()
  135.     MsgBox "(c) 1994, TSAF", 64
  136. End Sub
  137. Sub MenuF_End_Click ()
  138.     Unload Me
  139. End Sub
  140. Sub MenuO_Qui_Click ()
  141.     MenuO_Qui.Checked = Not MenuO_Qui.Checked
  142.     QuickInfo = MenuO_Qui.Checked
  143. End Sub
  144. Sub ToolBar_DblClick ()
  145. Dim h As Integer
  146.     h = 15 * (GetSystemMetrics(15) + GetSystemMetrics(4) + 2 * GetSystemMetrics(33) - GetSystemMetrics(6))
  147.     Me.Height = h
  148.     ToolWnd.Show
  149. End Sub
  150. Sub ToolBar_MouseDown (button As Integer, Shift As Integer, x As Single, Y As Single)
  151. Dim sUsed As Integer
  152. Dim temp$
  153.     temp$ = "Ready"
  154.     sUsed = True
  155.     Select Case vbPaintedToolExt(ToolBar, MouseDown, Status)
  156.         Case 0
  157.         Case 1
  158.             If MsgBox("Quit?", 36) = 6 Then sUsed = False: Unload Me
  159.         Case 2
  160.         Case 3
  161.         Case 4
  162.         Case 5
  163.         Case 6
  164.     End Select
  165.     If sUsed Then Me.Show : Status.Caption = temp$
  166. End Sub
  167. Sub ToolBar_MouseMove (button As Integer, Shift As Integer, x As Single, Y As Single)
  168. Dim rc As Integer
  169. Dim mPoint As apiPoint
  170. Dim tRect As apiRect
  171. Static mm As Integer
  172.     If QuickInfo Then
  173.         If Not mm Then rc = vbPaintedToolExt(ToolBar, MouseMove, Status)
  174.         If button And Not mm And rc Then
  175.             mm = True
  176.             GetWindowRect ToolBar.hWnd, tRect
  177.             Do
  178.                 DoEvents
  179.                 GetCursorPos mPoint
  180.                 If mPoint.x < tRect.Left Or mPoint.Y < tRect.Top Or mPoint.x > tRect.Right Or mPoint.Y > tRect.Bottom Then
  181.                     If Not ToolhWnd Then
  182.                         Load ToolWnd
  183.                         GetCursorPos mPoint
  184.                         ToolWnd.Move mPoint.x * stppx, mPoint.Y * stppy
  185.                     End If
  186.                     FakeMove ToolWnd
  187.                 Else
  188.                     If ToolhWnd Then Unload ToolWnd
  189.                 End If
  190.             Loop Until GetKeyState(1) >= 0
  191.             GetCursorPos mPoint
  192.             If mPoint.x < tRect.Left Or mPoint.Y < tRect.Top Or mPoint.x > tRect.Right Or mPoint.Y > tRect.Bottom Then
  193.                 ToolBar_DblClick
  194.             Else
  195.                 Unload ToolWnd
  196.             End If
  197.             mm = False
  198.         End If
  199.     End If
  200. End Sub
  201. Sub ToolBar_Resize ()
  202.     MakeUpperStatusBar ToolBar
  203. End Sub
  204.