|
-
Aug 14th, 2000, 08:57 AM
#1
Thread Starter
New Member
Hello.
I am trying to make an on-screen keyboard.
The idea is:
The user has the keyboard on screen.
When a key on the screen keyboard is pressed - the appropriate key press is sent to the control in focus as if it came from the real keyboard.
This MUST happen without the focus change that usually happens when another control on the screen is pressed.
so, the question is: how do I have my on screen virtual keyboard acknoladge a mouse click by not receiving the focus, yet sending the right keypress to the control who had the focus?
If you have win2000 you can see this sort of application under accessories\accesibility\on-screen keyboard.
Thanks.
-----------------
-
Aug 14th, 2000, 10:24 AM
#2
Well you could use a timer and make a call to GetActiveWindow to store the active window handle. Then when the user click on one of your buttons call SetActiveWindow to restore the other window. When this is done you could just use SendKeys to send the key stroke.
-
Aug 14th, 2000, 10:30 AM
#3
sample code 4 keyboard ...
Use the getactivewindow API call as Joacim mentioned explained here
Sample code 4 virtual heyboard here
Hope this helps!
Alex Read
-
Aug 14th, 2000, 11:14 AM
#4
The GetActiveWindow function retrieves the window handle to the active window associated with the thread that calls the function.
-
Aug 14th, 2000, 11:21 AM
#5
Fanatic Member
Use getforegoundwindow and setforegroundwindow for all programs
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Aug 14th, 2000, 11:57 AM
#6
Thread Starter
New Member
Getting there!
Thanks.
Your answers were very helpful in getting things working.
some unfilled wishes:
A. I wish the focus didn't change back and forth. It causes the form which receives the key input to flash with every virtual keystroke, Plus some controls have lostFocus events that I'd rather didn't happen.
B. I wish I didn't have to use polling to get the active window. Is there another way to get the previously active window handle (without adding code to ever window in the application)?
C. The GetActiveWindow function only works for windows in my own appllication. What about using the virtual keyboard on other running applications (this is something I might be able to do without..)
Again - thanks for pointing in the right direction.
(Though without some more wish filling, I won't be getting very far with this)
------
-
Aug 14th, 2000, 12:04 PM
#7
Fanatic Member
for other applications use the GetForegroundWindow to get it and SetForegroundWindow to set it.
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Aug 14th, 2000, 12:15 PM
#8
Thread Starter
New Member
1 wish down. 2 to go.
Thanks gwdash.
Now I get your point.
Wish C is filled.
How about A and B. Anyone?
-
Aug 15th, 2000, 06:44 AM
#9
You could use SetWindowPos to always show your window on top of all other windows. Even when it's not having the focus.
-
Aug 15th, 2000, 07:36 AM
#10
transcendental analytic
for B
You could use GetForegroundWindow as well, just have a property that doesn't accept if the foreground window is your window.
Code:
Property Get LastWindow()
static wnd as long
if getforegroundwindow<>Yourform.hwnd then wnd=GetForegroundWindow
lastwindow=wnd
end property
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|