473,396 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

SendMessage and WM_SETTEXT

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, _
ByVal Msg As Integer, _
ByVal wParam As IntPtr, _
ByRef lParam As String) As IntPtr
End Function
and here is how I call it:

SendMessageString (editHwnd, WM_SETTEXT, 0, message.ToString())

The edit control of the dialog box is getting filled in, but it is
either filled with boxes (using CharSet.Auto or CharSet.Unicode in the
declaration) or with characters from languages other than US English
(using CharSet.Ansi in the declaration).

Any ideas on why the text is not making it through to the edit control?

For those that want more details, I'm trying to write a file name into
the edit control of the "Print To File" dialog box. I don't control the
printing, or I'd use the PrintDocument.PrintSettings stuff in the
framework. I'm calling the PrintAllPages() method of an ActiveX control
that doesn't support printing to a file directly, so these are the
hoops I must jump through.

thanks,
mark
Mar 2 '07 #1
3 7127
"Mark Ingalls" <re***@in.newsgroup.comschrieb:
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, _
ByVal Msg As Integer, _
ByVal wParam As IntPtr, _
ByRef lParam As String) As IntPtr
='ByVal lParam As String'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Mar 2 '07 #2
Hello Herfried K. Wagner [MVP],
>
='ByVal lParam As String'.
Thanks for the correction. I got the declaration from www.pinvoke.net and
implicitly trusted it. It all is working fine now.

thanks,
mark
Mar 2 '07 #3
Are you making a password program that uncovers the '*' from the edit box?
If so, there are loads of VB.NET examples out on the Internet including some
that I have posted 3-4 years ago.

With the SendMessage API function its common to overload it too & Herfried
is correct becaiuse you don't want to be passing ByRef as you'll soon crash
your app.

--
Newbie Coder
(It's just a name)
Mar 2 '07 #4

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

Similar topics

5
by: Adam Clauss | last post by:
I am attempting to set the text on a richedit control in another application using EM_SETTEXTEX:...
3
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...
4
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"...
4
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...
22
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. ...
2
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...
15
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...
1
by: Necromis | last post by:
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...
5
by: michelqa | last post by:
Hi, I need to call a lot of different native SendMessage to retreive informations from non managed application. Some win32 messages use struct pointer for lparam....how to create and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.