home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.UserControl ScrollImgBox
- AutoRedraw = -1 'True
- BackColor = &H00808080&
- ClientHeight = 3765
- ClientLeft = 0
- ClientTop = 0
- ClientWidth = 3930
- ScaleHeight = 3765
- ScaleWidth = 3930
- Begin VB.VScrollBar VScroll1
- Height = 3420
- Left = 3645
- TabIndex = 3
- Top = 0
- Width = 240
- End
- Begin VB.HScrollBar HScroll1
- Height = 240
- Left = 15
- TabIndex = 2
- Top = 3495
- Width = 3600
- End
- Begin VB.PictureBox Picture2
- AutoRedraw = -1 'True
- BorderStyle = 0 'None
- Height = 3345
- Left = 120
- ScaleHeight = 223
- ScaleMode = 3 'Pixel
- ScaleWidth = 234
- TabIndex = 1
- Top = 120
- Width = 3510
- End
- Begin VB.PictureBox Picture1
- AutoRedraw = -1 'True
- AutoSize = -1 'True
- Height = 2235
- Left = 60
- ScaleHeight = 145
- ScaleMode = 3 'Pixel
- ScaleWidth = 117
- TabIndex = 0
- Top = 60
- Visible = 0 'False
- Width = 1815
- End
- End
- Attribute VB_Name = "ScrollImgBox"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = True
- Option Explicit
- Enum Styles
- None
- SingleLine
- End Enum
-
- 'Default Property Values:
- Const m_def_PictureFromURL = ""
- Const m_def_PictureWidth = 0
- Const m_def_PictureHeight = 0
-
- 'Property Variables:
- Private m_PictureFromURL As String
- Private m_PictureWidth As Integer
- Private m_PictureHeight As Integer
-
- 'Event Declarations:
- Event Click() 'MappingInfo=Picture1,Picture1,-1,Click
- Event DblClick() 'MappingInfo=Picture1,Picture1,-1,DblClick
- Event KeyDown(KeyCode As Integer, Shift As Integer) 'MappingInfo=Picture1,Picture1,-1,KeyDown
- Event KeyPress(KeyAscii As Integer) 'MappingInfo=Picture1,Picture1,-1,KeyPress
- Event KeyUp(KeyCode As Integer, Shift As Integer) 'MappingInfo=Picture1,Picture1,-1,KeyUp
- Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=Picture1,Picture1,-1,MouseDown
- Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=Picture1,Picture1,-1,MouseMove
- Event ScrollX(X As Integer) 'MappingInfo=HScroll1,HScroll1,-1,Scroll
- Event ScrollY(Y As Integer) 'MappingInfo=VScroll1,VScroll1,-1,Scroll
- Event ChangeX(X As Integer) 'MappingInfo=HScroll1,HScroll1,-1,Change
- Event ChangeY(Y As Integer) 'MappingInfo=VScroll1,VScroll1,-1,Change
- Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseUp
-
- Event DownloadFailed()
- Event DownloadCompleted()
-
- Private Sub UserControl_AsyncReadComplete(AsyncProp As AsyncProperty)
- On Error GoTo NoImage
- If AsyncProp.PropertyName = "PictureFromURL" Then
- Set Picture1.Picture = AsyncProp.Value
- Debug.Print "Download complete"
- ArrangeControl
- UserControl_Paint
- RaiseEvent DownloadCompleted
- End If
- Exit Sub
-
- NoImage:
- RaiseEvent DownloadFailed
- Debug.Print "Download failed"
- End Sub
-
- Private Sub UserControl_Initialize()
- ArrangeControl
- UserControl_Paint
- End Sub
-
- Private Sub UserControl_Paint()
- On Error Resume Next
- Picture2.PaintPicture Picture1.Picture, 0, 0, _
- Picture2.Width, Picture2.Height, _
- HScroll1.Value, VScroll1.Value, _
- Picture2.Width, Picture2.Height
- End Sub
-
- Private Sub ArrangeControl()
- Picture2.Top = 0
- Picture2.Left = 0
- Picture2.Width = UserControl.Width - VScroll1.Width
- Picture2.Height = UserControl.Height - HScroll1.Height
- HScroll1.Left = 0
- HScroll1.Width = UserControl.Width - VScroll1.Width
- HScroll1.Top = UserControl.Height - HScroll1.Height
- VScroll1.Left = UserControl.Width - VScroll1.Width
- VScroll1.Top = 0
- VScroll1.Height = UserControl.Height - HScroll1.Height
- SetScrollbars
- End Sub
-
- Public Sub ScrollTo(X As Integer, Y As Integer)
- If HScroll1.Enabled Then
- If X > HScroll1.Max Then X = HScroll1.Max
- HScroll1.Value = X
- End If
- If VScroll1.Enabled Then
- If Y > VScroll1.Max Then Y = VScroll1.Max
- VScroll1.Value = Y
- End If
- End Sub
-
- 'Initialize Properties for User Control
- Private Sub UserControl_InitProperties()
- m_PictureWidth = m_def_PictureWidth
- m_PictureHeight = m_def_PictureHeight
- m_PictureFromURL = m_def_PictureFromURL
- End Sub
-
- 'Load property values from storage
- Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
- m_PictureWidth = PropBag.ReadProperty("PictureWidth", m_def_PictureWidth)
- m_PictureHeight = PropBag.ReadProperty("PictureHeight", m_def_PictureHeight)
- Set Picture = PropBag.ReadProperty("Picture", Nothing)
- Picture2.BorderStyle = PropBag.ReadProperty("BorderStyle", 0)
- UserControl.Enabled = PropBag.ReadProperty("Enabled", True)
- m_PictureFromURL = PropBag.ReadProperty("PictureFromURL", m_def_PictureFromURL)
- HScroll1.Value = PropBag.ReadProperty("XPosition", 0)
- VScroll1.Value = PropBag.ReadProperty("YPosition", 0)
- End Sub
-
- 'Write property values to storage
- Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
- Call PropBag.WriteProperty("PictureWidth", m_PictureWidth, m_def_PictureWidth)
- Call PropBag.WriteProperty("PictureHeight", m_PictureHeight, m_def_PictureHeight)
- Call PropBag.WriteProperty("Picture", Picture, Nothing)
- Call PropBag.WriteProperty("BorderStyle", Picture2.BorderStyle, 0)
- Call PropBag.WriteProperty("Enabled", UserControl.Enabled, True)
- Call PropBag.WriteProperty("PictureFromURL", m_PictureFromURL, m_def_PictureFromURL)
- Call PropBag.WriteProperty("XPosition", HScroll1.Value, 0)
- Call PropBag.WriteProperty("YPosition", VScroll1.Value, 0)
- End Sub
-
- Public Property Get PictureWidth() As Integer
- PictureWidth = m_PictureWidth
- End Property
-
- Public Property Get PictureHeight() As Integer
- PictureHeight = m_PictureHeight
- End Property
-
- Public Property Get VisibleWidth() As Integer
- VisibleWidth = (UserControl.Width - VScroll1.Width) / Screen.TwipsPerPixelX
- End Property
-
- Public Property Get VisibleHeight() As Integer
- VisibleHeight = (UserControl.Height - HScroll1.Height) / Screen.TwipsPerPixelY
- End Property
- b
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=Picture2,Picture2,-1,BorderStyle
- Public Property Get BorderStyle() As Integer
- Attribute BorderStyle.VB_Description = "Returns/sets the border style for an object."
- BorderStyle = Picture2.BorderStyle
- End Property
-
- Public Property Let BorderStyle(ByVal New_BorderStyle As Integer)
- Picture2.BorderStyle() = New_BorderStyle
- PropertyChanged "BorderStyle"
- End Property
-
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=UserControl,UserControl,-1,Refresh
- Public Sub Refresh()
- Attribute Refresh.VB_Description = "Forces a complete repaint of a object."
- UserControl.Refresh
- End Sub
-
- Private Sub picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
- RaiseEvent MouseUp(Button, Shift, X, Y)
- End Sub
-
- Public Property Get Picture() As Picture
- Set Picture = Picture1.Picture
- End Property
-
- Public Property Set Picture(ByVal New_Picture As Picture)
- Set Picture1.Picture = New_Picture
- ArrangeControl
- UserControl_Paint
- End Property
-
- Private Sub SetScrollbars()
- m_PictureWidth = ScaleX(Picture1.Picture.Width, 8, vbPixels)
- m_PictureHeight = ScaleY(Picture1.Picture.Height, 8, vbPixels)
- HScroll1.Enabled = True
- VScroll1.Enabled = True
- HScroll1.Visible = True
- VScroll1.Visible = True
- ' should we disable horizontal scrollbar?
- If m_PictureWidth <= Picture2.ScaleWidth Then
- Picture2.Width = m_PictureWidth * Screen.TwipsPerPixelX
- HScroll1.Enabled = False
- HScroll1.Width = Picture2.Width
- HScroll1.Visible = False
- VScroll1.Left = Picture2.Left + Picture2.Width
- End If
- ' should we disable vertical scrollbar?
- If m_PictureHeight <= Picture2.ScaleHeight Then
- Picture2.Height = m_PictureHeight * Screen.TwipsPerPixelY
- VScroll1.Enabled = False
- VScroll1.Height = Picture2.Height
- VScroll1.Visible = False
- HScroll1.Top = Picture2.Top + Picture2.Height
- End If
- HScroll1.Min = 0
- HScroll1.Max = m_PictureWidth - Picture2.ScaleWidth
- HScroll1.LargeChange = 10
- HScroll1.SmallChange = 1
- VScroll1.Min = 0
- VScroll1.Max = m_PictureHeight - Picture2.ScaleHeight
- VScroll1.LargeChange = 10
- VScroll1.SmallChange = 1
- End Sub
-
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=UserControl,UserControl,-1,Enabled
- Public Property Get Enabled() As Boolean
- Attribute Enabled.VB_Description = "Returns/sets a value that determines whether an object can respond to user-generated events."
- Enabled = UserControl.Enabled
- End Property
-
- Public Property Let Enabled(ByVal New_Enabled As Boolean)
- UserControl.Enabled() = New_Enabled
- PropertyChanged "Enabled"
- End Property
-
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MemberInfo=13,0,0,
- Public Property Get PictureFromURL() As String
- PictureFromURL = m_PictureFromURL
- End Property
-
- Public Property Let PictureFromURL(ByVal newValue As String)
- m_PictureFromURL = newValue
- If Ambient.UserMode And newValue <> "" Then
- AsyncRead newValue, vbAsyncTypePicture, "PictureFromURL"
- End If
- PropertyChanged "PictureFromURL"
- End Property
-
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=HScroll1,HScroll1,-1,Value
- Public Property Get XPosition() As Integer
- Attribute XPosition.VB_Description = "Returns/sets the value of an object."
- XPosition = HScroll1.Value
- End Property
-
- Public Property Let XPosition(ByVal New_XPosition As Integer)
- HScroll1.Value() = New_XPosition
- PropertyChanged "XPosition"
- End Property
-
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=VScroll1,VScroll1,-1,Value
- Public Property Get YPosition() As Integer
- Attribute YPosition.VB_Description = "Returns/sets the value of an object."
- YPosition = VScroll1.Value
- End Property
-
- Public Property Let YPosition(ByVal New_YPosition As Integer)
- VScroll1.Value() = New_YPosition
- PropertyChanged "YPosition"
- End Property
-
- Private Sub HScroll1_Scroll()
- UserControl_Paint
- RaiseEvent ScrollX(HScroll1.Value)
- End Sub
-
- Private Sub VScroll1_Scroll()
- UserControl_Paint
- RaiseEvent ScrollY(VScroll1.Value)
- End Sub
-
- Private Sub HScroll1_Change()
- UserControl_Paint
- RaiseEvent ChangeX(HScroll1.Value)
- End Sub
-
- Private Sub VScroll1_Change()
- UserControl_Paint
- RaiseEvent ChangeY(HScroll1.Value)
- End Sub
-
- Private Sub Picture2_Click()
- RaiseEvent Click
- End Sub
-
- Private Sub Picture2_DblClick()
- RaiseEvent DblClick
- End Sub
-
- Private Sub Picture2_KeyDown(KeyCode As Integer, Shift As Integer)
- RaiseEvent KeyDown(KeyCode, Shift)
- End Sub
-
- Private Sub Picture2_KeyPress(KeyAscii As Integer)
- RaiseEvent KeyPress(KeyAscii)
- End Sub
-
- Private Sub Picture2_KeyUp(KeyCode As Integer, Shift As Integer)
- RaiseEvent KeyUp(KeyCode, Shift)
- End Sub
-
- Private Sub Picture2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
- RaiseEvent MouseDown(Button, Shift, X, Y)
- End Sub
-
- Private Sub Picture2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
- RaiseEvent MouseMove(Button, Shift, X, Y)
- End Sub
-
-