未找到方法或数据成员
我想窗体的"暂停"按钮定义一个对话框,也就是是否将已经获得的屏幕图片1合称为视频文件。但是我调用窗体fMain中的cmdWriteAvi_Click时,老是出现编译错误:“未找到方法或数据成员”。还请各位大虾指点迷津。
///////////////////////////////////////////////////////
Private Sub CommandPause_Click()
Dim Msg, Style, title, Ctxt, Response, MyString
Dim photonumber As Integer
Static bool As Integer
bool = bool * 1
Msg = "是否要将现在截的图片制作成视频文件 ?" ' 定义信息。
Style = vbYesNo + vbCritical + vbDefaultButton2 ' 定义按钮。
title = "MsgBox Demonstration" ' 定义标题。
Ctxt = 1000 ' 定义标题
Response = MsgBox(Msg, Style, title, 0, Ctxt)
If bool = 0 Then
Timer1.Enabled = False
bool = 1
If Response = vbYes Then
Load fMain
fMain.Show
File1.Path = App.Path & "\截图"
File1.Refresh
For i = 0 To File1.ListCount - 1
fMain.lstDIBList.AddItem App.Path & "\截图" & File1.List(i)
Next
fMain.cmdWriteAVI_Click '///////////////就是在这个地方报错!!!
Unload fMain
Set fMain = Nothing
End If
Else
Timer1.Enabled = True
bool = 0
End If
End Sub
///////////////////////////////////////////////////////
Private Sub cmdWriteAVI_Click()
Dim file As cFileDlg
Dim InitDir As String
Dim szOutputAVIFile As String
Dim res As Long
Dim pfile As Long 'ptr PAVIFILE
Dim bmp As cDIB
Dim ps As Long 'ptr PAVISTREAM
Dim psCompressed As Long 'ptr PAVISTREAM
Dim strhdr As AVI_STREAM_INFO
Dim BI As BITMAPINFOHEADER
Dim opts As AVI_COMPRESS_OPTIONS
Dim pOpts As Long
Dim i As Long
Debug.Print
Set file = New cFileDlg
'get an avi filename from user
With file
.DefaultExt = "avi"
.DlgTitle = "Choose a filename to save AVI to..."
.Filter = "AVI Files|*.avi"
.OwnerHwnd = Me.hWnd
End With
szOutputAVIFile = "MyAVI.avi"
If file.VBGetSaveFileName(szOutputAVIFile) <> True Then Exit Sub
' Open the file for writing
res = AVIFileOpen(pfile, szOutputAVIFile, OF_WRITE Or OF_CREATE, 0&)
If (res <> AVIERR_OK) Then GoTo error
'Get the first bmp in the list for setting format
Set bmp = New cDIB
lstDIBList.ListIndex = 0
If bmp.CreateFromFile(lstDIBList.Text) <> True Then
MsgBox "Could not load first bitmap file in list!", vbExclamation, App.title
GoTo error
End If
' Fill in the header for the video stream
With strhdr
.fccType = mmioStringToFOURCC("vids", 0&) '// stream type video
.fccHandler = 0& '// default AVI handler
.dwScale = 1
.dwRate = Val(txtFPS) '// fps
.dwSuggestedBufferSize = bmp.SizeImage '// size of one frame pixels
Call SetRect(.rcFrame, 0, 0, bmp.Width, bmp.Height) '// rectangle for stream
End With
'validate user input
If strhdr.dwRate < 1 Then strhdr.dwRate = 1
If strhdr.dwRate > 30 Then strhdr.dwRate = 30
' And create the stream
res = AVIFileCreateStream(pfile, ps, strhdr)
If (res <> AVIERR_OK) Then GoTo error
'get the compression options from the user
'Careful! this API requires a pointer to a pointer to a UDT
pOpts = VarPtr(opts)
res = AVISaveOptions(Me.hWnd, _
ICMF_CHOOSE_KEYFRAME Or ICMF_CHOOSE_DATARATE, _
1, _
ps, _
pOpts) 'returns TRUE if User presses OK, FALSE if Cancel, or error code
If res <> 1 Then 'In C TRUE = 1
Call AVISaveOptionsFree(1, pOpts)
GoTo error
End If
'make compressed stream
res = AVIMakeCompressedStream(psCompressed, ps, opts, 0&)
If res <> AVIERR_OK Then GoTo error
'set format of stream according to the bitmap
With BI
.biBitCount = bmp.BitCount
.biClrImportant = bmp.ClrImportant
.biClrUsed = bmp.ClrUsed
.biCompression = bmp.Compression
.biHeight = bmp.Height
.biWidth = bmp.Width
.biPlanes = bmp.Planes
.biSize = bmp.SizeInfoHeader
.biSizeImage = bmp.SizeImage
.biXPelsPerMeter = bmp.XPPM
.biYPelsPerMeter = bmp.YPPM
End With
'set the format of the compressed stream
res = AVIStreamSetFormat(psCompressed, 0, ByVal bmp.PointerToBitmapInfo, bmp.SizeBitmapInfo)
If (res <> AVIERR_OK) Then GoTo error
' Now write out each video frame
For i = 0 To lstDIBList.ListCount - 1
lstDIBList.ListIndex = i
bmp.CreateFromFile (lstDIBList.Text) 'load the bitmap (ignore errors)
res = AVIStreamWrite(psCompressed, _
i, _
1, _
bmp.PointerToBits, _
bmp.SizeImage, _
AVIIF_KEYFRAME, _
ByVal 0&, _
ByVal 0&)
If res <> AVIERR_OK Then GoTo error
'Show user feedback
imgPreview.Picture = LoadPicture(lstDIBList.Text)
imgPreview.Refresh
lblStatus = "Frame number " & i & " saved"
lblStatus.Refresh
Next
lblStatus = "Finished!"
[解决办法]
将cmdWriteAVI_Click 前面的private改成public