Archived

This topic is now archived and is closed to further replies.

Roof Top Pew Wee

Multiple Window Keyboard Association?

Recommended Posts

I am writing a program which has multiple windows, each with their own handles (G.hWnd, G.hWnd2, G.hWnd3, and so on). Well, I would like to have all the windows be able to recieve input from the keyboard. However, to set up the keyboard with DirectInput, you have to do the following: G.lpDIKeyboard->SetCooperativeLevel(G.hWnd3, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE); The first argument is a handle to a window, and I have only been able to get the keyboard to work with that specific window. Is there anyway to pass multiple handles to this function, or does anyone know of another method to do this, such as calling a function that lets you add windows to the object? If this is not possible, is the only way to get multiple windows to recognize the keyboard by creating multiple directInput objects? Thanks for any help. --Vic--

Share this post


Link to post
Share on other sites
this isn''t EXACTLY an answer to your problem, but:
you could put code in your program so that whenever you get keyboard input with the one window, it passes it on (if relevant) to the other ones.

--- krez (krezisback@aol.com)

Share this post


Link to post
Share on other sites
Krez:

Oops, I must not have stated this specifically, but as in the case I stated above, where I pass G.hWnd3 as the first argument to the SetCooperativeLevel function, the only time the keyboard is read is when whatever window G.hWnd3 is a handle to is activated. So if say I have G.hWnd, G.hWnd2, and G.hWnd3 on the screen, if I click on the window represented by G.hWnd2, then input is no longer read. That way, your suggestion won''t work. Any other ideas anyone?

--Vic--

Share this post


Link to post
Share on other sites
You can make DI process input events even if the window it is attached to is in the background. Use the DISCL_BACKGROUND flag in your call to SetCooperativeLevel instead of DISCL_FOREGROUND (background here means "foreground *and* background").

I know this doesn''t exactly answer your question, but you could use krez'' method if you set your cooperative level like this.

Share this post


Link to post
Share on other sites
When it comes to stuff that''s not direct to the game (EG. graphics) I try to get by with as little learning as possible. I don''t know how to do child windows, nor do I want to redo my whole program, so I think I''ll stick to doing the Foreground/background thing. This should fix it.
Thanks

--Vic--

Share this post


Link to post
Share on other sites