home *** CD-ROM | disk | FTP | other *** search
- Type ImageMasterForm From SampleMasterForm
- Dim Label1 As New Label
- Dim optNone As New OptionButton
- Dim optLine As New OptionButton
- Dim optInset As New OptionButton
- Dim optRaised As New OptionButton
- Dim imgAttributes As New Image
- Dim imgTrafficLight As New Image
- Dim Label2 As New Label
- Dim Label3 As New Label
- Dim bitmapAttributes As New Bitmap
- Dim bmpRedTrafficLight As New Bitmap
- Dim bmpYellowTrafficLight As New Bitmap
- Dim bmpGreenTrafficLight As New Bitmap
- Dim Label4 As New Label
- Dim optBorderWidth0 As New OptionButton
- Dim optBorderWidth1 As New OptionButton
- Dim optBorderWidth2 As New OptionButton
- Dim optBorderWidth3 As New OptionButton
- Dim Label5 As New Label
- Dim optFull As New OptionButton
- Dim optHalf As New OptionButton
- Dim optDouble As New OptionButton
- Dim Label6 As New Label
- Dim optSBNever As New OptionButton
- Dim optSBAlways As New OptionButton
- Dim optSBAutomatic As New OptionButton
- Dim LabelFont As New Font
- Dim Label7 As New Label
- Dim btnGo As New Button
- Dim btnCaution As New Button
- Dim btnStop As New Button
- Dim chkZoomDemo As New CheckBox
-
- ' METHODS for object: ImageMasterForm
- Sub optNone_Click()
- imgAttributes.BevelOuter = "None"
- End Sub
-
- Sub optLine_Click()
- imgAttributes.BevelOuter = "Line"
- End Sub
-
- Sub optInset_Click()
- imgAttributes.BevelOuter = "Inset"
- End Sub
-
- Sub optHalf_Click()
- ZoomFactor(0.5)
- imgAttributes.Refresh
- End Sub
-
- Sub optDouble_Click()
- ZoomFactor(2)
- End Sub
-
- Sub optFull_Click()
- ZoomFactor(1)
- End Sub
-
- Sub optSBNever_Click()
- imgAttributes.ScrollBars = 0
- End Sub
-
- Sub optSBAlways_Click()
- imgAttributes.ScrollBars = 1
- End Sub
-
- Sub optSBAutomatic_Click()
- imgAttributes.ScrollBars = 2
- End Sub
-
- Sub optZoomDemo_Click()
- End Sub
-
- Sub chkZoomDemo_Click()
- If chkZoomDemo.Value == 0 Then
- chkZoomDemo.Caption = "Off"
- DemoZoomForm.Hide
- Else
- chkZoomDemo.Caption = "On"
- DemoZoomForm.Show
- End If
- End Sub
-
- Sub optRaised_Click()
- imgAttributes.BevelOuter = "Raised"
- End Sub
-
- Sub ZoomFactor(factor As Single)
- dim cx, cy as integer
- ' Zoom in on the image by a given scale factor
- imgAttributes.CropXOffset = bitmapAttributes.Width / 2 - (1 / factor) * (bitmapAttributes.Width / 2)
- imgAttributes.CropYOffset = bitmapAttributes.Height / 2 - (1 / factor) * (bitmapAttributes.Height / 2)
- cx = (1 / factor) * (bitmapAttributes.Width)
- cy = (1 / factor) * (bitmapAttributes.Height)
- If (cx < 1) Then cx = 1
- If (cy < 1) Then cy = 1
- imgAttributes.CropXSize = cx
- imgAttributes.CropYSize = cy
- imgAttributes.Refresh
- End Sub
-
- Sub optBorderWidth2_Click()
- imgAttributes.BevelWidth = 2
- End Sub
-
- Sub optBorderWidth0_Click()
- imgAttributes.BevelWidth = 0
- End Sub
-
- Sub optBorderWidth1_Click()
- imgAttributes.BevelWidth = 1
- End Sub
-
- Sub optBorderWidth3_Click()
- imgAttributes.BevelWidth = 3
- End Sub
-
- Sub btnCaution_Click()
- imgTrafficLight.Picture = bmpYellowTrafficLight
- imgTrafficLight.Refresh
- End Sub
-
- Sub btnGo_Click()
- imgTrafficLight.Picture = bmpGreenTrafficLight
- imgTrafficLight.Refresh
- End Sub
-
- Sub btnStop_Click()
- imgTrafficLight.Picture = bmpRedTrafficLight
- imgTrafficLight.Refresh
- End Sub
-
- Sub ResetApplication_Click ()
- ' Make sure form is loaded
- LoadForm
-
- ' Initialize the Border Style options
- optNone.Value = False
- optLine.Value = False
- optInset.Value = True
- optRaised.Value = False
-
- ' Initialize Border width attribute
- optBorderWidth0.Value = False
- optBorderWidth1.Value = False
- optBorderWidth2.Value = True
- optBorderWidth3.Value = False
-
- ' Initialize scrollbars in this demo
- imgAttributes.ScrollBars = 0
-
- imgTrafficLight.Picture = bmpGreenTrafficLight
- imgTrafficLight.Refresh
-
- ' Default Zoom option
- optFull.Value = True
- optSBNever.Value = True
- chkZoomDemo.Value = 0
- chkZoomDemo.Caption = "Off"
-
- End Sub
-
- End Type
-
- Type DemoZoomForm From Form
- Dim ZoomFileMenu As New PopupMenu
- Dim ZoomMenuBar As New MenuBar
- Dim Color As Long
- Dim imgZoom As New Image
- Dim FocusRec As New RECT
- Dim X1 As Long
- Dim X2 As Long
- Dim Y1 As Long
- Dim Y2 As Long
-
- ' METHODS for object: DemoZoomForm
- Sub MouseUp(button, shift As Integer, x,y As Single)
- End Sub
-
- Sub Resize()
-
- ' Prevent the size of the form from being changed
- Width = 3960
- Height = 4515
-
- ' Keep the size of the image in sync with the size of the form
- imgZoom.Left = 0
- imgZoom.Top = 0
- imgZoom.Width = ScaleWidth
- imgZoom.Height = ScaleHeight
-
- imgZoom.Refresh
- End Sub
-
- Sub Swap(firstArg, secondArg As Long)
- dim temp as Long
- temp = firstArg
- firstArg = secondArg
- secondArg = temp
- End Sub
-
- Sub imgZoom_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
- ' Be sure it's the left_ button
- If (Button And 1) == 0 Then Exit Sub
-
- ' Set starting corner of box
- X1 = X / 15
- Y1 = Y / 15
- End Sub
-
- Sub imgZoom_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
- dim Ret% As Integer
- dim xs, ys As Single
-
- ' Be sure it's the left_ button
- If (Button And 1) == 0 Then Exit Sub
-
- ' Erase focus rectangle if it exists
- If FocusRec.right_ Or FocusRec.bottom Then
- User32.DrawFocusRect imgZoom.hDC, FocusRec
- End If
-
- ' Set line thickness
- ' Picture1.DrawWidth = 2
-
- ' Put coordinates in correct order
- If X2 < X1 Then Swap X1, X2
- If Y2 < Y1 Then Swap Y1, Y2
-
- xs = imgZoom.ScaleX
- ys = imgZoom.ScaleY
-
- imgZoom.CropXOffset = X1 / xs
- imgZoom.CropYOffset = Y1 / ys
- imgZoom.CropXSize = ((X2 - X1) + 1) / xs
- imgZoom.CropYSize = ((Y2 - Y1) + 1) / ys
- imgZoom.Refresh
-
- ' Zero the rectangle coordinates
- X1 = 0
- Y1 = 0
- X2 = 0
- Y2 = 0
-
- End Sub
-
- Sub imgZoom_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
- ' Be sure left_ button is depressed
- If (Button And 1) == 0 Then Exit Sub
-
- ' Erase focus rectangle if it exists
- If X2 Or Y2 Then
- User32.DrawFocusRect imgZoom.hDC, FocusRec
- End If
-
- ' Update coordinates
- X2 = X / 15
- Y2 = Y / 15
-
- ' Update rectangle
- FocusRec.left_ = X1
- FocusRec.top = Y1
- FocusRec.right_ = X2
- FocusRec.bottom = Y2
-
- ' Adjust rectangle
- If Y2 < Y1 Then Swap FocusRec.top, FocusRec.bottom
-
- ' Draw focus rectangle
- User32.DrawFocusRect imgZoom.hDC, FocusRec
- End Sub
-
- Sub ExitZoom_Click()
- ImageMasterForm.chkZoomDemo.Value = 0
- ImageMasterForm.chkZoomDemo_Click
- End Sub
-
- Sub Load()
- ' Preset the size of the form
- Width = 3960
- Height = 4515
-
- ' Show a test bitmap image
- imgZoom.Picture = ImageMasterForm.bitmapAttributes
- imgZoom.Refresh
- End Sub
-
- Sub FullScale_Click()
- imgZoom.InitCropRect()
- imgZoom.Refresh()
- End Sub
-
- End Type
-
- Begin Code
- ' Reconstruction commands for object: ImageMasterForm
- '
- With ImageMasterForm
- .Caption := "Image Demonstration"
- .Move(5595, 1575, 6900, 6105)
- .SampleDir := "W:\bootcamp\basic\image\"
- .SampleName := "image"
- With .Label1
- .Caption := "1. Image Attributes"
- .ForeColor := 13107200
- .ZOrder := 1
- .Move(300, 150, 1950, 300)
- End With 'ImageMasterForm.Label1
- With .optNone
- .Caption := "0 = None"
- .ZOrder := 2
- .Move(300, 900, 1635, 300)
- .TabGroup := True
- End With 'ImageMasterForm.optNone
- With .optLine
- .Caption := "1 = Line"
- .ZOrder := 3
- .Move(300, 1200, 1635, 300)
- End With 'ImageMasterForm.optLine
- With .optInset
- .Caption := "2 = Inset"
- .ZOrder := 4
- .Move(300, 1500, 1635, 300)
- .TabStop := True
- .Value := True
- End With 'ImageMasterForm.optInset
- With .optRaised
- .Caption := "3 = Raised"
- .ZOrder := 5
- .Move(300, 1800, 1635, 300)
- End With 'ImageMasterForm.optRaised
- With .imgAttributes
- .ZOrder := 6
- .Move(1950, 600, 2550, 2400)
- .TabStop := False
- .AutoInitCropRect := False
- .Picture := ImageMasterForm.bitmapAttributes
- .ScrollBars := "Never"
- .CropXSize := 256
- .CropYSize := 256
- End With 'ImageMasterForm.imgAttributes
- With .imgTrafficLight
- .ZOrder := 7
- .Move(5100, 3450, 900, 1050)
- .TabStop := False
- .BevelOuter := "None"
- .Picture := ImageMasterForm.bmpGreenTrafficLight
- End With 'ImageMasterForm.imgTrafficLight
- With .Label2
- .Caption := "BevelOuter"
- .Font := ImageMasterForm.LabelFont
- .ZOrder := 8
- .Move(300, 600, 1500, 300)
- End With 'ImageMasterForm.Label2
- With .Label3
- .Caption := "Zoom Factor"
- .Font := ImageMasterForm.LabelFont
- .ZOrder := 9
- .Move(4950, 600, 1500, 300)
- End With 'ImageMasterForm.Label3
- With .bitmapAttributes
- .LoadType := "MemoryBased"
- .FileName := "image.ero"
- .ResId := 0
- End With 'ImageMasterForm.bitmapAttributes
- With .bmpRedTrafficLight
- .LoadType := "MemoryBased"
- .FileName := "image.ero"
- .ResId := 32884
- End With 'ImageMasterForm.bmpRedTrafficLight
- With .bmpYellowTrafficLight
- .LoadType := "MemoryBased"
- .FileName := "image.ero"
- .ResId := 33512
- End With 'ImageMasterForm.bmpYellowTrafficLight
- With .bmpGreenTrafficLight
- .LoadType := "MemoryBased"
- .FileName := "image.ero"
- .ResId := 34140
- End With 'ImageMasterForm.bmpGreenTrafficLight
- With .Label4
- .Caption := "BevelWidth"
- .Font := ImageMasterForm.LabelFont
- .ZOrder := 10
- .Move(300, 2250, 1500, 300)
- End With 'ImageMasterForm.Label4
- With .optBorderWidth0
- .Caption := "0"
- .ZOrder := 11
- .Move(300, 2550, 600, 300)
- .TabGroup := True
- End With 'ImageMasterForm.optBorderWidth0
- With .optBorderWidth1
- .Caption := "1"
- .ZOrder := 12
- .Move(300, 2850, 600, 300)
- End With 'ImageMasterForm.optBorderWidth1
- With .optBorderWidth2
- .Caption := "2"
- .ZOrder := 13
- .Move(1050, 2550, 750, 300)
- .TabStop := True
- .Value := True
- End With 'ImageMasterForm.optBorderWidth2
- With .optBorderWidth3
- .Caption := "3"
- .ZOrder := 14
- .Move(1050, 2850, 750, 300)
- End With 'ImageMasterForm.optBorderWidth3
- With .Label5
- .Caption := "2. Change Image by click events."
- .ForeColor := 13107200
- .ZOrder := 15
- .Move(300, 3450, 3450, 300)
- End With 'ImageMasterForm.Label5
- With .optFull
- .Caption := "Full"
- .ZOrder := 16
- .Move(4950, 900, 1350, 300)
- .TabStop := True
- .TabGroup := True
- .Value := True
- End With 'ImageMasterForm.optFull
- With .optHalf
- .Caption := "Half"
- .ZOrder := 17
- .Move(4950, 1200, 1350, 300)
- End With 'ImageMasterForm.optHalf
- With .optDouble
- .Caption := "Double"
- .ZOrder := 18
- .Move(4950, 1500, 1350, 300)
- End With 'ImageMasterForm.optDouble
- With .Label6
- .Caption := "ScrollBars"
- .Font := ImageMasterForm.LabelFont
- .ZOrder := 19
- .Move(4950, 1950, 1350, 300)
- End With 'ImageMasterForm.Label6
- With .optSBNever
- .Caption := "Never"
- .ZOrder := 20
- .Move(4950, 2250, 1350, 300)
- .TabStop := True
- .TabGroup := True
- .Value := True
- End With 'ImageMasterForm.optSBNever
- With .optSBAlways
- .Caption := "Always"
- .ZOrder := 21
- .Move(4950, 2550, 1350, 300)
- End With 'ImageMasterForm.optSBAlways
- With .optSBAutomatic
- .Caption := "Automatic"
- .ZOrder := 22
- .Move(4950, 2850, 1350, 300)
- End With 'ImageMasterForm.optSBAutomatic
- With .LabelFont
- .FaceName := "Terminal"
- .Underline := True
- End With 'ImageMasterForm.LabelFont
- With .Label7
- .Caption := "3. Dynamic zoom demonstration:"
- .ForeColor := 13107200
- .ZOrder := 23
- .Move(300, 4950, 3300, 300)
- End With 'ImageMasterForm.Label7
- With .btnGo
- .Caption := "Go"
- .ZOrder := 24
- .Move(555, 4095, 1050, 450)
- End With 'ImageMasterForm.btnGo
- With .btnCaution
- .Caption := "Caution"
- .ZOrder := 25
- .Move(1905, 4095, 1050, 450)
- End With 'ImageMasterForm.btnCaution
- With .btnStop
- .Caption := "Stop"
- .ZOrder := 26
- .Move(3255, 4095, 1050, 450)
- End With 'ImageMasterForm.btnStop
- With .chkZoomDemo
- .Caption := "Off"
- .ZOrder := 27
- .Move(3750, 4950, 1050, 300)
- .TabGroup := True
- End With 'ImageMasterForm.chkZoomDemo
- With .helpfile
- .FileName := "W:\bootcamp\basic\image\image.hlp"
- End With 'ImageMasterForm.helpfile
- End With 'ImageMasterForm
- ' Reconstruction commands for object: DemoZoomForm
- '
- With DemoZoomForm
- .Caption := "Click and drag over image"
- .Move(9300, 4950, 3960, 4515)
- .BevelWidth := 0
- .Outlined := True
- .FillStyle := "Transparent"
- .ScaleMode := "Pixel"
- .MenuBar := DemoZoomForm.ZoomMenuBar
- .Color := 1
- .X1 := 0
- .X2 := 0
- .Y1 := 0
- .Y2 := 0
- With .ZoomFileMenu
-
- .InsertItem("FullScale", "&Fit", -1)
- .InsertItem("ExitZoom", "Exit", -1)
- End With 'DemoZoomForm.ZoomFileMenu
- With .ZoomMenuBar
-
- .InsertPopup(DemoZoomForm.ZoomFileMenu, "&Options", -1)
- End With 'DemoZoomForm.ZoomMenuBar
- With .imgZoom
- .Caption := "imgZoom"
- .ZOrder := 1
- .Move(0, 0, 256, 255)
- .BevelOuter := "None"
- .BevelWidth := 0
- .AutoInitCropRect := False
- .Picture := ImageMasterForm.bitmapAttributes
- .CropXSize := 256
- .CropYSize := 256
- End With 'DemoZoomForm.imgZoom
- With .FocusRec
- .left_ := 53
- .top := 10
- .right_ := 115
- .bottom := 123
- End With 'DemoZoomForm.FocusRec
- End With 'DemoZoomForm
- End Code
-