PC Review


Reply
Thread Tools Rate Thread

callback Proc: need delegate obj. Pls help

 
 
suria`
Guest
Posts: n/a
 
      22nd Nov 2003
hi
New to delegates, trying to figure out how to use a
delegate to fix a bug after upgrading code from VB6 to
VB.NET

I have the following callback proc:
' in vb 6.0

###############################################################################
Public Sub LineCallbackProc(ByVal hDevice As Long, _
ByVal dwMsg As Long, _
ByVal dwCallbackInstance As Long, _
ByVal dwParam1 As Long, _
ByVal dwParam2 As Long, _
ByVal dwParam3 As Long)
'the callbackInstance parameter contains a pointer to the
CvbTAPILine class
'this sub just routes all callbacks back to the class for handling
there
Dim PassedObj As CvbTAPILine
Dim objTemp As CvbTAPILine
Debug.Print "LineCALLBACK : dwCallbackInst = " &
dwCallbackInstance
If dwCallbackInstance <> 0 Then
'turn pointer into illegal, uncounted reference
'Debug.Print "step #1"
CopyMemory objTemp, dwCallbackInstance, 4
'Assign to legal reference
'Debug.Print "step #2"
Set PassedObj = objTemp
'Destroy the illegal reference
'Debug.Print "step #3"
CopyMemory objTemp, 0&, 4
'use the interface to call back to the class
'Debug.Print "step #4"
PassedObj.LineProcHandler hDevice, dwMsg, dwParam1, dwParam2,
dwParam3
'Debug.Print "step #5"


End If

End Sub
###############################################################################

rc = lineInitializeEx(m_hLineApp, App.hInstance, AddressOf _
LineCallbackProc, App.Title, _
m_numLines, m_HiAPI, lip)
###############################################################################


When i converted this in vb.net i get an errors stating that

'AddressOf' expression cannot be converted to 'Integer' because
'Integer' is not a delegate type.

i have made some study on this .
1.) first we have to create a delegate object on the callback function
then
2.) we have to put the correct signature and bla.. bla
i have tried many things but it seems doesn't help me
if any body can help me please provide me the code , its urgent

TIA
 
Reply With Quote
 
 
 
 
Ken Tucker [MVP]
Guest
Posts: n/a
 
      23rd Nov 2003
Hi,

Maybe this will help
http://www.elitevb.com/content/01,0075,01/04.aspx

Ken
---------------
"suria`" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> hi
> New to delegates, trying to figure out how to use a
> delegate to fix a bug after upgrading code from VB6 to
> VB.NET
>
> I have the following callback proc:
> ' in vb 6.0
>
>

############################################################################
###
> Public Sub LineCallbackProc(ByVal hDevice As Long, _
> ByVal dwMsg As Long, _
> ByVal dwCallbackInstance As Long, _
> ByVal dwParam1 As Long, _
> ByVal dwParam2 As Long, _
> ByVal dwParam3 As Long)
> 'the callbackInstance parameter contains a pointer to the
> CvbTAPILine class
> 'this sub just routes all callbacks back to the class for handling
> there
> Dim PassedObj As CvbTAPILine
> Dim objTemp As CvbTAPILine
> Debug.Print "LineCALLBACK : dwCallbackInst = " &
> dwCallbackInstance
> If dwCallbackInstance <> 0 Then
> 'turn pointer into illegal, uncounted reference
> 'Debug.Print "step #1"
> CopyMemory objTemp, dwCallbackInstance, 4
> 'Assign to legal reference
> 'Debug.Print "step #2"
> Set PassedObj = objTemp
> 'Destroy the illegal reference
> 'Debug.Print "step #3"
> CopyMemory objTemp, 0&, 4
> 'use the interface to call back to the class
> 'Debug.Print "step #4"
> PassedObj.LineProcHandler hDevice, dwMsg, dwParam1, dwParam2,
> dwParam3
> 'Debug.Print "step #5"
>
>
> End If
>
> End Sub
>

############################################################################
###
>
> rc = lineInitializeEx(m_hLineApp, App.hInstance, AddressOf _
> LineCallbackProc, App.Title, _
> m_numLines, m_HiAPI, lip)
>

############################################################################
###
>
>
> When i converted this in vb.net i get an errors stating that
>
> 'AddressOf' expression cannot be converted to 'Integer' because
> 'Integer' is not a delegate type.
>
> i have made some study on this .
> 1.) first we have to create a delegate object on the callback function
> then
> 2.) we have to put the correct signature and bla.. bla
> i have tried many things but it seems doesn't help me
> if any body can help me please provide me the code , its urgent
>
> TIA



 
Reply With Quote
 
suria`
Guest
Posts: n/a
 
      24th Nov 2003
thanks for your link
i have solve the problem
thanks again
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with delegate callback error Flomo Togba Kwele Microsoft VB .NET 9 7th May 2007 04:37 AM
delegate for unmanaged callback =?Utf-8?B?dGIyMDAw?= Microsoft Dot NET Compact Framework 5 10th Feb 2006 06:10 AM
Delegate Callback with parameter Budi Microsoft C# .NET 0 12th Jul 2004 11:25 PM
Delegate and callback problem Coder Microsoft Dot NET Framework 5 9th Sep 2003 07:00 PM
Delegate and callback problem Coder Microsoft Dot NET Compact Framework 5 9th Sep 2003 07:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:12 PM.