home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / flyout / form1.frm < prev    next >
Text File  |  1992-12-28  |  8KB  |  302 lines

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