473,326 Members | 2,815 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,326 software developers and data experts.

SendMessage(handle, WM_CHAR, VirtualKeys.VK_A, 0) does not trigger KeyDown...

Hi All,

maybe this is a sill question..but if i have TextBox and use the
SendMessage(..) to send
a character the control.. the KeyDown event is not triggered.... in would
need to check in the WndProc(...) of the WM_CHAR event...

Is there another way to send characters to the TextBox, when I'm only having
the control's handle
which does simulated the user typing in characters so the KeyDown event gets
triggered?

Cheers,

Fred
Jul 22 '05 #1
4 35440
If you want the KeyDown event triggered, you need to send the
WM_KEYDOWN message.

Jul 22 '05 #2
Hi Chris,

thx...

using the WM_KEYDOWN.. how can i send a control key + a letter.. e.g Ctrl+G
??

Cheers,

Fred

"Chris Dunaway" <du******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
If you want the KeyDown event triggered, you need to send the
WM_KEYDOWN message.

Jul 22 '05 #3
It appears as if you have to send 5 messages to get a Ctrl+G:

WM_KEYDOWN for the Ctrl key
WM_KEYDOWN for the G key
WM_CHAR for the Ctrl-G (7)
WM_KEYUP for the G key
WM_KEYUP for the Ctrl key

I could be wrong, but that is how it looked in Spy++ when I pressed
Ctrl+G on a textbox.

Here is how I duplicated that in code:

Dim GDownLParam As New IntPtr(&H220001)
Dim GUpLParam As New IntPtr(&HC0220001)
Dim CtrlDownLParam As New IntPtr(&H11D0001)
Dim CtrlUpLParam As New IntPtr(&HC11D0001)
Win32.User.SendMessage(TextBox1.Handle, Win32.User.WM_KEYDOWN,
&H11, CtrlDownLParam)
Win32.User.SendMessage(TextBox1.Handle, Win32.User.WM_KEYDOWN,
&H47, GDownLParam)
Win32.User.SendMessage(TextBox1.Handle, Win32.User.WM_CHAR,
&H7, GDownLParam)
Win32.User.SendMessage(TextBox1.Handle, Win32.User.WM_KEYUP,
&H47, GUpLParam)
Win32.User.SendMessage(TextBox1.Handle, Win32.User.WM_KEYUP,
&H11, CtrlUpLParam)

I have a set of classes that make it easy to call the Win32 API and
that is what I am using in this code. If you're interested in those
classes, I can send them.

Chris

Jul 22 '05 #4
Hi Chris,

that works great! Thx,

Cheers,
Fred

"Chris Dunaway" <du******@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
It appears as if you have to send 5 messages to get a Ctrl+G:

WM_KEYDOWN for the Ctrl key
WM_KEYDOWN for the G key
WM_CHAR for the Ctrl-G (7)
WM_KEYUP for the G key
WM_KEYUP for the Ctrl key

I could be wrong, but that is how it looked in Spy++ when I pressed
Ctrl+G on a textbox.

Here is how I duplicated that in code:

Dim GDownLParam As New IntPtr(&H220001)
Dim GUpLParam As New IntPtr(&HC0220001)
Dim CtrlDownLParam As New IntPtr(&H11D0001)
Dim CtrlUpLParam As New IntPtr(&HC11D0001)
Win32.User.SendMessage(TextBox1.Handle, Win32.User.WM_KEYDOWN,
&H11, CtrlDownLParam)
Win32.User.SendMessage(TextBox1.Handle, Win32.User.WM_KEYDOWN,
&H47, GDownLParam)
Win32.User.SendMessage(TextBox1.Handle, Win32.User.WM_CHAR,
&H7, GDownLParam)
Win32.User.SendMessage(TextBox1.Handle, Win32.User.WM_KEYUP,
&H47, GUpLParam)
Win32.User.SendMessage(TextBox1.Handle, Win32.User.WM_KEYUP,
&H11, CtrlUpLParam)

I have a set of classes that make it easy to call the Win32 API and
that is what I am using in this code. If you're interested in those
classes, I can send them.

Chris

Jul 22 '05 #5

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

Similar topics

6
by: R.Wieser | last post by:
Hello All, I'm trying to get a "Virtual Listbox" to work. I've currently got a form, and used CreateWindowExA to create a ListBox with the LBS_OWNERDRAWFIXED and LBS_NODATA flags on it. I've...
1
by: Nidhi | last post by:
Hi, I am trying to write code to retrieve the small icon for an application in C#. I am using SendMessage with WM_GETICON for this purpose but the return value I get is 0. I don't understand...
5
by: Adam Clauss | last post by:
I am attempting to set the text on a richedit control in another application using EM_SETTEXTEX:...
0
by: TonyG | last post by:
I need to send a message to a window in another application. The name of the window is known at design time and set in the constant App2_MONITOR_CAPTION. The message is defined as X_GenerateEvent....
4
by: Fred Heida | last post by:
Hi All, maybe this is a sill question..but if i have TextBox and use the SendMessage(..) to send a character the control.. the KeyDown event is not triggered.... in would need to check in the...
4
by: Sean | last post by:
I am trying to send a WM_COPYDATA message to another application in C#, ..NET 2.0. The other application receives the message, but only seems to see the first character of the string, does...
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...
4
by: michelqa | last post by:
Hi, I use sendMessage to retrieve information from another application. For some obscur reasons, my code work only in a button click event and nowhere else in my application. I mean I get...
3
by: michelqa | last post by:
Hi, I already post a similar question last week without success. Ok I want to get the current text selection in a RICHEDIT control.. This can be easily done in C++ with EM_EXGETSEL message. I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.