home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / flyout / form2.frm < prev    next >
Text File  |  1992-12-26  |  10KB  |  370 lines

  1. VERSION 2.00
  2. Begin Form frmFlyout 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    ControlBox      =   0   'False
  6.    Height          =   2130
  7.    Left            =   3570
  8.    LinkTopic       =   "Form2"
  9.    MaxButton       =   0   'False
  10.    MinButton       =   0   'False
  11.    ScaleHeight     =   115
  12.    ScaleMode       =   3  'Pixel
  13.    ScaleWidth      =   139
  14.    Top             =   1290
  15.    Width           =   2205
  16.    Begin ccSubClass SubClass1 
  17.       Left            =   100
  18.       Messages        =   FORM2.FRX:0000
  19.       Top             =   80
  20.    End
  21.    Begin Image Image1 
  22.       Height          =   330
  23.       Index           =   15
  24.       Left            =   0
  25.       Top             =   900
  26.       Width           =   360
  27.    End
  28.    Begin Image Image1 
  29.       Height          =   330
  30.       Index           =   14
  31.       Left            =   1440
  32.       Top             =   600
  33.       Width           =   360
  34.    End
  35.    Begin Image Image1 
  36.       Height          =   330
  37.       Index           =   13
  38.       Left            =   1080
  39.       Top             =   600
  40.       Width           =   360
  41.    End
  42.    Begin Image Image1 
  43.       Height          =   330
  44.       Index           =   12
  45.       Left            =   720
  46.       Top             =   600
  47.       Width           =   360
  48.    End
  49.    Begin Image Image1 
  50.       Height          =   330
  51.       Index           =   11
  52.       Left            =   360
  53.       Top             =   600
  54.       Width           =   360
  55.    End
  56.    Begin Image Image1 
  57.       Height          =   330
  58.       Index           =   10
  59.       Left            =   0
  60.       Top             =   600
  61.       Width           =   360
  62.    End
  63.    Begin Image Image1 
  64.       Height          =   330
  65.       Index           =   9
  66.       Left            =   1440
  67.       Top             =   300
  68.       Width           =   360
  69.    End
  70.    Begin Image Image1 
  71.       Height          =   330
  72.       Index           =   8
  73.       Left            =   1080
  74.       Top             =   300
  75.       Width           =   360
  76.    End
  77.    Begin Image Image1 
  78.       Height          =   330
  79.       Index           =   7
  80.       Left            =   720
  81.       Top             =   300
  82.       Width           =   360
  83.    End
  84.    Begin Image Image1 
  85.       Height          =   330
  86.       Index           =   6
  87.       Left            =   360
  88.       Top             =   300
  89.       Width           =   360
  90.    End
  91.    Begin Image Image1 
  92.       Height          =   330
  93.       Index           =   5
  94.       Left            =   0
  95.       Top             =   300
  96.       Width           =   360
  97.    End
  98.    Begin Image Image1 
  99.       Height          =   330
  100.       Index           =   4
  101.       Left            =   1440
  102.       Top             =   0
  103.       Width           =   360
  104.    End
  105.    Begin Image Image1 
  106.       Height          =   330
  107.       Index           =   3
  108.       Left            =   1080
  109.       Top             =   0
  110.       Width           =   360
  111.    End
  112.    Begin Image Image1 
  113.       Height          =   330
  114.       Index           =   2
  115.       Left            =   720
  116.       Top             =   0
  117.       Width           =   360
  118.    End
  119.    Begin Image Image1 
  120.       Height          =   330
  121.       Index           =   1
  122.       Left            =   360
  123.       Top             =   0
  124.       Width           =   360
  125.    End
  126.    Begin Image Image1 
  127.       Height          =   330
  128.       Index           =   0
  129.       Left            =   0
  130.       Top             =   0
  131.       Width           =   360
  132.    End
  133. End
  134. Option Explicit
  135.  
  136. Dim LastIndexPressed%
  137.  
  138. Sub Form_Load ()
  139.  
  140.    '
  141.    ' Set the form's global var LastIndexPressed% to -1.
  142.    '
  143.  
  144.    LastIndexPressed% = -1
  145.  
  146. End Sub
  147.  
  148. Sub SubClass1_WndMessage (wnd As Integer, msg As Integer, wp As Integer, lp As Long, retval As Long, nodef As Integer)
  149.  
  150.    Dim x%                        ' X coordinate of the mouse
  151.    Dim y%                        ' Y coordinate of the mouse
  152.    Dim row%                      ' Icon row the mouse is over
  153.    Dim column%                   ' Icon column the mouse is over
  154.    Dim image_num%                ' The index of the icon the mouse is over
  155.    Dim temp_str$                 ' Temp var
  156.    Dim temp%                     ' Temp var
  157.    
  158.    
  159.    '
  160.    ' Based on the message received...
  161.    '
  162.  
  163.    Select Case (msg)
  164.  
  165.       '
  166.       ' Mouse has moved.
  167.       '
  168.  
  169.       Case WM_MOUSEMOVE
  170.  
  171.          '
  172.          ' Do some common stuff.
  173.          '
  174.  
  175.          GoSub WM_DataExtract
  176.  
  177.  
  178.          '
  179.          ' Determine the help message to be displayed.
  180.          '
  181.  
  182.          If (image_num% < 0) Then
  183.             temp_str$ = ""
  184.          Else
  185.             temp_str$ = gToolbox.icons(gToolbox.tool_selected, (image_num% + 1)).help_str
  186.          End If
  187.          
  188.          
  189.          '
  190.          ' If the left mouse button is depressed, change the icons as needed.
  191.          '
  192.  
  193.          If (wp And MK_LBUTTON) Then
  194.          
  195.             '
  196.             ' If the image number is different than the index in LastIndexPressed%...
  197.             '
  198.             If (image_num% <> LastIndexPressed%) Then
  199.    
  200.                '
  201.                ' Set the previously depressed icon to the normal state. (if needed).
  202.                '
  203.    
  204.                If (LastIndexPressed% > -1) Then
  205.                   frmFlyout!Image1(LastIndexPressed%).Picture = frmToolbox!PicClip1.GraphicCell(gToolbox.icons(gToolbox.tool_selected, (LastIndexPressed% + 1)).icon_index)
  206.                End If
  207.    
  208.                
  209.                '
  210.                ' If the mouse is over one of the icons in the flyout, show the depressed
  211.                ' version of the current icon and set the var LastIndexPressed%.
  212.                ' Otherwise, set the var LastIndexPressed% to -1.
  213.                '
  214.                
  215.                If (image_num% > -1) Then
  216.                   frmFlyout!Image1(image_num%).Picture = frmToolbox!PicClip1.GraphicCell(gToolbox.icons(gToolbox.tool_selected, (image_num% + 1)).icon_index + ICON_DEPRESSED)
  217.                   LastIndexPressed% = image_num%
  218.                Else
  219.                   LastIndexPressed% = -1
  220.                End If
  221.    
  222.             End If
  223.  
  224.          End If
  225.  
  226.          
  227.          '
  228.          ' Display the help message in the MDIForm's status line.
  229.          '
  230.  
  231.          MDIForm1!Panel.Caption = temp_str$
  232.  
  233.       
  234.       
  235.       '
  236.       ' Left mouse button has been depressed.
  237.       '
  238.  
  239.       Case WM_LBUTTONDOWN
  240.  
  241.          '
  242.          ' Do some common stuff.
  243.          '
  244.  
  245.          GoSub WM_DataExtract
  246.  
  247.  
  248.          '
  249.          ' Determine the help message to be displayed.
  250.          '
  251.  
  252.          If (image_num% < 0) Then
  253.             temp_str$ = ""
  254.          Else
  255.             temp_str$ = gToolbox.icons(gToolbox.tool_selected, (image_num% + 1)).help_str
  256.          End If
  257.          
  258.          
  259.          '
  260.          ' If the image number is different than the index in LastIndexPressed%...
  261.          '
  262.  
  263.          If (image_num% <> LastIndexPressed%) Then
  264.  
  265.             '
  266.             ' Set the previously depressed icon to the normal state. (if needed).
  267.             '
  268.  
  269.             If (LastIndexPressed% > -1) Then
  270.                frmFlyout!Image1(LastIndexPressed%).Picture = frmToolbox!PicClip1.GraphicCell(gToolbox.icons(gToolbox.tool_selected, (LastIndexPressed% + 1)).icon_index)
  271.             End If
  272.  
  273.             
  274.             '
  275.             ' If the mouse is over one of the icons in the flyout, show the depressed
  276.             ' version of the current icon and set the var LastIndexPressed%.
  277.             ' Otherwise, set the var LastIndexPressed% to -1.
  278.             '
  279.             
  280.             If (image_num% > -1) Then
  281.                frmFlyout!Image1(image_num%).Picture = frmToolbox!PicClip1.GraphicCell(gToolbox.icons(gToolbox.tool_selected, (image_num% + 1)).icon_index + ICON_DEPRESSED)
  282.                LastIndexPressed% = image_num%
  283.             Else
  284.                LastIndexPressed% = -1
  285.             End If
  286.  
  287.          End If
  288.  
  289.          
  290.          '
  291.          ' Display the help message in the MDIForm's status line.
  292.          '
  293.  
  294.          MDIForm1!Panel.Caption = temp_str$
  295.  
  296.  
  297.       '
  298.       ' Left mouse button has been released.
  299.       '
  300.  
  301.       Case WM_LBUTTONUP
  302.  
  303.          '
  304.          ' Do some common stuff.
  305.          '
  306.  
  307.          GoSub WM_DataExtract
  308.  
  309.          
  310.          '
  311.          ' If the mouse is over an icon, restore it to its normal state.
  312.          '
  313.  
  314.          If (image_num% > -1) Then
  315.             frmFlyout!Image1(image_num%).Picture = frmToolbox!PicClip1.GraphicCell(gToolbox.icons(gToolbox.tool_selected, (image_num% + 1)).icon_index)
  316.          End If
  317.          
  318.          
  319.          '
  320.          ' Clear the status line in the MDIForm1 window.
  321.          ' Set the LastIndexPressed% var to -1.
  322.          ' Release the mouse capture.
  323.          ' Set the form to sub-class to 0  (stop sub-classing this window).
  324.          ' Post a message to the toolbox indicating what flyout item was selected.
  325.          '
  326.  
  327.          MDIForm1!Panel.Caption = ""
  328.          LastIndexPressed% = -1
  329.          Call ReleaseCapture
  330.          frmFlyout!SubClass1.HwndParam = 0
  331.          temp% = PostMessage%(frmToolbox.hWnd, WM_USER, image_num%, 0&)
  332.    
  333.    End Select
  334.  
  335.    Exit Sub
  336.  
  337.  
  338. WM_DataExtract:
  339.  
  340.    '
  341.    ' Extract the x and y mouse coordinates from the lp parameter.
  342.    '
  343.    
  344.    Call dwDWORDto2Integers(lp, x%, y%)
  345.    
  346.    
  347.    '
  348.    ' Calculate the icon row and column the mouse is over.
  349.    '
  350.    
  351.    column% = x% \ frmFlyout!Image1(0).Width
  352.    row% = y% \ frmFlyout!Image1(0).Height
  353.    
  354.    
  355.    '
  356.    ' Determine the index of the icon the mouse is over.
  357.    ' Take into account the fact that the mouse may be outside the flyout window.
  358.    '
  359.    
  360.    If ((column% >= gToolbox.flyout_data(gToolbox.tool_selected).num_columns) Or (row% >= gToolbox.flyout_data(gToolbox.tool_selected).num_rows) Or (x% < 0) Or (y% < 0)) Then
  361.       image_num% = -1
  362.    Else
  363.       image_num% = (gToolbox.flyout_data(gToolbox.tool_selected).num_columns * row%) + column%
  364.    End If
  365.  
  366. Return
  367.  
  368. End Sub
  369.  
  370.