home *** CD-ROM | disk | FTP | other *** search
/ The Best of Select: Windows 95 Special 2 / WIN95_2.bin / utils / envelop / envelop.6 / Tools / Bootcamp / basic / popmenu / popmenu.eto < prev    next >
Encoding:
Text File  |  1996-07-08  |  11.5 KB  |  355 lines

  1. Type PopupMenuSampleForm From SampleMasterForm
  2.   Dim Frame1 As New Frame
  3.   Dim CHKEnableRed As New CheckBox
  4.   Dim CHKEnableOrange As New CheckBox
  5.   Dim CHKEnableYellow As New CheckBox
  6.   Dim CHKEnableGreen As New CheckBox
  7.   Dim CHKEnableBlue As New CheckBox
  8.   Dim CHKEnablePurple As New CheckBox
  9.   Type CustomPopup From PopupMenu
  10.     Dim Caller As Object
  11.  
  12.     ' METHODS for object: PopupMenuSampleForm.CustomPopup
  13.     Sub TargetTrack(ByVal ownerWindow as Object, ByVal x as Long, ByVal y as Long)
  14.       ' TargetTrack is a custom method to demonstrate how to add custom
  15.       ' functionality to existing PopupMenus. In this case, I want a
  16.       ' way to find out the control who recieved the MouseDown event
  17.       ' since the PopupMenu will do something to that control.
  18.       Caller = ownerWindow
  19.       Track(ownerWindow, x, y)
  20.     End Sub
  21.  
  22.   End Type
  23.   Dim ControlPopup As New PopupMenuSampleForm.CustomPopup
  24.   Type LBLBackColor From Label
  25.  
  26.     ' METHODS for object: PopupMenuSampleForm.LBLBackColor
  27.     Sub Blue_Click()
  28.       BackColor = RGB(0, 0, 255)
  29.     End Sub
  30.  
  31.     Sub Green_Click()
  32.       BackColor = RGB(0, 255, 0)
  33.     End Sub
  34.  
  35.     Sub Orange_Click()
  36.       BackColor = RGB(255, 255 / 2, 0)
  37.     End Sub
  38.  
  39.     Sub Purple_Click()
  40.       BackColor = RGB(255 / 2, 0, 255 / 2)
  41.     End Sub
  42.  
  43.     Sub Red_Click()
  44.       BackColor = RGB(255, 0, 0)
  45.     End Sub
  46.  
  47.     Sub Yellow_Click()
  48.       BackColor = RGB(255, 255, 0)
  49.     End Sub
  50.  
  51.   End Type
  52.   Type LBLForeColor From PopupMenuSampleForm.LBLBackColor
  53.  
  54.     ' METHODS for object: PopupMenuSampleForm.LBLForeColor
  55.     Sub Blue_Click()
  56.       ForeColor = RGB(0, 0, 255)
  57.     End Sub
  58.  
  59.     Sub Green_Click()
  60.       ForeColor = RGB(0, 255, 0)
  61.     End Sub
  62.  
  63.     Sub Orange_Click()
  64.       ForeColor = RGB(255, 255 / 2, 0)
  65.     End Sub
  66.  
  67.     Sub Purple_Click()
  68.       ForeColor = RGB(255 / 2, 0, 255 / 2)
  69.     End Sub
  70.  
  71.     Sub Red_Click()
  72.       ForeColor = RGB(255, 0, 0)
  73.     End Sub
  74.  
  75.     Sub Yellow_Click()
  76.       ForeColor = RGB(255, 255, 0)
  77.     End Sub
  78.  
  79.   End Type
  80.   Dim Frame2 As New Frame
  81.   Dim Frame3 As New Frame
  82.   Dim LBLTogglePopup As New Label
  83.   Dim OBEnablePopup As New OptionButton
  84.   Dim OBDisablePopup As New OptionButton
  85.   Type HPCNoPopupRegion From Form
  86.     Dim Frame1 As New Frame
  87.     Type LBLTrackPopup From Label
  88.  
  89.       ' METHODS for object: PopupMenuSampleForm.HPCNoPopupRegion.LBLTrackPopup
  90.       Sub MouseDown(button As Integer, shift As Integer, x As Single, y As Single)
  91.         If button = 2 Then PopupMenuSampleForm.ControlPopup.Track(Me, x, y)
  92.       End Sub
  93.  
  94.     End Type
  95.     Type LBLBothButtons From Label
  96.  
  97.       ' METHODS for object: PopupMenuSampleForm.HPCNoPopupRegion.LBLBothButtons
  98.       Sub MouseDown(button As Integer, shift As Integer, x As Single, y As Single)
  99.         PopupMenuSampleForm.ControlPopup.Track(Me, x, y)
  100.       End Sub
  101.  
  102.     End Type
  103.     Type LBLBothButtons1 From PopupMenuSampleForm.HPCNoPopupRegion.LBLBothButtons
  104.  
  105.       ' METHODS for object: PopupMenuSampleForm.HPCNoPopupRegion.LBLBothButtons1
  106.       Sub MouseDown(button As Integer, shift As Integer, x As Single, y As Single)
  107.         If button = 1 && shift = 1 Then PopupMenuSampleForm.ControlPopup.Track(Me, x, y)
  108.       End Sub
  109.  
  110.     End Type
  111.  
  112.     ' METHODS for object: PopupMenuSampleForm.HPCNoPopupRegion
  113.     Sub ReadMe
  114.       ' A HyperControl can have controls on it, and can intercept the
  115.       ' main form's PopupMenu...allowing regions where the form's Popup
  116.       ' can be supressed.
  117.     End Sub
  118.  
  119.     Sub Resize()
  120.       Frame1.Move(0, 0, ScaleWidth, ScaleHeight)
  121.     End Sub
  122.  
  123.   End Type
  124.  
  125.   ' METHODS for object: PopupMenuSampleForm
  126.   Function Blue_Enable() As Integer
  127.     Blue_Enable = (CHKEnableBlue.Value = "Checked")
  128.   End Function
  129.  
  130.   Function Green_Enable() As Integer
  131.     Green_Enable = (CHKEnableGreen.Value = "Checked")
  132.   End Function
  133.  
  134.   Sub OBDisablePopup_Click()
  135.     ' Setting the PopupMenu reference on an object to "FindObject(PopupMenu)" would
  136.     ' cause the default PopupMenu to come up. But, the default PopupMenu
  137.     ' should never have any items on it, so it doesn't appear. Setting
  138.     ' the reference to Nothing causes the Label's container's PopupMenu
  139.     ' to appear, which is the one on the Form. Note that the Form is the
  140.     ' container for the label and NOT the Frame. It may look like the
  141.     ' label is in the frame, but in reality, it is only placed on top
  142.     ' of the frame, and has no other relation to it. In fact, frames
  143.     ' can not have PopupMenus
  144.     LBLTogglePopup.PopupMenu = IIf(OBEnablePopup.Value, Nothing, FindObject("PopupMenu"))
  145.   End Sub
  146.  
  147.   Sub OBEnablePopup_Click()
  148.     ' See the remark in the OBDisablePopup_Click method
  149.     LBLTogglePopup.PopupMenu = IIf(OBEnablePopup.Value, Nothing, FindObject("PopupMenu"))
  150.   End Sub
  151.  
  152.   Function Orange_Enable() As Integer
  153.     Orange_Enable = (CHKEnableOrange.Value = "Checked")
  154.   End Function
  155.  
  156.   Function Purple_Enable() As Integer
  157.     Purple_Enable = (CHKEnablePurple.Value = "Checked")
  158.   End Function
  159.  
  160.   Function Red_Enable() As Integer
  161.     Red_Enable = (CHKEnableRed.Value = "Checked")
  162.   End Function
  163.  
  164.   Sub ResetApplication_Click
  165.     OBEnablePopup.Value = True
  166.     CHKEnableRed.Value = "Checked"
  167.     CHKEnableBlue.Value = "Checked"
  168.     CHKEnableGreen.Value = "Checked"
  169.     CHKEnableOrange.Value = "Unchecked"
  170.     CHKEnableYellow.Value = "Unchecked"
  171.     CHKEnablePurple.Value = "Unchecked"
  172.   End Sub
  173.  
  174.   Function Yellow_Enable() As Integer
  175.     Yellow_Enable = (CHKEnableYellow.Value = "Checked")
  176.   End Function
  177.  
  178. End Type
  179.  
  180. Type PopupMenuSample From Application
  181.   Dim AccessControl As New ACL
  182. End Type
  183.  
  184. Begin Code
  185. ' Reconstruction commands for object: SampleMasterFormHelpMenu
  186. '
  187.   With SampleMasterFormHelpMenu
  188.  
  189.     .InsertItem("HelpContents", "&Contents", -1)
  190.   End With  'SampleMasterFormHelpMenu
  191. ' Reconstruction commands for object: PopupMenuSampleForm
  192. '
  193.   With PopupMenuSampleForm
  194.     .Caption := "BOOT CAMP Sample"
  195.     .PopupMenu := PopupMenuSampleForm.ControlPopup
  196.     .Move(1890, 1665, 8370, 6060)
  197.     .Outlined := True
  198.     .MenuBar := SampleMasterFormMenuBar
  199.     .SampleDir := "C:\Current\Popmenu\"
  200.     .SampleName := "Popmenu"
  201.     With .helpfile
  202.       .FileName := "C:\Current\Popmenu\Popmenu.hlp"
  203.     End With  'PopupMenuSampleForm.helpfile
  204.     With .Frame1
  205.       .Caption := "Enablers"
  206.       .ZOrder := 13
  207.       .Move(6150, 150, 1950, 4950)
  208.     End With  'PopupMenuSampleForm.Frame1
  209.     With .CHKEnableRed
  210.       .Caption := "Red"
  211.       .Value := "Checked"
  212.       .ZOrder := 7
  213.       .Move(6300, 450, 1650, 600)
  214.     End With  'PopupMenuSampleForm.CHKEnableRed
  215.     With .CHKEnableOrange
  216.       .Caption := "Orange"
  217.       .ZOrder := 8
  218.       .Move(6300, 1200, 1650, 600)
  219.     End With  'PopupMenuSampleForm.CHKEnableOrange
  220.     With .CHKEnableYellow
  221.       .Caption := "Yellow"
  222.       .Value := "Checked"
  223.       .ZOrder := 9
  224.       .Move(6300, 1950, 1650, 600)
  225.     End With  'PopupMenuSampleForm.CHKEnableYellow
  226.     With .CHKEnableGreen
  227.       .Caption := "Green"
  228.       .ZOrder := 10
  229.       .Move(6300, 2700, 1650, 600)
  230.     End With  'PopupMenuSampleForm.CHKEnableGreen
  231.     With .CHKEnableBlue
  232.       .Caption := "Blue"
  233.       .ZOrder := 11
  234.       .Move(6300, 3450, 1650, 600)
  235.     End With  'PopupMenuSampleForm.CHKEnableBlue
  236.     With .CHKEnablePurple
  237.       .Caption := "Purple"
  238.       .Value := "Checked"
  239.       .ZOrder := 12
  240.       .Move(6300, 4200, 1650, 600)
  241.     End With  'PopupMenuSampleForm.CHKEnablePurple
  242.     With .CustomPopup
  243.  
  244.       .Caller := Nothing
  245.     End With  'PopupMenuSampleForm.CustomPopup
  246.     With .ControlPopup
  247.  
  248.       .InsertItem("Red", "Red", -1)
  249.       .InsertItem("Orange", "Orange", -1)
  250.       .InsertItem("Yellow", "Yellow", -1)
  251.       .InsertItem("Green", "Green", -1)
  252.       .InsertItem("Blue", "Blue", -1)
  253.       .InsertItem("Purple", "Purple", -1)
  254.     End With  'PopupMenuSampleForm.ControlPopup
  255.     With .LBLBackColor
  256.       .Caption := "This Label uses the same PopupMenu as the form, and handles its own Click Events"
  257.       .BackColor := 8323199
  258.       .ForeColor := 16777215
  259.       .ZOrder := 6
  260.       .PopupMenu := PopupMenuSampleForm.ControlPopup
  261.       .Move(300, 450, 2850, 975)
  262.       .BorderStyle := "Fixed Single"
  263.       .Alignment := "Center"
  264.     End With  'PopupMenuSampleForm.LBLBackColor
  265.     With .LBLForeColor
  266.       .Caption := "This Label also uses the same PopupMenu as the form, but handles its click events differently"
  267.       .BackColor := 16777215
  268.       .ForeColor := 8323199
  269.       .ZOrder := 5
  270.       .Move(300, 1500, 2850, 975)
  271.     End With  'PopupMenuSampleForm.LBLForeColor
  272.     With .Frame2
  273.       .Caption := "Simple click event handlers"
  274.       .ZOrder := 14
  275.       .Move(150, 150, 3150, 2550)
  276.     End With  'PopupMenuSampleForm.Frame2
  277.     With .Frame3
  278.       .Caption := "Enabling and Disabling"
  279.       .ZOrder := 4
  280.       .Move(3450, 150, 2550, 2550)
  281.     End With  'PopupMenuSampleForm.Frame3
  282.     With .LBLTogglePopup
  283.       .Caption := "This Label can allow or disallow the form's PopupMenu to come through"
  284.       .BackColor := 8388736
  285.       .ForeColor := 16777215
  286.       .ZOrder := 3
  287.       .Move(3600, 450, 2250, 1050)
  288.       .BorderStyle := "Fixed Single"
  289.       .Alignment := "Center"
  290.     End With  'PopupMenuSampleForm.LBLTogglePopup
  291.     With .OBEnablePopup
  292.       .Caption := "Enable Popup"
  293.       .ZOrder := 2
  294.       .Move(3600, 1650, 2250, 450)
  295.       .TabStop := True
  296.       .Value := True
  297.     End With  'PopupMenuSampleForm.OBEnablePopup
  298.     With .OBDisablePopup
  299.       .Caption := "Disable Popup"
  300.       .ZOrder := 1
  301.       .Move(3600, 2100, 2250, 450)
  302.     End With  'PopupMenuSampleForm.OBDisablePopup
  303.     With .HPCNoPopupRegion
  304.       .ZOrder := 15
  305.       .PopupMenu := PopupMenu
  306.       .Move(150, 2850, 5850, 2250)
  307.       .Outlined := True
  308.       .BorderStyle := "None"
  309.       .MaxButton := False
  310.       .ControlBox := False
  311.       .Parent := PopupMenuSampleForm
  312.       .Visible := True
  313.       With .Frame1
  314.         .Caption := "This region blocks the main form's PopupMenu"
  315.         .ZOrder := 4
  316.         .Move(0, 0, 5850, 2250)
  317.       End With  'PopupMenuSampleForm.HPCNoPopupRegion.Frame1
  318.       With .LBLTrackPopup
  319.         .Caption := "This Label uses the Track method for PopupMenus"
  320.         .BackColor := 8388736
  321.         .ForeColor := 16777215
  322.         .ZOrder := 3
  323.         .Move(150, 300, 1725, 1800)
  324.         .BorderStyle := "Fixed Single"
  325.         .Alignment := "Center"
  326.       End With  'PopupMenuSampleForm.HPCNoPopupRegion.LBLTrackPopup
  327.       With .LBLBothButtons
  328.         .Caption := "This Label lets the user use either mouse button for PopupMenus"
  329.         .BackColor := 8388736
  330.         .ForeColor := 16777215
  331.         .ZOrder := 2
  332.         .Move(2055, 300, 1725, 1800)
  333.         .BorderStyle := "Fixed Single"
  334.         .Alignment := "Center"
  335.       End With  'PopupMenuSampleForm.HPCNoPopupRegion.LBLBothButtons
  336.       With .LBLBothButtons1
  337.         .Caption := "This Label will only bring up a PopupMenu if the Left Button is pressed while the shift key is held down"
  338.         .ZOrder := 1
  339.         .Move(3960, 300, 1725, 1800)
  340.       End With  'PopupMenuSampleForm.HPCNoPopupRegion.LBLBothButtons1
  341.     End With  'PopupMenuSampleForm.HPCNoPopupRegion
  342.   End With  'PopupMenuSampleForm
  343. ' Reconstruction commands for object: PopupMenuSample
  344. '
  345.   With PopupMenuSample
  346.     .ModulePath := "base.ebo;win32.ebo;dialogs.ebo;tools.ebo;Popmenu.eto"
  347.     .ProjectFileName := "C:\Current\Popmenu\Popmenu.epj"
  348.     .Path := "C:\Current\Popmenu\"
  349.     .EXEName := "Popmenu"
  350.     With .AccessControl
  351.       .ObjectAccess := "R,W,C,M,P"
  352.     End With  'PopupMenuSample.AccessControl
  353.   End With  'PopupMenuSample
  354. End Code
  355.