Benutzer mit den meisten Antworten
Abfragen von Events

Frage
-
Hallo zusammen
Ich habe folgenden Code in einem C# Programm gefunden:
-->
public event KeyPressEventHandler KeyPressprivate
int KeyboardProc(int code, IntPtr wParam, IntPtr lParam)
{if (msg == WinApi.WM_KEYDOWN && KeyPress != null)
{
.
}}
<--Übersetzt in VB habe ich es wie folgt:
-->
Public Event KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)Private
Function KeyboardProc(ByVal code As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Integer
If msg = WinApi.WM_KEYDOWN AndAlso Not KeyPress(Me, Nothing) = Nothing Then
End If
End Function
Wo ich ein Feher erhalten ist in "AndAlso Not KeyPress = Nothing".
Mir ist auch klar wiso. Ich Frage ja hier einen Event auf Nothing ab und dies geht nicht micht mit Events.
Weiss jemand dieman siese Zeile richtig übersetzen würde?
Gruss Marcel
Antworten
-
Hallo Marcel,
Übersetzt in VB habe ich es wie folgt:
-->
Public Event KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)Private Function KeyboardProc(ByVal code As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Integer
den Delegate zum Event legt VB im Hintergrund mit der Erweiterung 'Event' an. Diesen siehst Du nicht im IntelliSense, kannst Ihn aber genauso nutzen:
If msg = WinApi.WM_KEYDOWN AndAlso KeyPressEvent IsNot Nothing Then
Thorsten Dörfler
Microsoft MVP Visual Basic
vb-faq.de- Als Antwort markiert Marcel Garaventa RTC Montag, 2. August 2010 10:31
Alle Antworten
-
Hallo Marcel,
Übersetzt in VB habe ich es wie folgt:
-->
Public Event KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)Private Function KeyboardProc(ByVal code As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Integer
den Delegate zum Event legt VB im Hintergrund mit der Erweiterung 'Event' an. Diesen siehst Du nicht im IntelliSense, kannst Ihn aber genauso nutzen:
If msg = WinApi.WM_KEYDOWN AndAlso KeyPressEvent IsNot Nothing Then
Thorsten Dörfler
Microsoft MVP Visual Basic
vb-faq.de- Als Antwort markiert Marcel Garaventa RTC Montag, 2. August 2010 10:31