VB.NET Sendmessage Tutorial gesucht.

  • VB.NET
  • .NET (FX) 4.0

    VB.NET Sendmessage Tutorial gesucht.

    Hallo,

    Ich würde ganz gerne das Programm fdKlinika mit einen zusätzlichen vb.net Programm zwecks Automatisierung (Macro ähnlich) über SendMessage von meinen Visual Basic Programm aus Steuern. Jetzt ist für mich natürlich die Frage. Kennt jemand ein gutes Tutorial für SendMessage.

    Wichtig ist neben Grundlegenden ein ListView auslesen und beschreiben zu können. Und eine Textbox / RichTextbox diese aber in ein Groupview versteckt / eingebettet ist.

    Ich habe schon etwas Gegoogelt und bin scheinbar nicht so weit gekommen, hier ist mein Coode:

    VB.NET-Quellcode

    1. Imports System.Runtime.InteropServices
    2. Imports System.Text
    3. Public Class fdConnector
    4. Private Declare Function SendMessageByString Lib "user32.dll" Alias "SendMessageA" _
    5. (ByVal hWnd As IntPtr, _
    6. ByVal uMsg As Integer, _
    7. ByVal wParam As Integer, _
    8. ByVal lParam As StringBuilder) As Integer
    9. Private Declare Function SendMessageByInt Lib "user32.dll" Alias "SendMessageA" _
    10. (ByVal hWnd As IntPtr, _
    11. ByVal uMsg As Integer, _
    12. ByVal wParam As Integer, _
    13. ByVal lParam As Integer) As Integer
    14. Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" _
    15. (ByVal handle As IntPtr, ByVal uMsg As Integer, _
    16. ByVal wParam As IntPtr, ByVal lParam As String) As IntPtr
    17. Const WM_SETTEXT As Integer = &HC
    18. <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    19. Private Shared Function FindWindow( _
    20. ByVal lpClassName As String, _
    21. ByVal lpWindowTitle As String) As IntPtr
    22. End Function
    23. <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    24. Private Shared Function FindWindowEx(ByVal parentHandle As IntPtr, _
    25. ByVal childAfter As IntPtr, _
    26. ByVal lpClassName As String, _
    27. ByVal lpWindowTitle As String) As IntPtr
    28. End Function
    29. Protected KliDDE As IntPtr = fdConnector.FindWindow("MSCTFIME UI", "KliDDE")
    30. Protected KliDDE_LogServer = fdConnector.FindWindowEx(Me.KliDDE, IntPtr.Zero, "Button", Nothing)
    31. Protected KliDDE_LogInterface = fdConnector.FindWindowEx(Me.KliDDE_LogServer, IntPtr.Zero, "RICHEDIT", "Protokoll")
    32. Const WM_GETTEXT As Integer = &HD
    33. Const WM_GETTEXTLENGTH As Integer = &HE
    34. Public Function GetLogText() As String
    35. If (Not Me.KliDDE.Equals(IntPtr.Zero)) Then
    36. Dim length As Integer = SendMessageByInt(Me.KliDDE, WM_GETTEXTLENGTH, 0, 0)
    37. If length > 0 Then
    38. Dim SB As New StringBuilder(length)
    39. Dim Result As Int32 = SendMessageByString(Me.KliDDE, WM_GETTEXT, length + 1, SB)
    40. If Result <> 0 Then
    41. Return SB.ToString()
    42. Else
    43. Return String.Empty
    44. End If
    45. Else
    46. Return "Kein Text vorhanden"
    47. End If
    48. Else
    49. Return "Handle nicht gefunden"
    50. End If
    51. End Function
    52. End Class


    Vielen Danck an alle schonmal in vorraus :)

    LG, Herbrich