Solved

how to simulate a OnKeyDown event

Posted on 2000-05-13
1
253 Views
Last Modified: 2008-02-20
How can I simulate a OnKeyDown event in C++ Builder 4? Basically I want my program to think that I pressed a certain key on the keybord when I click a TButton for example.
0
Comment
Question by:TropicalFish
1 Comment
 
LVL 22

Accepted Solution

by:
nietod earned 30 total points
ID: 2807176
Often it is best not to even try that.  Instead you should try to move the code that responds to the key to a seperate function.  Then you can call this function when the button is pressed or when the key is typed.  

That is likely to be the best solution.  However, you could use the keybd_event() function to "simulate" the pressing of the key.  This is a windows API function and it is documented in the windows help.  

Let me know if you have any questions.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question