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 / image / image.eto < prev    next >
Encoding:
Text File  |  1996-07-08  |  14.2 KB  |  538 lines

  1. Type ImageMasterForm From SampleMasterForm
  2.   Dim Label1 As New Label
  3.   Dim optNone As New OptionButton
  4.   Dim optLine As New OptionButton
  5.   Dim optInset As New OptionButton
  6.   Dim optRaised As New OptionButton
  7.   Dim imgAttributes As New Image
  8.   Dim imgTrafficLight As New Image
  9.   Dim Label2 As New Label
  10.   Dim Label3 As New Label
  11.   Dim bitmapAttributes As New Bitmap
  12.   Dim bmpRedTrafficLight As New Bitmap
  13.   Dim bmpYellowTrafficLight As New Bitmap
  14.   Dim bmpGreenTrafficLight As New Bitmap
  15.   Dim Label4 As New Label
  16.   Dim optBorderWidth0 As New OptionButton
  17.   Dim optBorderWidth1 As New OptionButton
  18.   Dim optBorderWidth2 As New OptionButton
  19.   Dim optBorderWidth3 As New OptionButton
  20.   Dim Label5 As New Label
  21.   Dim optFull As New OptionButton
  22.   Dim optHalf As New OptionButton
  23.   Dim optDouble As New OptionButton
  24.   Dim Label6 As New Label
  25.   Dim optSBNever As New OptionButton
  26.   Dim optSBAlways As New OptionButton
  27.   Dim optSBAutomatic As New OptionButton
  28.   Dim LabelFont As New Font
  29.   Dim Label7 As New Label
  30.   Dim btnGo As New Button
  31.   Dim btnCaution As New Button
  32.   Dim btnStop As New Button
  33.   Dim chkZoomDemo As New CheckBox
  34.  
  35.   ' METHODS for object: ImageMasterForm
  36.   Sub optNone_Click()
  37.     imgAttributes.BevelOuter = "None"
  38.   End Sub
  39.  
  40.   Sub optLine_Click()
  41.     imgAttributes.BevelOuter = "Line"
  42.   End Sub
  43.  
  44.   Sub optInset_Click()
  45.     imgAttributes.BevelOuter = "Inset"
  46.   End Sub
  47.  
  48.   Sub optHalf_Click()
  49.     ZoomFactor(0.5)
  50.     imgAttributes.Refresh
  51.   End Sub
  52.  
  53.   Sub optDouble_Click()
  54.     ZoomFactor(2)
  55.   End Sub
  56.  
  57.   Sub optFull_Click()
  58.     ZoomFactor(1)
  59.   End Sub
  60.  
  61.   Sub optSBNever_Click()
  62.     imgAttributes.ScrollBars = 0
  63.   End Sub
  64.  
  65.   Sub optSBAlways_Click()
  66.     imgAttributes.ScrollBars = 1
  67.   End Sub
  68.  
  69.   Sub optSBAutomatic_Click()
  70.     imgAttributes.ScrollBars = 2
  71.   End Sub
  72.  
  73.   Sub optZoomDemo_Click()
  74.   End Sub
  75.  
  76.   Sub chkZoomDemo_Click()
  77.     If chkZoomDemo.Value == 0 Then 
  78.       chkZoomDemo.Caption = "Off"
  79.       DemoZoomForm.Hide
  80.     Else 
  81.       chkZoomDemo.Caption = "On"
  82.       DemoZoomForm.Show
  83.     End If
  84.   End Sub
  85.  
  86.   Sub optRaised_Click()
  87.     imgAttributes.BevelOuter = "Raised"
  88.   End Sub
  89.  
  90.   Sub ZoomFactor(factor As Single)
  91.     dim cx, cy as integer
  92.     ' Zoom in on the image by a given scale factor
  93.     imgAttributes.CropXOffset = bitmapAttributes.Width / 2 - (1 / factor) * (bitmapAttributes.Width / 2)
  94.     imgAttributes.CropYOffset = bitmapAttributes.Height / 2 - (1 / factor) * (bitmapAttributes.Height / 2)
  95.     cx = (1 / factor) * (bitmapAttributes.Width)
  96.     cy = (1 / factor) * (bitmapAttributes.Height)
  97.     If (cx < 1) Then cx = 1
  98.     If (cy < 1) Then cy = 1
  99.     imgAttributes.CropXSize = cx
  100.     imgAttributes.CropYSize = cy
  101.     imgAttributes.Refresh
  102.   End Sub
  103.  
  104.   Sub optBorderWidth2_Click()
  105.     imgAttributes.BevelWidth = 2
  106.   End Sub
  107.  
  108.   Sub optBorderWidth0_Click()
  109.     imgAttributes.BevelWidth = 0
  110.   End Sub
  111.  
  112.   Sub optBorderWidth1_Click()
  113.     imgAttributes.BevelWidth = 1
  114.   End Sub
  115.  
  116.   Sub optBorderWidth3_Click()
  117.     imgAttributes.BevelWidth = 3
  118.   End Sub
  119.  
  120.   Sub btnCaution_Click()
  121.     imgTrafficLight.Picture = bmpYellowTrafficLight
  122.     imgTrafficLight.Refresh
  123.   End Sub
  124.  
  125.   Sub btnGo_Click()
  126.     imgTrafficLight.Picture = bmpGreenTrafficLight
  127.     imgTrafficLight.Refresh
  128.   End Sub
  129.  
  130.   Sub btnStop_Click()
  131.     imgTrafficLight.Picture = bmpRedTrafficLight
  132.     imgTrafficLight.Refresh
  133.   End Sub
  134.  
  135.   Sub ResetApplication_Click ()
  136.     ' Make sure form is loaded
  137.     LoadForm
  138.   
  139.     ' Initialize the Border Style options
  140.     optNone.Value = False
  141.     optLine.Value = False
  142.     optInset.Value = True
  143.     optRaised.Value = False
  144.   
  145.     ' Initialize Border width attribute
  146.     optBorderWidth0.Value = False
  147.     optBorderWidth1.Value = False
  148.     optBorderWidth2.Value = True
  149.     optBorderWidth3.Value = False
  150.   
  151.     ' Initialize scrollbars in this demo
  152.     imgAttributes.ScrollBars = 0
  153.   
  154.     imgTrafficLight.Picture = bmpGreenTrafficLight
  155.     imgTrafficLight.Refresh
  156.   
  157.     ' Default Zoom option
  158.     optFull.Value = True
  159.     optSBNever.Value = True
  160.     chkZoomDemo.Value = 0
  161.     chkZoomDemo.Caption = "Off"
  162.   
  163.   End Sub
  164.  
  165. End Type
  166.  
  167. Type DemoZoomForm From Form
  168.   Dim ZoomFileMenu As New PopupMenu
  169.   Dim ZoomMenuBar As New MenuBar
  170.   Dim Color As Long
  171.   Dim imgZoom As New Image
  172.   Dim FocusRec As New RECT
  173.   Dim X1 As Long
  174.   Dim X2 As Long
  175.   Dim Y1 As Long
  176.   Dim Y2 As Long
  177.  
  178.   ' METHODS for object: DemoZoomForm
  179.   Sub MouseUp(button, shift As Integer, x,y As Single)
  180.   End Sub
  181.  
  182.   Sub Resize()
  183.   
  184.     ' Prevent the size of the form from being changed
  185.     Width = 3960
  186.     Height = 4515
  187.   
  188.     ' Keep the size of the image in sync with the size of the form
  189.     imgZoom.Left = 0
  190.     imgZoom.Top = 0
  191.     imgZoom.Width = ScaleWidth
  192.     imgZoom.Height = ScaleHeight
  193.   
  194.     imgZoom.Refresh
  195.   End Sub
  196.  
  197.   Sub Swap(firstArg, secondArg As Long)
  198.     dim temp as Long
  199.     temp = firstArg
  200.     firstArg = secondArg
  201.     secondArg = temp
  202.   End Sub
  203.  
  204.   Sub imgZoom_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  205.     ' Be sure it's the left_ button
  206.     If (Button And 1) == 0 Then Exit Sub
  207.   
  208.     ' Set starting corner of box
  209.     X1 = X / 15
  210.     Y1 = Y / 15
  211.   End Sub
  212.  
  213.   Sub imgZoom_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  214.     dim Ret% As Integer
  215.     dim xs, ys As Single
  216.   
  217.     ' Be sure it's the left_ button
  218.     If (Button And 1) == 0 Then Exit Sub
  219.   
  220.     ' Erase focus rectangle if it exists
  221.     If FocusRec.right_ Or FocusRec.bottom Then 
  222.       User32.DrawFocusRect imgZoom.hDC, FocusRec
  223.     End If
  224.   
  225.     ' Set line thickness
  226.     ' Picture1.DrawWidth = 2
  227.   
  228.     ' Put coordinates in correct order
  229.     If X2 < X1 Then Swap X1, X2
  230.     If Y2 < Y1 Then Swap Y1, Y2
  231.   
  232.     xs = imgZoom.ScaleX
  233.     ys = imgZoom.ScaleY
  234.   
  235.     imgZoom.CropXOffset = X1 / xs
  236.     imgZoom.CropYOffset = Y1 / ys
  237.     imgZoom.CropXSize = ((X2 - X1) + 1) / xs
  238.     imgZoom.CropYSize = ((Y2 - Y1) + 1) / ys
  239.     imgZoom.Refresh
  240.   
  241.     ' Zero the rectangle coordinates
  242.     X1 = 0
  243.     Y1 = 0
  244.     X2 = 0
  245.     Y2 = 0
  246.   
  247.   End Sub
  248.  
  249.   Sub imgZoom_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  250.     ' Be sure left_ button is depressed
  251.     If (Button And 1) == 0 Then Exit Sub
  252.   
  253.     ' Erase focus rectangle if it exists
  254.     If X2 Or Y2 Then 
  255.       User32.DrawFocusRect imgZoom.hDC, FocusRec
  256.     End If
  257.   
  258.     ' Update coordinates
  259.     X2 = X / 15
  260.     Y2 = Y / 15
  261.   
  262.     ' Update rectangle
  263.     FocusRec.left_ = X1
  264.     FocusRec.top = Y1
  265.     FocusRec.right_ = X2
  266.     FocusRec.bottom = Y2
  267.   
  268.     ' Adjust rectangle
  269.     If Y2 < Y1 Then Swap FocusRec.top, FocusRec.bottom
  270.   
  271.     ' Draw focus rectangle
  272.     User32.DrawFocusRect imgZoom.hDC, FocusRec
  273.   End Sub
  274.  
  275.   Sub ExitZoom_Click()
  276.     ImageMasterForm.chkZoomDemo.Value = 0
  277.     ImageMasterForm.chkZoomDemo_Click
  278.   End Sub
  279.  
  280.   Sub Load()
  281.     ' Preset the size of the form
  282.     Width = 3960
  283.     Height = 4515
  284.   
  285.     ' Show a test bitmap image
  286.     imgZoom.Picture = ImageMasterForm.bitmapAttributes
  287.     imgZoom.Refresh
  288.   End Sub
  289.  
  290.   Sub FullScale_Click()
  291.     imgZoom.InitCropRect()
  292.     imgZoom.Refresh()
  293.   End Sub
  294.  
  295. End Type
  296.  
  297. Begin Code
  298. ' Reconstruction commands for object: ImageMasterForm
  299. '
  300.   With ImageMasterForm
  301.     .Caption := "Image Demonstration"
  302.     .Move(5595, 1575, 6900, 6105)
  303.     .SampleDir := "W:\bootcamp\basic\image\"
  304.     .SampleName := "image"
  305.     With .Label1
  306.       .Caption := "1. Image Attributes"
  307.       .ForeColor := 13107200
  308.       .ZOrder := 1
  309.       .Move(300, 150, 1950, 300)
  310.     End With  'ImageMasterForm.Label1
  311.     With .optNone
  312.       .Caption := "0 = None"
  313.       .ZOrder := 2
  314.       .Move(300, 900, 1635, 300)
  315.       .TabGroup := True
  316.     End With  'ImageMasterForm.optNone
  317.     With .optLine
  318.       .Caption := "1 = Line"
  319.       .ZOrder := 3
  320.       .Move(300, 1200, 1635, 300)
  321.     End With  'ImageMasterForm.optLine
  322.     With .optInset
  323.       .Caption := "2 = Inset"
  324.       .ZOrder := 4
  325.       .Move(300, 1500, 1635, 300)
  326.       .TabStop := True
  327.       .Value := True
  328.     End With  'ImageMasterForm.optInset
  329.     With .optRaised
  330.       .Caption := "3 = Raised"
  331.       .ZOrder := 5
  332.       .Move(300, 1800, 1635, 300)
  333.     End With  'ImageMasterForm.optRaised
  334.     With .imgAttributes
  335.       .ZOrder := 6
  336.       .Move(1950, 600, 2550, 2400)
  337.       .TabStop := False
  338.       .AutoInitCropRect := False
  339.       .Picture := ImageMasterForm.bitmapAttributes
  340.       .ScrollBars := "Never"
  341.       .CropXSize := 256
  342.       .CropYSize := 256
  343.     End With  'ImageMasterForm.imgAttributes
  344.     With .imgTrafficLight
  345.       .ZOrder := 7
  346.       .Move(5100, 3450, 900, 1050)
  347.       .TabStop := False
  348.       .BevelOuter := "None"
  349.       .Picture := ImageMasterForm.bmpGreenTrafficLight
  350.     End With  'ImageMasterForm.imgTrafficLight
  351.     With .Label2
  352.       .Caption := "BevelOuter"
  353.       .Font := ImageMasterForm.LabelFont
  354.       .ZOrder := 8
  355.       .Move(300, 600, 1500, 300)
  356.     End With  'ImageMasterForm.Label2
  357.     With .Label3
  358.       .Caption := "Zoom Factor"
  359.       .Font := ImageMasterForm.LabelFont
  360.       .ZOrder := 9
  361.       .Move(4950, 600, 1500, 300)
  362.     End With  'ImageMasterForm.Label3
  363.     With .bitmapAttributes
  364.       .LoadType := "MemoryBased"
  365.       .FileName := "image.ero"
  366.       .ResId := 0
  367.     End With  'ImageMasterForm.bitmapAttributes
  368.     With .bmpRedTrafficLight
  369.       .LoadType := "MemoryBased"
  370.       .FileName := "image.ero"
  371.       .ResId := 32884
  372.     End With  'ImageMasterForm.bmpRedTrafficLight
  373.     With .bmpYellowTrafficLight
  374.       .LoadType := "MemoryBased"
  375.       .FileName := "image.ero"
  376.       .ResId := 33512
  377.     End With  'ImageMasterForm.bmpYellowTrafficLight
  378.     With .bmpGreenTrafficLight
  379.       .LoadType := "MemoryBased"
  380.       .FileName := "image.ero"
  381.       .ResId := 34140
  382.     End With  'ImageMasterForm.bmpGreenTrafficLight
  383.     With .Label4
  384.       .Caption := "BevelWidth"
  385.       .Font := ImageMasterForm.LabelFont
  386.       .ZOrder := 10
  387.       .Move(300, 2250, 1500, 300)
  388.     End With  'ImageMasterForm.Label4
  389.     With .optBorderWidth0
  390.       .Caption := "0"
  391.       .ZOrder := 11
  392.       .Move(300, 2550, 600, 300)
  393.       .TabGroup := True
  394.     End With  'ImageMasterForm.optBorderWidth0
  395.     With .optBorderWidth1
  396.       .Caption := "1"
  397.       .ZOrder := 12
  398.       .Move(300, 2850, 600, 300)
  399.     End With  'ImageMasterForm.optBorderWidth1
  400.     With .optBorderWidth2
  401.       .Caption := "2"
  402.       .ZOrder := 13
  403.       .Move(1050, 2550, 750, 300)
  404.       .TabStop := True
  405.       .Value := True
  406.     End With  'ImageMasterForm.optBorderWidth2
  407.     With .optBorderWidth3
  408.       .Caption := "3"
  409.       .ZOrder := 14
  410.       .Move(1050, 2850, 750, 300)
  411.     End With  'ImageMasterForm.optBorderWidth3
  412.     With .Label5
  413.       .Caption := "2. Change Image by click events."
  414.       .ForeColor := 13107200
  415.       .ZOrder := 15
  416.       .Move(300, 3450, 3450, 300)
  417.     End With  'ImageMasterForm.Label5
  418.     With .optFull
  419.       .Caption := "Full"
  420.       .ZOrder := 16
  421.       .Move(4950, 900, 1350, 300)
  422.       .TabStop := True
  423.       .TabGroup := True
  424.       .Value := True
  425.     End With  'ImageMasterForm.optFull
  426.     With .optHalf
  427.       .Caption := "Half"
  428.       .ZOrder := 17
  429.       .Move(4950, 1200, 1350, 300)
  430.     End With  'ImageMasterForm.optHalf
  431.     With .optDouble
  432.       .Caption := "Double"
  433.       .ZOrder := 18
  434.       .Move(4950, 1500, 1350, 300)
  435.     End With  'ImageMasterForm.optDouble
  436.     With .Label6
  437.       .Caption := "ScrollBars"
  438.       .Font := ImageMasterForm.LabelFont
  439.       .ZOrder := 19
  440.       .Move(4950, 1950, 1350, 300)
  441.     End With  'ImageMasterForm.Label6
  442.     With .optSBNever
  443.       .Caption := "Never"
  444.       .ZOrder := 20
  445.       .Move(4950, 2250, 1350, 300)
  446.       .TabStop := True
  447.       .TabGroup := True
  448.       .Value := True
  449.     End With  'ImageMasterForm.optSBNever
  450.     With .optSBAlways
  451.       .Caption := "Always"
  452.       .ZOrder := 21
  453.       .Move(4950, 2550, 1350, 300)
  454.     End With  'ImageMasterForm.optSBAlways
  455.     With .optSBAutomatic
  456.       .Caption := "Automatic"
  457.       .ZOrder := 22
  458.       .Move(4950, 2850, 1350, 300)
  459.     End With  'ImageMasterForm.optSBAutomatic
  460.     With .LabelFont
  461.       .FaceName := "Terminal"
  462.       .Underline := True
  463.     End With  'ImageMasterForm.LabelFont
  464.     With .Label7
  465.       .Caption := "3. Dynamic zoom demonstration:"
  466.       .ForeColor := 13107200
  467.       .ZOrder := 23
  468.       .Move(300, 4950, 3300, 300)
  469.     End With  'ImageMasterForm.Label7
  470.     With .btnGo
  471.       .Caption := "Go"
  472.       .ZOrder := 24
  473.       .Move(555, 4095, 1050, 450)
  474.     End With  'ImageMasterForm.btnGo
  475.     With .btnCaution
  476.       .Caption := "Caution"
  477.       .ZOrder := 25
  478.       .Move(1905, 4095, 1050, 450)
  479.     End With  'ImageMasterForm.btnCaution
  480.     With .btnStop
  481.       .Caption := "Stop"
  482.       .ZOrder := 26
  483.       .Move(3255, 4095, 1050, 450)
  484.     End With  'ImageMasterForm.btnStop
  485.     With .chkZoomDemo
  486.       .Caption := "Off"
  487.       .ZOrder := 27
  488.       .Move(3750, 4950, 1050, 300)
  489.       .TabGroup := True
  490.     End With  'ImageMasterForm.chkZoomDemo
  491.     With .helpfile
  492.       .FileName := "W:\bootcamp\basic\image\image.hlp"
  493.     End With  'ImageMasterForm.helpfile
  494.   End With  'ImageMasterForm
  495. ' Reconstruction commands for object: DemoZoomForm
  496. '
  497.   With DemoZoomForm
  498.     .Caption := "Click and drag over image"
  499.     .Move(9300, 4950, 3960, 4515)
  500.     .BevelWidth := 0
  501.     .Outlined := True
  502.     .FillStyle := "Transparent"
  503.     .ScaleMode := "Pixel"
  504.     .MenuBar := DemoZoomForm.ZoomMenuBar
  505.     .Color := 1
  506.     .X1 := 0
  507.     .X2 := 0
  508.     .Y1 := 0
  509.     .Y2 := 0
  510.     With .ZoomFileMenu
  511.  
  512.       .InsertItem("FullScale", "&Fit", -1)
  513.       .InsertItem("ExitZoom", "Exit", -1)
  514.     End With  'DemoZoomForm.ZoomFileMenu
  515.     With .ZoomMenuBar
  516.  
  517.       .InsertPopup(DemoZoomForm.ZoomFileMenu, "&Options", -1)
  518.     End With  'DemoZoomForm.ZoomMenuBar
  519.     With .imgZoom
  520.       .Caption := "imgZoom"
  521.       .ZOrder := 1
  522.       .Move(0, 0, 256, 255)
  523.       .BevelOuter := "None"
  524.       .BevelWidth := 0
  525.       .AutoInitCropRect := False
  526.       .Picture := ImageMasterForm.bitmapAttributes
  527.       .CropXSize := 256
  528.       .CropYSize := 256
  529.     End With  'DemoZoomForm.imgZoom
  530.     With .FocusRec
  531.       .left_ := 53
  532.       .top := 10
  533.       .right_ := 115
  534.       .bottom := 123
  535.     End With  'DemoZoomForm.FocusRec
  536.   End With  'DemoZoomForm
  537. End Code
  538.