Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Delegate
Message
From
12/03/2003 13:13:13
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Delegate
Miscellaneous
Thread ID:
00765008
Message ID:
00765008
Views:
75
Hello all, I am converting some C# code to VB. I am having a problem with the code below. The design time debugger underlines the BeforeMessageEventHandler after Public Event. The error is
Events cannot be declared with a delegate type that has a return type.
Is the conversion wrong or does the code only work for C#. Thanks for the help.


'VB Code
Imports System
Imports Microsoft.WindowsCE.Forms

Namespace Corrigo.CorrigoNet.CorrigoNetToGo

Public Class clsMessageWindow

' Summary description - MessageWindow.

Inherits MessageWindow

Public Sub New()
End Sub 'New

Delegate Function BeforeMessageEventHandler(ByRef msg As Message) As Boolean
Delegate Sub AfterMessageEventHandler(ByRef msg As Message)

Public Event BeforeMessageEvent As BeforeMessageEventHandler
Public Event AfterMessageEvent As AfterMessageEventHandler


Protected Overrides Sub WndProc(ByRef m As Message)
If Not (BeforeMessageEvent Is Nothing) And BeforeMessageEvent(m) Then
Return
End If
MyBase.WndProc(m)
RaiseEvent AfterMessageEvent(m)
End Sub 'WndProc

End Class

End Namespace 'Corrigo.CorrigoNet.CorrigoNetToGo


'C# code
using System;
using Microsoft.WindowsCE.Forms;

namespace Corrigo.CorrigoNet.CorrigoNetToGo
{
///
/// Summary description for MyMessageWindow.
///

public class MyMessageWindow: MessageWindow
{
public MyMessageWindow()
{
}

public delegate bool BeforeMessageEventHandler(ref Message msg);
public delegate void AfterMessageEventHandler(ref Message msg);
public event BeforeMessageEventHandler BeforeMessageEvent;
public event AfterMessageEventHandler AfterMessageEvent;

protected override void WndProc(ref Message m)
{
if ( BeforeMessageEvent != null && BeforeMessageEvent(ref m) )
return;
base.WndProc (ref m);
AfterMessageEvent(ref m);
}

}
}
Randy Belcher
AFG Industries, Inc.
Next
Reply
Map
View

Click here to load this message in the networking platform