SendMessage WM_SETTEXT Issues

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Necromis

    SendMessage WM_SETTEXT Issues

    Ok, I have gotten my head around things better regarding SendMessage
    and FindWindow functions. However, I am running into an issue with my
    code still. The program I am working with is EXTRA! by Attachmate. It
    is a mainframe terminal. Here is the issue and strange part of it. It
    is accepting sendmessage when I use the WM_KEYDOWN/UP commands.
    However, when I use WM_SETTEXT to send my string it is not imputing
    the string to the session window. Does anyone know why an app would
    work with one SendMessage command and not another, and possibly a work
    around on this? I have a thought to a solution, but dread the
    implications of trying to make it. I would have to use a select case
    scenario for each of the letters, numbers 0-9 and for some of the
    characters like the *. Then I would have to send the text one key at a
    time. As you could imagine that would be a lot of coding and overkill.
    Below is my code as it stands so far. This is my testing phase and
    each piece as it is resolved will be ported into my final project to
    create the app.

    Public Class Form1

    Private Declare Function SendMessage Lib "user32" Alias
    "SendMessag eA" _
    (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As
    Integer, _
    ByVal lParam As String) As Integer

    Private Declare Function FindWindow Lib "user32" Alias
    "FindWindow A" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As
    Integer

    Private Declare Function FindWindowEx Lib "user32" Alias
    "FindWindow ExA" _
    (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As
    String, _
    ByVal lpsz2 As String) As Integer

    Private Declare Function MapVirtualKey Lib "user32" Alias
    "MapVirtualKeyA " _
    (ByVal wCode As Integer, ByVal wMapType As Integer) As Integer

    Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
    As System.EventArg s) _
    Handles Button1.Click

    Const WM_SETTEXT = &HC
    Const WM_KEYDOWN = &H100
    Const WM_KEYUP = &H101
    Const VK_RETURN = &HD

    Dim whwnd As Integer

    Dim hwnd_box As Integer

    Dim comment As String

    comment = TextBox1.Text

    whwnd = FindWindow(vbNu llString, "SESSION1 - EXTRA! for
    NetWare")

    hwnd_box = FindWindowEx(wh wnd, 0, vbNullString, vbNullString)

    If hwnd_box <0 Then
    SendMessage(hwn d_box, WM_SETTEXT, 0, comment)

    Threading.Threa d.Sleep(500)

    SendMessage(hwn d_box, WM_KEYDOWN, VK_RETURN, 0)
    SendMessage(hwn d_box, WM_KEYUP, VK_RETURN, 0)

    'this is just to verify that I am catching the child
    handle
    TextBox2.Text = hwnd_box
    Else
    SendMessage(whw nd, WM_SETTEXT, 0&, comment)
    End If
    End Sub


    End Class

  • Mattias Sjögren

    #2
    Re: SendMessage WM_SETTEXT Issues

    >Here is the issue and strange part of it. It
    >is accepting sendmessage when I use the WM_KEYDOWN/UP commands.
    >However, when I use WM_SETTEXT to send my string it is not imputing
    >the string to the session window. Does anyone know why an app would
    >work with one SendMessage command and not another, and possibly a work
    >around on this?
    Well it's up to the application to decide which messages it cares
    about and how it handles them.

    In a terminal window it makes sense to support entering a character at
    a time (such as when the user is typing) but perhaps not to replace
    the entire text content at once.


    Mattias

    --
    Mattias Sjögren [C# MVP] mattias @ mvps.org
    http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    Please reply only to the newsgroup.

    Comment

    Working...