J
john
Hello,
I am trying to convert a project from vb6 to vb.net. The code is a
sample from an sdk for Canon digital camera's. I have gotten most of the
issues resolved, but there are some that I am lacking knowledge in. I would
appreciate any help give with this. The main errors have to deal with the
VarPtr and AddressOf expression. Unfortunetly I do not have much experience
with delegates. Below is some of the code. I can produce the entire project
if anyone would like it. Thanks in advance for your time.
John
addressOf issue:
Private Sub cmdViewFinder_Click(ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles cmdViewFinder.Click
Dim err_Renamed As Integer
If m_bCamConnect = False Then
Exit Sub
End If
If m_bViewFinder = False Then
'UPGRADE_WARNING: Add a delegate for AddressOf ViewFinderCallbackFunc Click
for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1048"'
err_Renamed = CDStartViewfinder(m_hSource, 1, AddressOf
ViewFinderCallbackFunc, 0)
If err_Renamed <> cdOK Then
GoTo ErrHandler
End If
cmdViewFinder.Text = "End"
cmdAEAF.Enabled = True
m_bViewFinder = True
Else
err_Renamed = CDTermViewfinder(m_hSource)
If err_Renamed <> cdOK Then
GoTo ErrHandler
End If
cmdViewFinder.Text = "Start"
cmdAEAF.Enabled = False
m_bViewFinder = False
picViewFinder.Image = Nothing
End If
Exit Sub
VarPrt issue:
Private Sub GetRelData(ByRef NumData As Integer)
'UPGRADE_NOTE: err was upgraded to err_Renamed. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1061"'
Dim err_Renamed As Integer
Dim myMedium As cdStgMedium
Dim RelImgInfo As cdReleaseImageInfo
Dim i As Integer
Dim szPrefix As String
Dim szExt As String
Dim index As String
Dim bytBuff() As Byte
If NumData = 0 Then
Exit Sub
End If
m_Progress = New Progress.CProgress
'/* UI is locked so that information may not be changed. */
err_Renamed = CDLockUI(m_hSource)
If err_Renamed <> cdOK Then
GoTo ErrHandler
End If
For i = 1 To NumData
'/* A preservation file name is decided. */
If CDGetReleasedData(m_hSource, 0, 0, 0, RelImgInfo, 0) <> cdOK Then
Exit For
End If
Select Case RelImgInfo.DataType
Case cdDATA_TYPE_THUMBNAIL
szPrefix = "TH"
szExt = "JPG"
Case cdDATA_TYPE_PICTURE
szPrefix = "FV"
If RelImgInfo.Format_Renamed = 1 Then
szExt = "JPG"
Else
szExt = "CRW"
End If
Case cdDATA_TYPE_PLUS_JPEG
szPrefix = "FP"
szExt = "JPG"
End Select
m_RelFileIndex = m_RelFileIndex + 1
index = VB6.Format(m_RelFileIndex, "000000")
myMedium.Type = cdMEMTYPE_FILE
myMedium.u.lpszFileName = txtSavePath.Text & szPrefix & index & "." & szExt
ReDim bytBuff(Len(myMedium.Type) + Len(myMedium.u.lpszFileName))
'UPGRADE_ISSUE: VarPtr function is not supported. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1040"'
Call RtlMoveMemory(VarPtr(bytBuff(0)), myMedium.Type, Len(myMedium.Type))
'UPGRADE_ISSUE: VarPtr function is not supported. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1040"'
Call RtlMoveMemory(VarPtr(bytBuff(Len(myMedium.Type))),
myMedium.u.lpszFileName, Len(myMedium.u.lpszFileName))
m_Progress.startProgress((Me.Handle.ToInt32))
'UPGRADE_ISSUE: VarPtr function is not supported. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1040"'
'UPGRADE_WARNING: Add a delegate for AddressOf ProgressCallbackFunc Click
for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1048"'
err_Renamed = CDGetReleasedData(m_hSource, AddressOf ProgressCallbackFunc,
0, cdPROG_REPORT_PERIODICALLY, RelImgInfo, VarPtr(bytBuff(0)))
m_Progress.endProgress()
If err_Renamed <> cdOK Then
GoTo ErrHandler
End If
Next i
'UPGRADE_NOTE: Object m_Progress may not be destroyed until it is garbage
collected. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1029"'
m_Progress = Nothing
'/* The lock of UI is canceled. */
err_Renamed = CDUnlockUI(m_hSource)
If err_Renamed <> cdOK Then
GoTo ErrHandler
End If
Exit Sub
ErrHandler:
'UPGRADE_NOTE: Object m_Progress may not be destroyed until it is garbage
collected. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1029"'
m_Progress = Nothing
CDUnlockUI(m_hSource)
If GETERRORID(err_Renamed) <> cdOPERATION_CANCELLED Then
MsgBox("ErrorCode = 0x" & Hex(err_Renamed), MsgBoxStyle.Critical, "Error")
End If
End Sub
I am trying to convert a project from vb6 to vb.net. The code is a
sample from an sdk for Canon digital camera's. I have gotten most of the
issues resolved, but there are some that I am lacking knowledge in. I would
appreciate any help give with this. The main errors have to deal with the
VarPtr and AddressOf expression. Unfortunetly I do not have much experience
with delegates. Below is some of the code. I can produce the entire project
if anyone would like it. Thanks in advance for your time.
John
addressOf issue:
Private Sub cmdViewFinder_Click(ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles cmdViewFinder.Click
Dim err_Renamed As Integer
If m_bCamConnect = False Then
Exit Sub
End If
If m_bViewFinder = False Then
'UPGRADE_WARNING: Add a delegate for AddressOf ViewFinderCallbackFunc Click
for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1048"'
err_Renamed = CDStartViewfinder(m_hSource, 1, AddressOf
ViewFinderCallbackFunc, 0)
If err_Renamed <> cdOK Then
GoTo ErrHandler
End If
cmdViewFinder.Text = "End"
cmdAEAF.Enabled = True
m_bViewFinder = True
Else
err_Renamed = CDTermViewfinder(m_hSource)
If err_Renamed <> cdOK Then
GoTo ErrHandler
End If
cmdViewFinder.Text = "Start"
cmdAEAF.Enabled = False
m_bViewFinder = False
picViewFinder.Image = Nothing
End If
Exit Sub
VarPrt issue:
Private Sub GetRelData(ByRef NumData As Integer)
'UPGRADE_NOTE: err was upgraded to err_Renamed. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1061"'
Dim err_Renamed As Integer
Dim myMedium As cdStgMedium
Dim RelImgInfo As cdReleaseImageInfo
Dim i As Integer
Dim szPrefix As String
Dim szExt As String
Dim index As String
Dim bytBuff() As Byte
If NumData = 0 Then
Exit Sub
End If
m_Progress = New Progress.CProgress
'/* UI is locked so that information may not be changed. */
err_Renamed = CDLockUI(m_hSource)
If err_Renamed <> cdOK Then
GoTo ErrHandler
End If
For i = 1 To NumData
'/* A preservation file name is decided. */
If CDGetReleasedData(m_hSource, 0, 0, 0, RelImgInfo, 0) <> cdOK Then
Exit For
End If
Select Case RelImgInfo.DataType
Case cdDATA_TYPE_THUMBNAIL
szPrefix = "TH"
szExt = "JPG"
Case cdDATA_TYPE_PICTURE
szPrefix = "FV"
If RelImgInfo.Format_Renamed = 1 Then
szExt = "JPG"
Else
szExt = "CRW"
End If
Case cdDATA_TYPE_PLUS_JPEG
szPrefix = "FP"
szExt = "JPG"
End Select
m_RelFileIndex = m_RelFileIndex + 1
index = VB6.Format(m_RelFileIndex, "000000")
myMedium.Type = cdMEMTYPE_FILE
myMedium.u.lpszFileName = txtSavePath.Text & szPrefix & index & "." & szExt
ReDim bytBuff(Len(myMedium.Type) + Len(myMedium.u.lpszFileName))
'UPGRADE_ISSUE: VarPtr function is not supported. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1040"'
Call RtlMoveMemory(VarPtr(bytBuff(0)), myMedium.Type, Len(myMedium.Type))
'UPGRADE_ISSUE: VarPtr function is not supported. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1040"'
Call RtlMoveMemory(VarPtr(bytBuff(Len(myMedium.Type))),
myMedium.u.lpszFileName, Len(myMedium.u.lpszFileName))
m_Progress.startProgress((Me.Handle.ToInt32))
'UPGRADE_ISSUE: VarPtr function is not supported. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1040"'
'UPGRADE_WARNING: Add a delegate for AddressOf ProgressCallbackFunc Click
for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1048"'
err_Renamed = CDGetReleasedData(m_hSource, AddressOf ProgressCallbackFunc,
0, cdPROG_REPORT_PERIODICALLY, RelImgInfo, VarPtr(bytBuff(0)))
m_Progress.endProgress()
If err_Renamed <> cdOK Then
GoTo ErrHandler
End If
Next i
'UPGRADE_NOTE: Object m_Progress may not be destroyed until it is garbage
collected. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1029"'
m_Progress = Nothing
'/* The lock of UI is canceled. */
err_Renamed = CDUnlockUI(m_hSource)
If err_Renamed <> cdOK Then
GoTo ErrHandler
End If
Exit Sub
ErrHandler:
'UPGRADE_NOTE: Object m_Progress may not be destroyed until it is garbage
collected. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1029"'
m_Progress = Nothing
CDUnlockUI(m_hSource)
If GETERRORID(err_Renamed) <> cdOPERATION_CANCELLED Then
MsgBox("ErrorCode = 0x" & Hex(err_Renamed), MsgBoxStyle.Critical, "Error")
End If
End Sub