(500分求助)VB代码翻译成delphi,或者注释一下 在线等待 ( 积分: 200 )

  • 主题发起人 主题发起人 hfb9531
  • 开始时间 开始时间
H

hfb9531

Unregistered / Unconfirmed
GUEST, unregistred user!
Private Sub DownloadButton_Click()
Dim nret As Long
Dim cnt1 As Long
Dim picsize As Long
Dim FileName
Dim FileNum

On Error GoTo SampleError

If CamFolderList.ListIndex = -1 Then
MsgBox "No picture selected"
Exit Sub
End If

'Set current picture
ZoomScrl.Rye1.propCurrentPicture(nCurrentCamera) = CamFolderList.ListIndex + 1
'Get current picture file size
picsize = ZoomScrl.Rye1.propPicSize(nCurrentCamera)

ReDim Picbuff(picsize) As Byte
'Get current picture file name
FileName = ZoomScrl.Rye1.propFileName(nCurrentCamera)
ProgressForm.Caption = FileName
PictureForm.Caption = FileName
ProgressForm.Show 0, Me

'Get picture from camera
ZoomScrl.Rye1.GetPicture nCurrentCamera, picsize, Picbuff

SampleError:
If Err.Number <> 0 Then
MsgBox Err.Number
Else
PictureForm.Caption = FileName
ProgressForm.Message = &quot;Saving...&quot;
'Get file access ID
FileNum = FreeFile

'Create file
Open &quot;Picture.jpg&quot
For Random As FileNum Len = 1
'Write index picture data
For cnt1 = 1 To picsize
Put FileNum, cnt1, Picbuff(cnt1 - 1)
Next
'Close index file
Close FileNum
Unload ProgressForm
Set PictureForm.PicCtrl.Picture = LoadPicture(&quot;Picture.jpg&quot;)
PictureForm.Show 0, Me
End If
End Sub
 
Private Sub DownloadButton_Click()
Dim nret As Long
Dim cnt1 As Long
Dim picsize As Long
Dim FileName
Dim FileNum

On Error GoTo SampleError

If CamFolderList.ListIndex = -1 Then
MsgBox &quot;No picture selected&quot;
Exit Sub
End If

'Set current picture
ZoomScrl.Rye1.propCurrentPicture(nCurrentCamera) = CamFolderList.ListIndex + 1
'Get current picture file size
picsize = ZoomScrl.Rye1.propPicSize(nCurrentCamera)

ReDim Picbuff(picsize) As Byte
'Get current picture file name
FileName = ZoomScrl.Rye1.propFileName(nCurrentCamera)
ProgressForm.Caption = FileName
PictureForm.Caption = FileName
ProgressForm.Show 0, Me

'Get picture from camera
ZoomScrl.Rye1.GetPicture nCurrentCamera, picsize, Picbuff

SampleError:
If Err.Number <> 0 Then
MsgBox Err.Number
Else
PictureForm.Caption = FileName
ProgressForm.Message = &quot;Saving...&quot;
'Get file access ID
FileNum = FreeFile

'Create file
Open &quot;Picture.jpg&quot
For Random As FileNum Len = 1
'Write index picture data
For cnt1 = 1 To picsize
Put FileNum, cnt1, Picbuff(cnt1 - 1)
Next
'Close index file
Close FileNum
Unload ProgressForm
Set PictureForm.PicCtrl.Picture = LoadPicture(&quot;Picture.jpg&quot;)
PictureForm.Show 0, Me
End If
End Sub
 
没有人知道啊
 
本人不会VB,有些重要的语法无法确定,这是我开发数码相机的项目,非常着急
 
不是翻译得很完善,仅供参考
procedure TForm1.DownloadButtonClick(Sender:TObject);
var
nret,cnt1,picsize: LongInt;
Picbuff:byte;
FileName: String;
//FileNum: Integer;
FileHandle : Integer;
begin
try
If CamFolderList.ItemIndex = -1 then
begin
Application.Messagbox('No Picture Selected',pchar(application.title));
exit;
end;

//Set current picture
//===ZoomScrl我不知道是什么对象,所以照搬
ZoomScrl.Rye1.propCurrentPicture(nCurrentCamera) := CamFolderList.ItemIndex + 1

//Get current picture file size
picsize := ZoomScrl.Rye1.propPicSize(nCurrentCamera);

//Get current picture file name
FileName := ZoomScrl.Rye1.propFileName(nCurrentCamera);
ProgressForm.Caption := FileName;
PictureForm.Caption := FileName;
ProgressForm.FormStyle := fsStayOnTop;
ProgressForm.Show;

//Get picture from camera
ZoomScrl.Rye1.GetPicture(nCurrentCamera, picsize, Picbuff);

except
on E: Exception do application.MessageBox(pchar(E.Message),pchar(application.title));
exit;
end;
PictureForm.Caption := FileName;
//===这里的ProgressForm的Message我也不清楚了,在Delphi中用TLabel来代替吧.
ProgressForm.Message.Caption := 'Saving...'


//Create file
FileHandle := FileOpen(FileName, fmOpenWrite or fmShareDenyNone);
if FileHandle > 0 then
begin
//Write index picture date
for cnt1 := 1 To picsize do
begin
//===在这里我不是很理解这个索引文件怎么做,所以Picbuff的值没有赋,自已加入吧
FileWrite(FileHandle, Picbuff, SizeOf(Picbuff));
end;
end;
//Close index file
FileClose(FileHandle);
ProgressForm.Free;
PictureForm.PicCtrl.Picture.LoadFromFile('Picture.jpg');
PictureForm.FormStyle := fsStayOnTop;
PictureForm.Show;
end;
 
czcn 500给不成,只能是200极限
 
czcn 我的分给了,好像我的分没有减少,不知道怎么回事,我是第一次提问,要是有问题告诉我,谢谢了,要是有别的问题你可以找我,vb不熟悉,d我还可以
 
好的.共同学习
 
后退
顶部