home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 2.00 Begin Form frmMousScrol AutoRedraw = -1 'True BackColor = &H00C0C0C0& Caption = "Mouse Scrolling" ClientHeight = 4740 ClientLeft = 2445 ClientTop = 1545 ClientWidth = 4140 Height = 5145 Icon = MOUSCROL.FRX:0000 Left = 2385 LinkTopic = "Form1" ScaleHeight = 4740 ScaleWidth = 4140 Top = 1200 Width = 4260 Begin CommandButton cmdExit Caption = "E&xit" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 400 Left = 1620 TabIndex = 1 Top = 4140 Width = 1000 End Begin PictureBox pic BorderStyle = 0 'None Height = 3060 Left = 500 ScaleHeight = 3060 ScaleWidth = 3135 TabIndex = 0 Top = 500 Width = 3135 Begin Image img Height = 4305 Left = 0 Picture = MOUSCROL.FRX:0302 Top = 0 Width = 6600 End End Option Explicit Dim MouseDownX, MouseDownY As Integer Dim NewLeft, NewTop As Integer Dim VScrollMax, HScrollMax As Integer Dim VScrollMin, HScrollMin As Integer ' Shift parameter masks Const SHIFT_MASK = 1 Const CTRL_MASK = 2 Const ALT_MASK = 4 ' Button parameter masks Const LEFT_BUTTON = 1 Const RIGHT_BUTTON = 2 Const MIDDLE_BUTTON = 4 'Colors Const G_BLACK = 0 Const G_BLUE = 1 Const G_GREEN = 2 Const G_CYAN = 3 Const G_RED = 4 Const G_MAGENTA = 5 Const G_BROWN = 6 Const G_LIGHT_GRAY = 7 Const G_DARK_GRAY = 8 Const G_LIGHT_BLUE = 9 Const G_LIGHT_GREEN = 10 Const G_LIGHT_CYAN = 11 Const G_LIGHT_RED = 12 Const G_LIGHT_MAGENTA = 13 Const G_YELLOW = 14 Const G_WHITE = 15 Const G_AUTOBW = 16 Sub cmdExit_Click () End End Sub Sub DrawFrameOn (TopLeftControl As Control, BottomRightControl As Control, Style As String, FrameOffset As Integer, Color As Integer, TopLeftEdges As Integer, BottomRightEdges As Integer) Dim SaveDrawWidth, SaveFillStyle, SaveScaleMode Dim Offset, TWIPS As Integer Dim xx, yy As Integer Dim x1, y1, x2, y2 As Integer Dim FrameLeft, FrameTop, FrameWidth, FrameHeight SaveDrawWidth = DrawWidth SaveFillStyle = FillStyle SaveScaleMode = ScaleMode DrawWidth = 1 FillStyle = 1 ScaleMode = 1 TWIPS = screen.TwipsPerPixelX Offset = FrameOffset * TWIPS FrameLeft = TopLeftControl.Left FrameTop = TopLeftControl.Top FrameWidth = BottomRightControl.Left + BottomRightControl.Width FrameHeight = BottomRightControl.Top + BottomRightControl.Height ' Draw a colored box the same size as the largest Frame. x1 = FrameLeft - Offset y1 = FrameTop - Offset x2 = FrameWidth + Offset - TWIPS y2 = FrameHeight + Offset - TWIPS Line (x1, y1)-(x2, y2), QBColor(Color), BF ' Raised or inset shading If UCase$(Left$(Style, 1)) = "R" Then xx = TopLeftEdges yy = BottomRightEdges Else xx = BottomRightEdges yy = TopLeftEdges End If ' Bottom-left to Top-left line x1 = FrameLeft - Offset y1 = FrameHeight + Offset - TWIPS x2 = FrameLeft - Offset y2 = FrameTop - Offset - TWIPS Line (x1, y1)-(x2, y2), QBColor(xx) ' Top-left to Top-Right line x1 = FrameLeft - Offset y1 = FrameTop - Offset x2 = FrameWidth + Offset y2 = FrameTop - Offset Line (x1, y1)-(x2, y2), QBColor(xx) ' Top-Right to Bottom-Right line x1 = FrameWidth + Offset - TWIPS y1 = FrameTop - Offset x2 = FrameWidth + Offset - TWIPS y2 = FrameHeight + Offset Line (x1, y1)-(x2, y2), QBColor(yy) ' Bottom-Right to Bottom-Left line x1 = FrameWidth + Offset - TWIPS y1 = FrameHeight + Offset - TWIPS x2 = FrameLeft - Offset - TWIPS y2 = FrameHeight + Offset - TWIPS Line (x1, y1)-(x2, y2), QBColor(yy) DrawWidth = SaveDrawWidth FillStyle = SaveFillStyle ScaleMode = SaveScaleMode End Sub Sub Form_Load () Show HScrollMax = -(img.Width - pic.Width) VScrollMax = -(img.Height - pic.Height) HScrollMin = 0 VScrollMin = 0 ' Center the image inside the picture box on program start img.Left = HScrollMax / 2 img.Top = VScrollMax / 2 ' Color Constants to be used in DrawFrameOn 'G_BLACK G_WHITE 'G_BLUE G_LIGHT_BLUE 'G_GREEN G_LIGHT_GREEN 'G_CYAN G_LIGHT_CYAN 'G_RED G_LIGHT_RED 'G_MAGENTA G_LIGHT_MAGENTA 'G_BROWN G_YELLOW 'G_LIGHT_GRAY G_DARK_GRAY ' DrawFrameOn TopLeftControl, BottomRightControl, Style, FrameOffset ' Box Color, Top and Left Lines Color, Bottom and Right Lines Color DrawFrameOn pic, pic, "Raised", 24, G_RED, G_BLACK, G_BLACK DrawFrameOn pic, pic, "Raised", 23, G_RED, G_WHITE, G_DARK_GRAY DrawFrameOn pic, pic, "Raised", 22, G_RED, G_WHITE, G_DARK_GRAY DrawFrameOn pic, pic, "Raised", 21, G_RED, G_BLACK, G_BLACK DrawFrameOn pic, pic, "Raised", 11, G_LIGHT_GRAY, G_DARK_GRAY, G_WHITE DrawFrameOn pic, pic, "Raised", 10, G_YELLOW, G_BLACK, G_BLACK DrawFrameOn pic, pic, "Raised", 7, G_LIGHT_GRAY, G_BLACK, G_BLACK DrawFrameOn pic, pic, "Raised", 6, G_GREEN, G_WHITE, G_DARK_GRAY DrawFrameOn pic, pic, "Raised", 1, G_LIGHT_GRAY, G_BLACK, G_WHITE End Sub Sub img_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single) Select Case Button Case RIGHT_BUTTON MouseDownX = X MouseDownY = Y End Select End Sub Sub img_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = RIGHT_BUTTON Then NewLeft = img.Left - (MouseDownX - X) If NewLeft > HScrollMax And NewLeft < 0 Then img.Left = NewLeft End If NewTop = img.Top - (MouseDownY - Y) If NewTop > VScrollMax And NewTop < 0 Then img.Top = NewTop End If End If End Sub