Displaying Keyboard Input from Parent Window to Child Window

From Visual Basic to GNU C, this is the place to talk programming.

Moderators: SecretSquirrel, just brew it!

Displaying Keyboard Input from Parent Window to Child Window

Postposted on Mon Mar 08, 2004 10:50 pm

I've gotten some good help here in the past so I'll ask another question.

I have my app with three splitter child windows set up in it....

I want to be able to launch my app, press a key, say F, and then have it display F in one of the child view windows....

I would assume this can be accomplish through OnChar or something in my MainFrm class (MainFrm is the main frame in which all my child frames are created).....
OutlawTornNMT
Gerbil First Class
 
Posts: 148
Joined: Sun Jul 21, 2002 5:30 pm

Postposted on Wed Mar 10, 2004 11:51 am

If you place a CEdit control in the child splitter window you want to type in then just give that control focus when the app initializes you should be able to accomplish what you want.
Veritas
Gerbil First Class
 
Posts: 113
Joined: Wed Dec 26, 2001 7:00 pm
Location: Houston, TX

Postposted on Wed Mar 10, 2004 12:08 pm

What language are you using... sounds like VB? Which version?
UberGerbil
Gerbil Khan
 
Posts: 9976
Joined: Thu Jun 19, 2003 3:11 pm

Postposted on Wed Mar 10, 2004 5:05 pm

I think he is using VC++ based on his other posts.
Veritas
Gerbil First Class
 
Posts: 113
Joined: Wed Dec 26, 2001 7:00 pm
Location: Houston, TX

Postposted on Thu Mar 11, 2004 2:22 am

Ah, you're probably right. The reference to "forms" threw me... but of course in C++ .NET you have the managed libraries, which have forms. Haven't done any mixing of C++ with .NET yet, though I find C# is quite nice.

In the .NET forms package, if you look at your form you'll find it has a "KeyPreview" property. Set that to True. Your form should see key events prior to any control (in other words, no matter which control on that form has the focus, when a key is pressed the form will see the key first, and then the control). You can then write whatever centralized key handling code in the appropriate event (keydown, keypress, keyup) for the form. You could get the same effect by attaching the same delegate to the keyevents for each control, but that's more work.
UberGerbil
Gerbil Khan
 
Posts: 9976
Joined: Thu Jun 19, 2003 3:11 pm


Return to Developer's Den

Who is online

Users browsing this forum: No registered users and 3 guests