473,770 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SendMessage(han dle, 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 35513
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.goo glegroups.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(&HC02200 01)
Dim CtrlDownLParam As New IntPtr(&H11D000 1)
Dim CtrlUpLParam As New IntPtr(&HC11D00 01)
Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_K EYDOWN,
&H11, CtrlDownLParam)
Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_K EYDOWN,
&H47, GDownLParam)
Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_C HAR,
&H7, GDownLParam)
Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_K EYUP,
&H47, GUpLParam)
Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_K EYUP,
&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.goo glegroups.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(&HC02200 01)
Dim CtrlDownLParam As New IntPtr(&H11D000 1)
Dim CtrlUpLParam As New IntPtr(&HC11D00 01)
Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_K EYDOWN,
&H11, CtrlDownLParam)
Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_K EYDOWN,
&H47, GDownLParam)
Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_C HAR,
&H7, GDownLParam)
Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_K EYUP,
&H47, GUpLParam)
Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_K EYUP,
&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
7873
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 allso subclassed the window and do see all kinds of WS_??? messages coming by. But now I'm stuck :-\ I've got *no* idea what to do next, and all my searching on the web leads me
1
15652
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 this. Is that expected? What am I doing wrong? Any help would be appreciated. Here is the snippet of code that I am using - public static extern int SendMessage(int
5
5861
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);
0
558
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. The following VB6 code works. Is this possible in C# ? Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function SendMessage Lib...
4
560
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 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
4
15610
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 anybody have any ideas? I have copied the code below. class WIN32 {
5
5237
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 marshaling the struct to be able to use it in sendmessage... Here is an example LM_GETITEM: http://msdn.microsoft.com/en-us/library/bb760720(VS.85).aspx
4
1683
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 unexpected result depending where the code is placed in my application ?!?!?!?!? Here is my code: ================================
3
6154
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 really need to do the same thing in C#. How can I put the structure in memory to be able to call SendMessage and get the expected results in the structure.
0
9618
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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
10259
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
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
9906
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
8933
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6710
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
5354
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
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.