home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 5 / MasteringVisualBasic5.iso / olympus / ik32_15t / vb4.shr / pan.Frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-08-07  |  4.2 KB  |  122 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Pan"
  5.    ClientHeight    =   3330
  6.    ClientLeft      =   2100
  7.    ClientTop       =   2100
  8.    ClientWidth     =   3615
  9.    Height          =   4110
  10.    Left            =   2040
  11.    LinkTopic       =   "Form1"
  12.    LockControls    =   -1  'True
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   3330
  16.    ScaleWidth      =   3615
  17.    Top             =   1380
  18.    Width           =   3735
  19.    Begin VB.CheckBox Check1 
  20.       Caption         =   "Enable Scroll Bars"
  21.       Height          =   255
  22.       Left            =   120
  23.       TabIndex        =   0
  24.       Top             =   3000
  25.       Width           =   1695
  26.    End
  27.    Begin ik32Lib.Picbuf Picbuf1 
  28.       Height          =   2895
  29.       Left            =   120
  30.       TabIndex        =   1
  31.       Top             =   0
  32.       Width           =   3375
  33.       _Version        =   65536
  34.       _ExtentX        =   5953
  35.       _ExtentY        =   5106
  36.       _StockProps     =   253
  37.    End
  38.    Begin MSComDlg.CommonDialog CommonDialog1 
  39.       Left            =   2280
  40.       Top             =   2880
  41.       _Version        =   65536
  42.       _ExtentX        =   847
  43.       _ExtentY        =   847
  44.       _StockProps     =   0
  45.    End
  46.    Begin VB.Menu mnuFile 
  47.       Caption         =   "&File"
  48.       Begin VB.Menu mnuLoad 
  49.          Caption         =   "&Load Image..."
  50.       End
  51.       Begin VB.Menu mnuSpacer 
  52.          Caption         =   "-"
  53.       End
  54.       Begin VB.Menu mnuExit 
  55.          Caption         =   "E&xit"
  56.          Shortcut        =   ^X
  57.       End
  58.    End
  59. Attribute VB_Name = "Form1"
  60. Attribute VB_Creatable = False
  61. Attribute VB_Exposed = False
  62. Dim intStartX, intStartY, intPixelX, intPixelY, intImageStartX, intImageStartY As Integer
  63. 'starts for initial cursor position on picbuf in pixels
  64. 'pixels for end cursor position on picbuf
  65. 'imagestarts for translation from screen to image pixels
  66. 'Description: This code determines whether or not
  67. 'the scroll bars can be used.
  68. Private Sub Check1_Click()
  69. If Check1.Value = 0 Then
  70.     Picbuf1.ScrollBars = 0
  71.     Picbuf1.MousePointer = 15
  72.     Picbuf1.ScrollBars = 3
  73.     Picbuf1.MousePointer = 0
  74. End If
  75. End Sub
  76. 'Description: This code exits then program.
  77. Private Sub mnuExit_Click()
  78.     ExitProgram
  79. End Sub
  80. 'Description: This code loads an image into the
  81. 'picbuf, and sets the mouse pointer.
  82. Private Sub Form_Load()
  83.     InitPicbuf Picbuf1, False, "marybeth.tif"
  84.     Picbuf1.MousePointer = 15
  85. End Sub
  86. 'Description: This code loads an image into the
  87. 'picbuf using the common dialog control.
  88. Private Sub mnuLoad_Click()
  89.     DoEvents ' for safety
  90.     LoadImage Picbuf1, commondialog1
  91. End Sub
  92. 'Description: This code moves the image according
  93. 'to the mouse movement while the mouse is clicked.
  94. Private Sub Picbuf1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  95.     If Button = 1 Then
  96.         intStartX = x / Screen.TwipsPerPixelX
  97.         intStartY = y / Screen.TwipsPerPixelY
  98.         'translate twips from initial mouse position to pixels
  99.         intImageStartX = Picbuf1.ScreenToImageX(intStartX)
  100.         intImageStartY = Picbuf1.ScreenToImageY(intStartY)
  101.         'translate pixels on screen to pixels on image
  102.     End If
  103. End Sub
  104. 'Description: This code works with mouse down to
  105. 'move the image in the picbuf.
  106. Private Sub Picbuf1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  107.     On Error GoTo ErrorHandler
  108.     If Button = 1 Then
  109.         intPixelX = x / Screen.TwipsPerPixelX
  110.         intPixelY = y / Screen.TwipsPerPixelY
  111.         'translate mouse coordinates in twips on picbuf to pixels
  112.         If x > 0 And y > 0 And x < Picbuf1.Width And y < Picbuf1.Height And x < (Screen.TwipsPerPixelX * Picbuf1.Xresolution) And y < (Screen.TwipsPerPixelY * Picbuf1.Yresolution) Then
  113.             'if the cursor is in bounds
  114.             Picbuf1.RePos intImageStartX, intImageStartY, intPixelX, intPixelY
  115.             'resposition imageposition to cursor position
  116.         End If
  117.     End If
  118.     Exit Sub
  119. ErrorHandler:
  120.     MsgBox Err.Description
  121. End Sub
  122.