home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Programmer'…arterly (Limited Edition)
/
Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso
/
code
/
ch13code
/
zoom.frm
< prev
next >
Wrap
Text File
|
1995-08-12
|
4KB
|
137 lines
VERSION 4.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3228
ClientLeft = 1332
ClientTop = 2076
ClientWidth = 4572
Height = 3780
Left = 1284
LinkTopic = "Form1"
ScaleHeight = 3228
ScaleWidth = 4572
Top = 1572
Width = 4668
Begin VB.VScrollBar VScroll1
Height = 3252
Left = 4320
TabIndex = 0
Top = 0
Width = 252
End
Begin VB.OLE OLE1
Height = 3252
Left = 0
SizeMode = 3 'Zoom
TabIndex = 1
Top = 0
Width = 4332
End
Begin VB.Menu mnuFile
Caption = "&File"
NegotiatePosition= 1 'Left
Begin VB.Menu mnuNew
Caption = "&New Object"
End
Begin VB.Menu mnuClose
Caption = "&Close Object"
End
Begin VB.Menu mnuSep1
Caption = "-"
End
Begin VB.Menu mnuExit
Caption = "E&xit"
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
Dim msHeightRatio As Single, msWidthRatio As Single
Dim msIdealHeight As Single, msIdealWidth As Single
Dim msActualHeight As Single, msActualWidth As Single
Dim mResized As Boolean
Private Sub Form_Load()
' Keep control the same size.
OLE1.SizeMode = vbOLESizeZoom
' Display the Insert Object dialog on startup.
OLE1.InsertObjDlg
End Sub
Private Sub Form_Resize()
' Move scroll bar
AdjustScrollBars Me
' Resize OLE object.
OLE1.Height = Me.Height
' Allow resize action
mResized = False
OLE1.Width = Me.Width - VScroll1.Width
End Sub
Private Sub mnuClose_Click()
OLE1.Close
End Sub
Private Sub mnuExit_Click()
End
End Sub
Private Sub mnuNew_Click()
mResized = False
OLE1.InsertObjDlg
End Sub
Private Sub OLE1_Resize(HeightNew As Single, WidthNew As Single)
' Get the actual height and width of the object
' from the application.
If Not mResized Then
' Get the control size.
msActualHeight = OLE1.Height
msActualWidth = OLE1.Width
' Temporarily switch SizeMode to get
' the actual size.
OLE1.SizeMode = vbOLESizeAutoSize
' Get the actual height and width of the object.
msIdealHeight = OLE1.Height
msIdealWidth = OLE1.Width
' Reset size mode and height/width
OLE1.SizeMode = vbOLESizeZoom
OLE1.Height = msActualHeight
OLE1.Width = msActualWidth
' Choose which ratio is greater.
msHeightRatio = OLE1.Height / msIdealHeight
msWidthRatio = OLE1.Width / msIdealWidth
' Use the greater ratio for the scroll bar zoom.
If msHeightRatio >= msHeightRatio Then
' Set the maxium value (400%)
VScroll1.MAX = msWidthRatio * 4
Else
' Set the maxium value (400%)
VScroll1.MAX = msWidthRatio * 4
End If
' Set the initial scrollbar position.
VScroll1.MIN = 1
VScroll1.VALUE = 1
' Set module-level variable.
mResized = True
End If
End Sub
' Zoom OLE control.
Private Sub VScroll1_Change()
' Scale Height and Width.
OLE1.Height = msActualHeight * VScroll1.VALUE
OLE1.Width = msActualWidth * VScroll1.VALUE
End Sub