Click here to Skip to main content
16,015,623 members
Home / Discussions / Windows Forms
   

Windows Forms

 
GeneralRe: datagridview problem Pin
John_Adams15-Jan-08 23:05
John_Adams15-Jan-08 23:05 
GeneralRe: datagridview problem Pin
Naresh12345678916-Jan-08 20:40
Naresh12345678916-Jan-08 20:40 
GeneralRe: datagridview problem Pin
Naresh12345678919-Jan-08 0:07
Naresh12345678919-Jan-08 0:07 
QuestionHow to implement a usb hub driver? Pin
qiulin682215-Jan-08 14:24
qiulin682215-Jan-08 14:24 
AnswerRe: How to implement a usb hub driver? Pin
LongRange.Shooter1-Feb-08 9:48
LongRange.Shooter1-Feb-08 9:48 
QuestionHow to Call SSIS Package From Asp.net With C# Pin
mrgaddam14-Jan-08 18:15
mrgaddam14-Jan-08 18:15 
AnswerRe: How to Call SSIS Package From Asp.net With C# Pin
Pete O'Hanlon15-Jan-08 9:49
mvePete O'Hanlon15-Jan-08 9:49 
QuestionHow to determine Win32 API Window States like "covered by a modal sub window" or the "active parent window" via Win 32 API [modified] Pin
schwiemn14-Jan-08 11:38
schwiemn14-Jan-08 11:38 
Application Wide Central Hotkey Filter based on Win 32 API Hooks

I have written a central hotkey manger prototype (see describtion below the question) for a complex MDI Application (child windows / subwindows are loaded via COM and other technologies). A simple Win 32 API hook (e.g. WH_KEYBOARD_LL) based filter (written in C# but that does not matter - could also be C/C++) replaces a lot of keyboard event forwarding code in an applications sub windows written in many different languages (as they are plug-ins etc.) and you no longer have to deal with different keyboard event management concepts in the different UI Frameworks used.

But I have two problems (the cases A and B below) as I am not a Win32 API Expert.

----------
QUESTION

I would be grateful for any ideas about how the states/cases below can be determined !easily! via Win32 API, without having to change the code of the sub windows.

A) "covered by a modal sub window"
I have to know (without changing the code of the modal dialog) when in the context of the main window (to that hotkeys are forwarded) a modal child window / dialog is opened (and closed), because the hotkey filter shall not filter any keyboard events (event when hotkeys) in the context of modal dialogs.

B) active parent window
You can think of cases, when there are several “main windows” ("main" means: windows that receive hotkeys and can have child windows)
that receive application wide hotkeys (but each main window belongs to a different sub tree in the window hierarchy), all main windows distinguished by their win32 API handles. The handles of the main windows are known to the hotkey manager, but not the sub windows.

Main Window A --child--> SubWindow2 … --child--> SubWindowFocus
Main Window B --child--> SubWindow3

When “SubWindowFocus” has the Focus each keyboard event reaches the same Hotkey Manager via the keyboard hook, the hotkey manager only knows (handles) A and B.
Is it possible to determine the appropriate Main Window (A would be correct) via Win32 API? In that context the event was raised.

-----
PROTOTYPE – Application Hotkey Filter

I am actually developing a “hotkey manager” that works in a complex environment (i.e. the main system and main windows are written in smalltalk or c++ and there are lots sub windows (i.e. plug-ins and add-ons) implemented in Java, .NET, VisualBasic …
Regarding the forwarding of not consumed keyboard events from the sub windows to the main windows there are many bugs and problems (some framework related or COM related) in order to get rid of all these problems I have written a central hotkey manager (filter) that attaches itself to each relevant event dispatching thread of the application.

The manager uses a Win 32 API keyboard hook (a local hook) that filters all keyboard events before the reach the sub windows, the filter than redirects hotkeys directly to the main window instead of relaying on the sub windows to forward them. Non-hotkeys go the normal way.

My code is actually quite ugly (prototype) so it makes no sense to post it (i will write a hotkey filter article when finished) - if you are interested in this topic see the codeproject article (this a global hook, i used a local one) on that my solution idea is based:

http://www.codeproject.com/KB/system/CSLLKeyboard.aspx

Best regards,
Martin Schwienbacher

modified on Tuesday, January 15, 2008 4:59:15 AM

QuestionA Beginners Thread Pin
bharathi_n_r11-Jan-08 20:16
bharathi_n_r11-Jan-08 20:16 
GeneralRe: A Beginners Thread Pin
Abhijit Jana13-Jan-08 1:19
professionalAbhijit Jana13-Jan-08 1:19 
GeneralRe: A Beginners Thread Pin
LongRange.Shooter1-Feb-08 9:50
LongRange.Shooter1-Feb-08 9:50 
QuestionHow to remotely connect multiple PCs(Windows OS based) computers from a single Mac Pin
ctrlnick11-Jan-08 7:16
ctrlnick11-Jan-08 7:16 
AnswerRe: How to remotely connect multiple PCs(Windows OS based) computers from a single Mac Pin
LongRange.Shooter1-Feb-08 9:52
LongRange.Shooter1-Feb-08 9:52 
QuestionHow to control attribute initialization order for controls? Pin
RichardM110-Jan-08 11:32
RichardM110-Jan-08 11:32 
AnswerRe: How to control attribute initialization order for controls? Pin
Patrick Etc.10-Jan-08 12:23
Patrick Etc.10-Jan-08 12:23 
GeneralRe: How to control attribute initialization order for controls? Pin
RichardM110-Jan-08 12:29
RichardM110-Jan-08 12:29 
GeneralRe: How to control attribute initialization order for controls? Pin
Patrick Etc.10-Jan-08 12:31
Patrick Etc.10-Jan-08 12:31 
GeneralRe: How to control attribute initialization order for controls? Pin
RichardM110-Jan-08 12:48
RichardM110-Jan-08 12:48 
QuestionHow to comunicate between two Windows Forms in BOTH directions???? Pin
szymon7910-Jan-08 8:12
szymon7910-Jan-08 8:12 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
Dave Kreskowiak10-Jan-08 10:36
mveDave Kreskowiak10-Jan-08 10:36 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
szymon7910-Jan-08 10:57
szymon7910-Jan-08 10:57 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
RichardM110-Jan-08 11:19
RichardM110-Jan-08 11:19 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
szymon7910-Jan-08 11:43
szymon7910-Jan-08 11:43 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
RichardM110-Jan-08 12:13
RichardM110-Jan-08 12:13 
GeneralRe: How to comunicate between two Windows Forms in BOTH directions???? Pin
Luc Pattyn10-Jan-08 12:14
sitebuilderLuc Pattyn10-Jan-08 12:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.