home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Basic / Samples / BMPVWS / BMPVWS.ZIP / BMPVIEW.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-09-21  |  7.5 KB  |  242 lines

  1. VERSION 2.00
  2. Begin Form BMPView 
  3.    Caption         =   "Bitmap Viewer 2.0"
  4.    ClientHeight    =   600
  5.    ClientLeft      =   3696
  6.    ClientTop       =   2880
  7.    ClientWidth     =   2040
  8.    ClipControls    =   0   'False
  9.    ControlBox      =   0   'False
  10.    FontBold        =   0   'False
  11.    FontItalic      =   0   'False
  12.    FontName        =   "MS Sans Serif"
  13.    FontSize        =   7.8
  14.    FontStrikethru  =   0   'False
  15.    FontTransparent =   0   'False
  16.    FontUnderline   =   0   'False
  17.    Height          =   972
  18.    Icon            =   BMPVIEW.FRX:0000
  19.    KeyPreview      =   -1  'True
  20.    Left            =   3672
  21.    LinkTopic       =   "Form1"
  22.    MaxButton       =   0   'False
  23.    MinButton       =   0   'False
  24.    ScaleHeight     =   600
  25.    ScaleWidth      =   2040
  26.    Top             =   2532
  27.    Width           =   2088
  28.    Begin PictureBox Picture1 
  29.       AutoSize        =   -1  'True
  30.       ClipControls    =   0   'False
  31.       Enabled         =   0   'False
  32.       Height          =   36
  33.       Left            =   0
  34.       ScaleHeight     =   12
  35.       ScaleWidth      =   24
  36.       TabIndex        =   0
  37.       Top             =   0
  38.       Visible         =   0   'False
  39.       Width           =   48
  40.    End
  41.    Begin Image Image1 
  42.       Height          =   612
  43.       Left            =   0
  44.       Stretch         =   -1  'True
  45.       Top             =   0
  46.       Width           =   2052
  47.    End
  48. Option Explicit
  49. Sub Form_KeyDown (Keycode As Integer, Shift As Integer)
  50. Dim ShiftDown, AltDown, CtrlDown, Txt, F12, F4
  51.     Const KEY_F4 = &H73
  52.     Const KEY_F12 = &H7B
  53.     Const SHIFT_MASK = 1
  54.     Const CTRL_MASK = 2
  55.     Const ALT_MASK = 4
  56.     ShiftDown = (Shift And SHIFT_MASK) > 0
  57.     AltDown = (Shift And ALT_MASK) > 0
  58.     CtrlDown = (Shift And CTRL_MASK) > 0
  59.     F12 = (Keycode = KEY_F12)
  60.     F4 = (Keycode = KEY_F4)
  61.     If (ShiftDown And F12) Then
  62.         WindowState = MINIMIZED
  63.         'Picture = Image1.Picture
  64.         'Form_Resize
  65.     End If
  66.     If (CtrlDown And F12) Then
  67.         WindowState = normal
  68.     End If
  69.     If (AltDown And F12) Then
  70.         WindowState = MAXIMIZED
  71.     End If
  72.     If (AltDown And F4) Then
  73.         Form_Unload 0
  74.     End If
  75. End Sub
  76. Sub Form_Load ()
  77.     ReadINI
  78.     Picture1.Top = 0
  79.     Picture1.Left = 0
  80.     Image1.Top = 0
  81.     Image1.Left = 0
  82.     Image1.Width = ScaleWidth
  83.     Image1.Height = ScaleHeight
  84.     Load OpenBitMap
  85.     Load BmpABout
  86.     If (BMPFileName <> "") Then
  87.         ImageLoad
  88.         Top = ViewTop
  89.         Left = ViewLeft
  90.         Height = ViewHeight
  91.         ViewAllowResize = True
  92.         Width = ViewWidth
  93.     Else
  94.         NotTopMost
  95.         OpenBitMap.Show 1
  96.     End If
  97.     If (OpenBitMap.OnTop = True) Then
  98.         Topmost
  99.     Else
  100.         NotTopMost
  101.     End If
  102. End Sub
  103. Sub Form_Resize ()
  104.     If (ScaleWidth > 1) And (ScaleHeight > 1) And (ViewAllowResize) Then
  105.         If (OpenBitMap.Aspect = True) And (WindowState = normal) Then
  106.             Width = (ScaleHeight * ViewAspect) + ViewBorder
  107.         End If
  108.         Image1.Width = ScaleWidth
  109.         Image1.Height = ScaleHeight
  110.     End If
  111. End Sub
  112. Sub Form_Unload (Cancel As Integer)
  113.     BMPView.Image1.Picture = LoadPicture("")
  114.     Unload OpenBitMap
  115.     Unload BmpABout
  116.     Unload BMPView
  117.     End
  118. End Sub
  119. Sub Image1_DblClick ()
  120.     NotTopMost
  121.     OpenBitMap.Show 1
  122. End Sub
  123. Sub Image1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  124.         
  125.     If (Button And 2) Then
  126.         ViewAllowResize = False
  127.         If (Caption = "") Then
  128.             ViewCaption = True
  129.             Caption = "Bitmap Viewer"
  130.         Else
  131.             ViewCaption = False
  132.             Caption = ""
  133.         End If
  134.         ViewAllowResize = True
  135.     Else
  136.         PixStartX = (BMPView.Left) / TPRatio
  137.         PixStartY = (BMPView.Top) / TPRatio
  138.         PixOffsetX = Int(X / TPRatio)
  139.         PixOffsetY = Int(Y / TPRatio)
  140.         OkToMove = True
  141.         GhostForm PixStartX, PixStartY, PixStartX + (BMPView.Width / TPRatio), PixStartY + (BMPView.Height / TPRatio)
  142.     End If
  143. End Sub
  144. Sub Image1_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
  145.     If Button = 1 And OkToMove = True Then
  146.         OkToMove = False
  147.         PixX = Int(X / TPRatio) - PixOffsetX
  148.         PixY = Int(Y / TPRatio) - PixOffsetY
  149.         GhostForm PixStartX, PixStartY, PixStartX + (BMPView.Width / TPRatio), PixStartY + (BMPView.Height / TPRatio)
  150.         GhostForm PixStartX + PixX, PixStartY + PixY, PixStartX + PixX + (BMPView.Width / TPRatio), PixStartY + PixY + (BMPView.Height / TPRatio)
  151.         PixOffsetX = Int(X / TPRatio)
  152.         PixOffsetY = Int(Y / TPRatio)
  153.         PixStartX = PixStartX + PixX
  154.         PixStartY = PixStartY + PixY
  155.         OkToMove = True
  156.     End If
  157. End Sub
  158. Sub Image1_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  159.     If Button = 1 And OkToMove = True Then
  160.         GhostForm PixStartX, PixStartY, PixStartX + (BMPView.Width / TPRatio), PixStartY + (BMPView.Height / TPRatio)
  161.         BMPView.Move (PixStartX) * TPRatio, (PixStartY) * TPRatio
  162.     End If
  163. End Sub
  164. Sub ReadINI ()
  165.     Dim INISection As String
  166.     Dim NoTitle As String
  167.     Dim SaveSet As String
  168.     Dim Always As String
  169.     Dim AspectRatio As String
  170.     Dim INIChan As Integer
  171.     Dim Tmp As Integer
  172.     Dim LIN As String
  173.     On Error GoTo NOINI
  174.     INIChan% = 1
  175.     BMPFileName = ""
  176.     ViewCaption = True
  177.     OpenBitMap.SaveSettings = False
  178.     OpenBitMap.OnTop = False
  179.     OpenBitMap.Aspect = False
  180.     Open "C:\WINDOWS\BMPVIEW.INI" For Input As #INIChan%
  181.     While (EOF(INIChan%) = 0)
  182.         
  183.         Line Input #INIChan%, LIN$
  184.         If Trim$(LIN$) <> "" Then
  185.             If (Left$(LIN$, 1) = "[") Then
  186.                 Tmp% = InStr(LIN$, "]")
  187.                 If (Tmp% > 2) Then
  188.                     INISection = Mid$(LIN$, 2, Tmp% - 2)
  189.                 Else
  190.                     INISection = Mid$(LIN$, 2)
  191.                 End If
  192.             Else
  193.                 Select Case INISection
  194.                     Case "Current Bitmap"
  195.                         BMPFileName = LIN$
  196.                     Case "Top"
  197.                         ViewTop = Val(LIN$)
  198.                     Case "Left"
  199.                         ViewLeft = Val(LIN$)
  200.                     Case "Height"
  201.                         ViewHeight = Val(LIN$)
  202.                     Case "Width"
  203.                         ViewWidth = Val(LIN$)
  204.                     Case "No Title"
  205.                         NoTitle = LIN$
  206.                     Case "Save Settings"
  207.                         SaveSet = LIN$
  208.                     Case "Always on top"
  209.                         Always = LIN$
  210.                     Case "Aspect Ratio"
  211.                         AspectRatio = LIN$
  212.                     Case Else
  213.                 End Select
  214.             End If
  215.         End If
  216.     Wend
  217.     Close #INIChan%
  218.     If (NoTitle = "Yes") Then
  219.         Caption = ""
  220.         ViewCaption = False
  221.     End If
  222.     If (SaveSet = "Yes") Then
  223.         OpenBitMap.SaveSettings = True
  224.     End If
  225.     If (Always = "Yes") Then
  226.         OpenBitMap.OnTop = True
  227.     End If
  228.     If (AspectRatio = "Yes") Then
  229.         OpenBitMap.Aspect = True
  230.     End If
  231. Exit Sub
  232. NOINI:
  233.         If (Err = 53) Then
  234.             Exit Sub
  235.         Else
  236.             MsgBox "Fatal error" & Str$(Err) & " in BMPView"
  237.         End If
  238.         
  239.         Form_Unload 0
  240.         End
  241. End Sub
  242.