473,385 Members | 1,372 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

callback Proc: need delegate obj. Pls help

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
Nov 20 '05 #1
3 1715
Hi,

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

Ken
---------------
"suria`" <su******@yahoo.com> wrote in message
news:ff************************@posting.google.com ...
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

Nov 20 '05 #2
Hi,

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

Ken
---------------
"suria`" <su******@yahoo.com> wrote in message
news:ff************************@posting.google.com ...
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

Nov 20 '05 #3
thanks for your link
i have solve the problem
thanks again
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ThinkRS232 | last post by:
I have a Win32 DLL that has a standard _stdcall (WINAPI) exports. I am able to call these fine from C#. One call in particular however has a callback to a CDECL function. How would I set that up?...
10
by: John Bowman | last post by:
Hello, I need some help getting a callback delegate passed as an argument to a dynamically linked Dll method so it in turn, can eventually call it. Below is the salient portions of code I'm...
2
by: Gerda | last post by:
Hi! I've implemented many times an asynchronous call of a method with a call backfunction successfully. But to implement this with VB.NET is not so successfully. I can implement all events...
5
by: greg.merideth | last post by:
I have a class that I've provided an event for to be called when the processing in the class is complete (a callback). The class spins up a series of threads for the background operation and I'm...
6
by: Bart Burkhardt | last post by:
Hi, I could use some help in setting a C# callback function that an external unmanaged dll will call on a event. Using a delegate and use the external callback set function doesn't work. The...
13
by: Wilfried Mestdagh | last post by:
Hi, I have an application using a DLL and callbacks. It generate random the error "A callback was made on a garbage collected delegate". I found some articles that the pointer to the delegate...
4
by: Edwin Gomez | last post by:
I'm a C# developer and I'm new to Python. I would like to know if the concept of Asynchronous call-backs exists in Python. Basically what I mean is that I dispatch a thread and when the thread...
5
by: sajin | last post by:
Hi All.. We are using VB .Net 2005 for implementing an API. API needs to generate events. For this client wants us to use Windows Callback (delegate implementation). The intention of using...
10
by: SQACPP | last post by:
Hi, I try to figure out how to use Callback procedure in a C++ form project The following code *work* perfectly on a console project #include "Windows.h" BOOL CALLBACK...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.