DerStauner
Erfahrenes Mitglied
Ich denke, dieser Thread gehört lieber hierher (vb.net).
Ich möchte folgendes Codeteil in vb6 konvertieren:
Was mir Probleme bereitet, ist der Konstruktor in vb6 (ist das das Initialize Event?) und das 'Thread' Teil.
Wäre froh, wenn jemand helfen könnte. Me.Handle und MyBase.WndProc sind auch schwierig für mich.
Ich möchte folgendes Codeteil in vb6 konvertieren:
Code:
Public Class hotkeys
Private Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As IntPtr, _
ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As _
Integer
Private Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As _
IntPtr, ByVal id As Integer) As Integer
Private Declare Function GlobalAddAtom Lib "kernel32" Alias "GlobalAddAtomA" _
(ByVal lpString As String) As Short
Private Declare Function GlobalDeleteAtom Lib "kernel32" (ByVal nAtom As _
Short) As Short
Public Class MODKeys
Public Const MOD_ALT As Integer = 1
Public Const MOD_CONTROL As Integer = 2
Public Const MOD_SHIFT As Integer = 4
Public Const MOD_WIN As Integer = 8
End Class
Dim hotkeyID As Short
Public Sub New(ByVal sKey As System.Windows.Forms.Keys, Optional ByVal _
Modulate As Long = 0)
RegisterGlobalHotKey(sKey, Modulate)
End Sub
Private Sub RegisterGlobalHotKey(ByVal hotkey As System.Windows.Forms.Keys, _
ByVal modifiers As Integer)
Try
Dim atomName As String = _
Threading.Thread.CurrentThread.ManagedThreadId.ToString("X8") & Me.Name
hotkeyID = GlobalAddAtom(atomName)
RegisterHotKey(Me.Handle, hotkeyID, modifiers, CInt(hotkey))
Catch ex As Exception
UnregisterGlobalHotKey()
End Try
End Sub
Private Sub UnregisterGlobalHotKey()
If Me.hotkeyID <> 0 Then
UnregisterHotKey(Me.Handle, hotkeyID)
GlobalDeleteAtom(hotkeyID)
hotkeyID = 0
End If
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
MyBase.WndProc(m)
Const WM_HOTKEY As Integer = &H312
If m.Msg = WM_HOTKEY Then
MsgBox "Hotkey Pressed"
End If
End Sub
End Class
Was mir Probleme bereitet, ist der Konstruktor in vb6 (ist das das Initialize Event?) und das 'Thread' Teil.
Wäre froh, wenn jemand helfen könnte. Me.Handle und MyBase.WndProc sind auch schwierig für mich.
Zuletzt bearbeitet: