home *** CD-ROM | disk | FTP | other *** search
/ Computer Tool Software / soft.iso / Multimed / WINFAST / WFST230 / VB-V400 / FORM1.FRM (.txt) next >
Encoding:
Visual Basic Form  |  1996-06-03  |  8.4 KB  |  258 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H80000005&
  5.    Caption         =   "Form1"
  6.    ClientHeight    =   2745
  7.    ClientLeft      =   1965
  8.    ClientTop       =   2040
  9.    ClientWidth     =   4500
  10.    BeginProperty Font 
  11.       name            =   "MS Sans Serif"
  12.       charset         =   1
  13.       weight          =   700
  14.       size            =   8.25
  15.       underline       =   0   'False
  16.       italic          =   0   'False
  17.       strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H80000008&
  20.    Height          =   3435
  21.    Icon            =   "FORM1.frx":0000
  22.    Left            =   1905
  23.    LinkTopic       =   "Form1"
  24.    ScaleHeight     =   183
  25.    ScaleMode       =   3  'Pixel
  26.    ScaleWidth      =   300
  27.    Top             =   1410
  28.    Width           =   4620
  29.    Begin VB.Timer Timer1 
  30.       Interval        =   500
  31.       Left            =   960
  32.       Top             =   0
  33.    End
  34.    Begin MSComDlg.CommonDialog CMDialog1 
  35.       Left            =   240
  36.       Top             =   0
  37.       _version        =   65536
  38.       _extentx        =   847
  39.       _extenty        =   847
  40.       _stockprops     =   0
  41.    End
  42.    Begin VB.Menu mLoad 
  43.       Caption         =   "&Load"
  44.    End
  45.    Begin VB.Menu mSave 
  46.       Caption         =   "&Save"
  47.    End
  48.    Begin VB.Menu mFreeze 
  49.       Caption         =   "&Freeze"
  50.    End
  51.    Begin VB.Menu mUnfreeze 
  52.       Caption         =   "&Unfreeze"
  53.    End
  54.    Begin VB.Menu mAbout 
  55.       Caption         =   "&About"
  56.    End
  57. Attribute VB_Name = "Form1"
  58. Attribute VB_Creatable = False
  59. Attribute VB_Exposed = False
  60. Private Sub CMDialog1_Click()
  61. End Sub
  62. Private Sub Form_Load()
  63.     Form1.top = 500
  64.     Form1.left = 500
  65.     Form1.Width = 4920
  66.     Form1.Height = 4290
  67.     Form1.Caption = "WinFast T230"
  68.     If VIDEO_Initialize() Then
  69.         'VIDEO_SetVideoPos 0, 0, 640, 480
  70.         VIDEO_SetHorizontalAlignment 108
  71.         VIDEO_SetVerticalAlignment 15
  72.         VIDEO_SetHorizontalCrop 640
  73.         VIDEO_SetVerticalCrop 480
  74.     Else
  75.         MsgBox "Can't initialize WinFast T230 Board"
  76.     End If
  77. End Sub
  78. Private Sub Form_Paint()
  79.     Dim FRECT As RECT
  80.     GetWindowRect Form1.hWnd, FRECT
  81.     xx = FRECT.left + GetSystemMetrics(SM_CXFRAME)
  82.     yy = FRECT.top + GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYMENU)
  83.     ww = FRECT.right - FRECT.left - 2 * GetSystemMetrics(SM_CXFRAME)
  84.     hh = FRECT.bottom - FRECT.top - 2 * GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYMENU) - GetSystemMetrics(SM_CYCAPTION)
  85.     VIDEO_EnableVideo
  86.     VIDEO_SetVideoPos xx, yy, ww, hh
  87. End Sub
  88. Private Sub Form_Resize()
  89. Dim RC As RECT
  90.     InvalidateRect Form1.hWnd, RC, 1
  91. End Sub
  92. Private Sub Form_Terminate()
  93.     VIDEO_DisableVideo
  94.     VIDEO_End
  95.     End
  96. End Sub
  97. Private Sub Form_Unload(Cancel As Integer)
  98.     VIDEO_DisableVideo
  99.     VIDEO_End
  100.     End
  101. End Sub
  102. Private Sub mAbout_Click()
  103.     Load frmAbout
  104.     frmAbout.Show
  105. End Sub
  106. Private Sub mFreeze_Click()
  107.     VIDEO_FreezeVideo
  108. End Sub
  109. Private Sub mLoad_Click()
  110.     Dim nWidth, nHeight As Integer
  111.     Dim totalsize As Long
  112.     Dim bmpinfo As BITMAPINFOHEADER
  113.     Dim bmpheader As BITMAPFILEHEADER
  114.     Dim linesize As Long
  115.     Dim imagesize As Long
  116.     Dim stMem As Long
  117.     Dim gMem As Integer
  118.     Dim hFile As Integer
  119.     Dim wLinesPerScan, wScanTimes, wRestLines As Integer
  120.     Dim ii As Integer
  121.     Dim szLoadFileName As String
  122.     szLoadFileName = ""
  123.     VIDEO_DisableVideo
  124.     CMDialog1.Filter = "Windows Bitmap (*.bmp)|*.bmp||"
  125.     CMDialog1.Flags = 0
  126.     CMDialog1.Action = 1
  127.     szLoadFileName = CMDialog1.filename
  128.     If szLoadFileName = "" Then
  129.         VIDEO_EnableVideo
  130.         Exit Sub
  131.     End If
  132.     gMem = GlobalAlloc(GHND, 31 * 1024)
  133.     If gMem > 0 Then
  134.         stMem = GlobalLock(gMem)
  135.         VIDEO_FreezeVideo
  136.         hFile = lopen(szLoadFileName, 0)
  137.         If (hFile > 0) Then
  138.             nRet% = lread(hFile, bmpheader, 14)
  139.             nRet% = lread(hFile, bmpinfo, 40)
  140.             
  141.             nWidth = bmpinfo.biWidth
  142.             nHeight = bmpinfo.biHeight
  143.             If bmpheader.bfType <> &H4D42 Or bmpinfo.biBitCount <> 24 Then
  144.                 MsgBox "Bitmap File is not BMP24 Format"
  145.                 VIDEO_EnableVideo
  146.                 Exit Sub
  147.             End If
  148.             
  149.             linesize = nWidth * 3
  150.             imagesize = bmpinfo.biSizeImage
  151.             totalsize = bmpinfo.biSizeImage
  152.             wLinesPerScan = (31 * 1024) \ linesize
  153.             wScanTimes = nHeight \ wLinesPerScan
  154.             wRestLines = nHeight - (wScanTimes * wLinesPerScan)
  155.             
  156.             nRet% = llread(hFile, stMem, wRestLines * linesize)
  157.             VIDEO_RestoreImageRect stMem, 0, wScanTimes * wLinesPerScan, nWidth, wRestLines, 4, 0
  158.             For ii = (wScanTimes - 1) To 0 Step -1
  159.                 nRet% = llread(hFile, stMem, wLinesPerScan * linesize)
  160.                 VIDEO_RestoreImageRect stMem, 0, ii * wLinesPerScan, nWidth, wLinesPerScan, 4, 0
  161.             Next ii
  162.             nRet% = lclose(hFile)
  163.             nRet% = GlobalUnlock(gMem)
  164.         Else
  165.             MsgBox "Not Enough Memory"
  166.             VIDEO_EnableVideo
  167.             Exit Sub
  168.         End If
  169.     End If
  170.     nRet% = GlobalFree(gMem)
  171.     VIDEO_EnableVideo
  172. End Sub
  173. Private Sub mSave_Click()
  174.     Dim nWidth, nHeight As Integer
  175.     Dim totalsize As Long
  176.     Dim bmpinfo As BITMAPINFOHEADER
  177.     Dim bmpheader As BITMAPFILEHEADER
  178.     Dim linesize As Long
  179.     Dim imagesize As Long
  180.     Dim stMem As Long
  181.     Dim gMem As Integer
  182.     Dim hFile As Integer
  183.     Dim wLinesPerScan, wScanTimes, wRestLines As Integer
  184.     Dim ii As Integer
  185.     Dim szSaveFileName As String
  186.     szSaveFileName = ""
  187.     VIDEO_DisableVideo
  188.     CMDialog1.Filter = "Windows Bitmap (*.bmp)|*.bmp||"
  189.     CMDialog1.Flags = 0
  190.     CMDialog1.Action = 1
  191.     szSaveFileName = CMDialog1.filename
  192.     If szSaveFileName = "" Then
  193.         VIDEO_EnableVideo
  194.         Exit Sub
  195.     End If
  196.     nWidth = ((ww + 3) \ 4) * 4
  197.     nHeight = hh
  198.     linesize = nWidth * 3
  199.     imagesize = linesize * nHeight
  200.     totalsize = imagesize + linesize
  201.     bmpinfo.biSize = 40
  202.     bmpinfo.biWidth = nWidth
  203.     bmpinfo.biHeight = nHeight
  204.     bmpinfo.biPlanes = 1
  205.     bmpinfo.biBitCount = 24
  206.     bmpinfo.biCompression = 0
  207.     bmpinfo.biSizeImage = imagesize
  208.     bmpinfo.biXPelsPerMeter = 0
  209.     bmpinfo.biYPelsPerMeter = 0
  210.     bmpinfo.biClrUsed = 0
  211.     bmpinfo.biClrImportant = 0
  212.     bmpheader.bfType = &H4D42
  213.     bmpheader.bfOffBits = 14 + 40
  214.     bmpheader.bfSize = bmpinfo.biSizeImage + bmpheader.bfOffBits
  215.     bmpheader.bfReserved1 = 0
  216.     bmpheader.bfReserved2 = 0
  217.     wLinesPerScan = (31 * 1024) \ linesize
  218.     wScanTimes = nHeight \ wLinesPerScan
  219.     wRestLines = nHeight - (wScanTimes * wLinesPerScan)
  220.     gMem = GlobalAlloc(GHND, 31 * 1024)
  221.     If gMem > 0 Then
  222.         stMem = GlobalLock(gMem)
  223.         VIDEO_FreezeVideo
  224.         hFile = lcreat(szSaveFileName, 0)
  225.         If (hFile > 0) Then
  226.             nRet% = lwrite(hFile, bmpheader, 14)
  227.             nRet% = lwrite(hFile, bmpinfo, 40)
  228.             VIDEO_LoadImageRect stMem, 0, wScanTimes * wLinesPerScan, nWidth, wRestLines, 4, 0
  229.             nRet% = llwrite(hFile, stMem, wRestLines * linesize)
  230.             For ii = (wScanTimes - 1) To 0 Step -1
  231.                 VIDEO_LoadImageRect stMem, 0, ii * wLinesPerScan, nWidth, wLinesPerScan, 4, 0
  232.                 nRet% = llwrite(hFile, stMem, wLinesPerScan * linesize)
  233.             Next ii
  234.         End If
  235.         nRet% = lclose(hFile)
  236.         nRet% = GlobalUnlock(gMem)
  237.     Else
  238.         MsgBox "Not Enough Memory"
  239.         VIDEO_EnableVideo
  240.         Exit Sub
  241.     End If
  242.     nRet% = GlobalFree(gMem)
  243.     VIDEO_EnableVideo
  244. End Sub
  245. Private Sub mUnfreeze_Click()
  246.     VIDEO_UnfreezeVideo
  247. End Sub
  248. Private Sub Timer1_Timer()
  249.     Dim FRECT As RECT
  250.     GetWindowRect Form1.hWnd, FRECT
  251.     xx = FRECT.left + GetSystemMetrics(SM_CXFRAME)
  252.     yy = FRECT.top + GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYMENU)
  253.     ww = FRECT.right - FRECT.left - 2 * GetSystemMetrics(SM_CXFRAME)
  254.     hh = FRECT.bottom - FRECT.top - 2 * GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYMENU) - GetSystemMetrics(SM_CYCAPTION)
  255.     VIDEO_EnableVideo
  256.     VIDEO_SetVideoPos xx, yy, ww, hh
  257. End Sub
  258.