Click here to Skip to main content
15,040,003 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do I disable mouse and keyboard input to an application? I want the mouse and keyboard to work when the pointer is outside the application area.
Posted
Updated 10-May-10 20:50pm
v3

You can disable the window, by calling the method CWnd::EnableWindow(BOOL bEnable), this way your window will not accept any user input, both mouse and keyboard.
This approach is the easiest one, but it make your window not able to process any kind of user interaction: you will be not able to minimize the window to the taskbar, to move the window by dragging its title bar, and so on.
If your window is dialog based and your target is to disable all the controls on the client area of the window, the best solution is to place all the controls on a child window (i.e. declared as WS_CHILD and without title bar nor border) then place that child window on the client area of your main window and then enable/disable the child window. This way the user will be not able to interact to the controls on the window, but he will be able to move the window on screen, minimize and maximize it, and so on.
   
The statements above seem to conflict with each other. If you disable the mouse and keyboard it cannot work inside or outside. Please try and reword your question.
   
The easiest way is putting up a modal dialog with the main window as it's parent. This will automatically disable the main window. How you will paint yourself out of this corner, though...
I'm kidding... just disable the main window yourself, and I suppose you have a mechanism for re-enabling it when needed.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900