473,666 Members | 2,331 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Jun 15 '07 #1
1 13406
>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.
Jun 16 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5852
by: Adam Clauss | last post by:
I am attempting to set the text on a richedit control in another application using EM_SETTEXTEX: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/richedit/richeditcontrols/richeditcontrolreference/richeditmessages/em_settextex.asp I have the following: public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
3
5329
by: Rob | last post by:
Hi all, I am having trouble converting the code below (found on http://vbnet.mvps.org/index.html?code/core/sendmessage.htm) into a format that will work using vb .NET. Can anyone have a look at it and let me know what I need to change. I have tried changing the "hwnd" type into intptr's but there seem to be other problems too, like it won't allow "lParam As Any" to be declared.
18
6557
by: Lars Netzel | last post by:
Hello! Thanx to this newgroup I have finally, with the help of you guys, gotten this to work halfway.. but the final action is still not working, clicking the "Button2" thru SendMessage(). Private Declare Auto Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Private Declare Auto Function FindWindowEx Lib "user32" (ByVal hWnd1 As
4
2061
by: paraidy | last post by:
Hi all, reading some examples in this group i'm trying to send a text to notepad, but it doesn't work, can someone to correct my code? Thx Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByRef lParam As String) As...
4
2128
by: Abubakar | last post by:
Hi, My application has a lot of threads which at some point call SendMessage api passing it the handle of the gui window. The calls r a lot. My question is that should I call the SendMessage api by protecting it in a critical section, or the SendMessage api itself handles this kind of situation where a lot of threads in the same process r calling it. Regards,
22
9238
by: SQACSharp | last post by:
I'm trying to get the control name of an editbox in another window. The following code set the value "MyPassword" in the password EditBox but it fail to return the control name of the EditBox. I'm sure the problem is the way i'm using the sendmessage API, the return string and the lParam return 0....is anybody have a clue? any sendmessage api expert here? public static extern Int32 FindWindow(String lpClassName,String
2
8096
by: SQACSharp | last post by:
Is there any way to get the int value of a specific WM_ message ?? ex: private const int WM_CLOSE = 16; private const int WM_SETTEXT = 12; ..... but where i can find the int value for WM_GETCONTROLNAME ??? Is it documented somewhere??
3
7154
by: Mark Ingalls | last post by:
Hello Everyone, I'm trying to send a text string to a dialog edit control using SendMessage and WM_SETTEXT and cannot get it working correctly. Here is the declaration of the function: <DllImport("user32.dll", EntryPoint:="SendMessage", SetLastError:=True, CharSet:=CharSet.Auto)_ Private Function SendMessageString(ByVal hWnd As IntPtr, _
15
10367
by: Necromis | last post by:
Ok, I am really losing it. I cannot seem to wrap my head around the SendMessage function/method. What I am trying to do is send text/data to an instance of a window that I know the handle of from within a vb.net application. Can someone give me a decent example of the code I would need to create to process this using the sample data below. Windows hwnd = 0xB0484 String text = "NM*14*ACCTNO*MMDDYY"
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1772
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.