home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 4.00 Begin VB.Form Form1 BorderStyle = 1 'Fixed Single Caption = "Pan" ClientHeight = 3330 ClientLeft = 2100 ClientTop = 2100 ClientWidth = 3615 Height = 4110 Left = 2040 LinkTopic = "Form1" LockControls = -1 'True MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 3330 ScaleWidth = 3615 Top = 1380 Width = 3735 Begin VB.CheckBox Check1 Caption = "Enable Scroll Bars" Height = 255 Left = 120 TabIndex = 0 Top = 3000 Width = 1695 End Begin ik32Lib.Picbuf Picbuf1 Height = 2895 Left = 120 TabIndex = 1 Top = 0 Width = 3375 _Version = 65536 _ExtentX = 5953 _ExtentY = 5106 _StockProps = 253 End Begin MSComDlg.CommonDialog CommonDialog1 Left = 2280 Top = 2880 _Version = 65536 _ExtentX = 847 _ExtentY = 847 _StockProps = 0 End Begin VB.Menu mnuFile Caption = "&File" Begin VB.Menu mnuLoad Caption = "&Load Image..." End Begin VB.Menu mnuSpacer Caption = "-" End Begin VB.Menu mnuExit Caption = "E&xit" Shortcut = ^X End End Attribute VB_Name = "Form1" Attribute VB_Creatable = False Attribute VB_Exposed = False Dim intStartX, intStartY, intPixelX, intPixelY, intImageStartX, intImageStartY As Integer 'starts for initial cursor position on picbuf in pixels 'pixels for end cursor position on picbuf 'imagestarts for translation from screen to image pixels 'Description: This code determines whether or not 'the scroll bars can be used. Private Sub Check1_Click() If Check1.Value = 0 Then Picbuf1.ScrollBars = 0 Picbuf1.MousePointer = 15 Picbuf1.ScrollBars = 3 Picbuf1.MousePointer = 0 End If End Sub 'Description: This code exits then program. Private Sub mnuExit_Click() ExitProgram End Sub 'Description: This code loads an image into the 'picbuf, and sets the mouse pointer. Private Sub Form_Load() InitPicbuf Picbuf1, False, "marybeth.tif" Picbuf1.MousePointer = 15 End Sub 'Description: This code loads an image into the 'picbuf using the common dialog control. Private Sub mnuLoad_Click() DoEvents ' for safety LoadImage Picbuf1, commondialog1 End Sub 'Description: This code moves the image according 'to the mouse movement while the mouse is clicked. Private Sub Picbuf1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) If Button = 1 Then intStartX = x / Screen.TwipsPerPixelX intStartY = y / Screen.TwipsPerPixelY 'translate twips from initial mouse position to pixels intImageStartX = Picbuf1.ScreenToImageX(intStartX) intImageStartY = Picbuf1.ScreenToImageY(intStartY) 'translate pixels on screen to pixels on image End If End Sub 'Description: This code works with mouse down to 'move the image in the picbuf. Private Sub Picbuf1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) On Error GoTo ErrorHandler If Button = 1 Then intPixelX = x / Screen.TwipsPerPixelX intPixelY = y / Screen.TwipsPerPixelY 'translate mouse coordinates in twips on picbuf to pixels 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 'if the cursor is in bounds Picbuf1.RePos intImageStartX, intImageStartY, intPixelX, intPixelY 'resposition imageposition to cursor position End If End If Exit Sub ErrorHandler: MsgBox Err.Description End Sub