SendMessage WM_SETTEXT Issues

N

Necromis

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
"SendMessageA" _
(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
"FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As
Integer

Private Declare Function FindWindowEx Lib "user32" Alias
"FindWindowExA" _
(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(ByVal sender As System.Object, ByVal e
As System.EventArgs) _
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(vbNullString, "SESSION1 - EXTRA! for
NetWare")

hwnd_box = FindWindowEx(whwnd, 0, vbNullString, vbNullString)

If hwnd_box <> 0 Then
SendMessage(hwnd_box, WM_SETTEXT, 0, comment)

Threading.Thread.Sleep(500)

SendMessage(hwnd_box, WM_KEYDOWN, VK_RETURN, 0)
SendMessage(hwnd_box, WM_KEYUP, VK_RETURN, 0)

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


End Class
 
M

Mattias Sjögren

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top