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

  1. VERSION 2.00
  2. Begin Form frmToolbox 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Tools"
  6.    ClientHeight    =   375
  7.    ClientLeft      =   4650
  8.    ClientTop       =   1815
  9.    ClientWidth     =   810
  10.    Height          =   780
  11.    Left            =   4590
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MDIChild        =   -1  'True
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   25
  17.    ScaleMode       =   3  'Pixel
  18.    ScaleWidth      =   54
  19.    Top             =   1470
  20.    Width           =   930
  21.    Begin PictureBox PicClip1 
  22.       Height          =   480
  23.       Left            =   0
  24.       ScaleHeight     =   450
  25.       ScaleWidth      =   1170
  26.       TabIndex        =   0
  27.       Top             =   0
  28.       Width           =   1200
  29.    End
  30.    Begin PictureBox SubClass1 
  31.       Height          =   480
  32.       Left            =   12
  33.       ScaleHeight     =   450
  34.       ScaleWidth      =   1170
  35.       TabIndex        =   1
  36.       Top             =   104
  37.       Width           =   1200
  38.    End
  39.    Begin Image Image1 
  40.       Height          =   330
  41.       Index           =   15
  42.       Left            =   0
  43.       Top             =   900
  44.       Width           =   360
  45.    End
  46.    Begin Image Image1 
  47.       Height          =   330
  48.       Index           =   14
  49.       Left            =   1440
  50.       Top             =   600
  51.       Width           =   360
  52.    End
  53.    Begin Image Image1 
  54.       Height          =   330
  55.       Index           =   13
  56.       Left            =   1080
  57.       Top             =   600
  58.       Width           =   360
  59.    End
  60.    Begin Image Image1 
  61.       Height          =   330
  62.       Index           =   12
  63.       Left            =   720
  64.       Top             =   600
  65.       Width           =   360
  66.    End
  67.    Begin Image Image1 
  68.       Height          =   330
  69.       Index           =   11
  70.       Left            =   360
  71.       Top             =   600
  72.       Width           =   360
  73.    End
  74.    Begin Image Image1 
  75.       Height          =   330
  76.       Index           =   10
  77.       Left            =   0
  78.       Top             =   600
  79.       Width           =   360
  80.    End
  81.    Begin Image Image1 
  82.       Height          =   330
  83.       Index           =   9
  84.       Left            =   1440
  85.       Top             =   300
  86.       Width           =   360
  87.    End
  88.    Begin Image Image1 
  89.       Height          =   330
  90.       Index           =   8
  91.       Left            =   1080
  92.       Top             =   300
  93.       Width           =   360
  94.    End
  95.    Begin Image Image1 
  96.       Height          =   330
  97.       Index           =   7
  98.       Left            =   720
  99.       Top             =   300
  100.       Width           =   360
  101.    End
  102.    Begin Image Image1 
  103.       Height          =   330
  104.       Index           =   6
  105.       Left            =   360
  106.       Top             =   300
  107.       Width           =   360
  108.    End
  109.    Begin Image Image1 
  110.       Height          =   330
  111.       Index           =   5
  112.       Left            =   0
  113.       Top             =   300
  114.       Width           =   360
  115.    End
  116.    Begin Image Image1 
  117.       Height          =   330
  118.       Index           =   4
  119.       Left            =   1440
  120.       Top             =   0
  121.       Width           =   360
  122.    End
  123.    Begin Image Image1 
  124.       Height          =   330
  125.       Index           =   3
  126.       Left            =   1080
  127.       Top             =   0
  128.       Width           =   360
  129.    End
  130.    Begin Image Image1 
  131.       Height          =   330
  132.       Index           =   2
  133.       Left            =   720
  134.       Top             =   0
  135.       Width           =   360
  136.    End
  137.    Begin Image Image1 
  138.       Height          =   330
  139.       Index           =   1
  140.       Left            =   360
  141.       Top             =   0
  142.       Width           =   360
  143.    End
  144.    Begin Image Image1 
  145.       Height          =   330
  146.       Index           =   0
  147.       Left            =   0
  148.       Top             =   0
  149.       Width           =   360
  150.    End
  151. Option Explicit
  152. Sub Form_Unload (Cancel As Integer)
  153.    Unload frmFlyout
  154.    frmToolbox!SubClass1.HwndParam = 0
  155.    MDIForm1!Panel.Caption = ""
  156. End Sub
  157. Sub Image1_MouseDown (Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
  158.    Dim last_tool%                            ' Index of the previously selected tool.
  159.    Dim temp%                                 ' Temp var
  160.    ' The only thing we're interested in is the left mouse button.
  161.    If (Button = LEFT_BUTTON) Then
  162.       
  163.       '
  164.       ' Save, in the Toolbox structure, which icon in the toolbox was clicked on.
  165.       '
  166.       last_tool% = gToolbox.tool_selected
  167.       gToolbox.tool_selected = Index
  168.       
  169.       
  170.       '
  171.       ' Change the selected tool's icon to the depressed version.
  172.       '
  173.       frmToolbox!Image1(Index).Picture = frmToolbox!PicClip1.GraphicCell(gToolbox.icons(Index, 0).icon_index + ICON_DEPRESSED)
  174.       
  175.       
  176.       '
  177.       ' If needed, arrange the flyout menu.
  178.       '
  179.       If (last_tool% <> gToolbox.tool_selected) Then Call ArrangeFlyout
  180.       '
  181.       ' Set the form to be sub-classed (enables sub-classing)
  182.       ' Show the flyout as modal.
  183.       '
  184.       frmFlyout!SubClass1.HwndParam = frmFlyout.hWnd
  185.       temp% = SetCapture%(frmFlyout.hWnd)
  186.       frmFlyout.Show MODELESS
  187.    End If
  188. End Sub
  189. Sub SubClass1_WndMessage (wnd As Integer, msg As Integer, wp As Integer, lp As Long, retval As Long, nodef As Integer)
  190.    Dim x%                        ' X coordinate of the mouse
  191.    Dim y%                        ' Y coordinate of the mouse
  192.    Dim row%                      ' Icon row the mouse is over
  193.    Dim column%                   ' Icon column the mouse is over
  194.    Dim image_num%                ' The index of the icon the mouse is over
  195.    ' Based on the API message received...
  196.    Select Case (msg)
  197.       '
  198.       ' Our message that is received when the user selects something on the flyout.
  199.       ' Index of flyout item selected is contained in the wp parameter.
  200.       '
  201.       Case WM_USER
  202.          
  203.          '
  204.          ' Hide the flyout window.
  205.          '
  206.          frmFlyout.Hide
  207.          
  208.          
  209.          '
  210.          ' Save the item flyout item selected in the gToolbox structure.
  211.          '
  212.          gToolbox.flyout_item_selected = wp
  213.          
  214.          
  215.          '
  216.          ' Restore the icon for the selected tool to its normal state.
  217.          '
  218.          frmToolbox!Image1(gToolbox.tool_selected).Picture = frmToolbox!PicClip1.GraphicCell(gToolbox.icons(gToolbox.tool_selected, 0).icon_index)
  219.          
  220.          
  221.          '
  222.          ' Process the flyout menu selection.
  223.          '
  224.          Call ProcessFlyoutSelection
  225.       
  226.       
  227.       
  228.       
  229.       '
  230.       ' The user is moving the mouse in the toolbox window.
  231.       ' Determine the tool the mouse is over and display the tool's help message.
  232.       '
  233.       Case WM_MOUSEMOVE
  234.          '
  235.          ' Extract the x and y mouse coordinates from the lp parameter.
  236.          '
  237.          
  238.          Call dwDWORDto2Integers(lp, x%, y%)
  239.          
  240.          
  241.          '
  242.          ' Calculate the icon row and column the mouse is over.
  243.          '
  244.          
  245.          column% = x% \ frmToolbox!Image1(0).Width
  246.          row% = y% \ frmToolbox!Image1(0).Height
  247.          
  248.          
  249.          '
  250.          ' Determine the index of the icon the mouse is over.
  251.          ' Display the tool's help string in the MDIForm1's status panel.
  252.          '
  253.          
  254.          image_num% = (gToolbox.num_columns * row%) + column%
  255.          MDIForm1!Panel.Caption = gToolbox.icons(image_num%, 0).help_str
  256.       
  257.       
  258.       '
  259.       ' The user has moved the toolbox window.
  260.       ' Set the tool_selected field in the gToolbox structure to -1 so that
  261.       ' if the user re-selects the last tool again, a call to ArrangeToolbox
  262.       ' is forced.  If this didn't happen, the flyout would be displayed in its
  263.       ' old position, not where it should be.
  264.       '
  265.       Case WM_MOVE
  266.          gToolbox.tool_selected = -1
  267.       
  268.    End Select
  269. End Sub
  270.