Link to home
Start Free TrialLog in
Avatar of Kevin_Foley
Kevin_FoleyFlag for United States of America

asked on

.NET DELEGATE issue

I have converted a VB6 project to .NET.  I have worked through every issue but one.

Add a delegate for AddressOf fWindowProc

I have read numerous articles and looked at examples.  However, when I try to use this code:

I created a delegate

Delegate Function fWindowProcDEL(ByVal hw As Integer, ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer

I added those code to my code:

Dim MyDelegate As fWindowProcDEL
MyDelegate = New fWindowProcDEL(AddressOf fWindowProc)

lpPrevWndProc = SetWindowLong(lHwnd, GWL_WNDPROC, MyDelegate)

I get the error:  Value of type 'Project1.modMain.fWindowProcDEL' cannot be converted to Integer
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Kevin_Foley

ASKER

I need to do a major rewrite in the long run.  In the short term, I am trying to resurrect this 7 year old tool.  

I have two applications and I'm monitoring the messages in one from the other.  (sub class the form to trap for windows messages).  

The VB6 code was

lpPrevWndProc = SetWindowLong(lwnd, GWL_WNDPROC, Address of fwindowProc.)

.NET doesn't like the Address of and says I need a delegate.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
found the answer... had to add .target