views:

710

answers:

2

I want to set focus to an MDI Parent Form when I click on the background of the form. However, the only way I can get it to set focus is when I resize the form.

I have tried using mouse click event, click event, key press event etc to manually set the focus when you click on the MDI Parent but none of these events fire. Is there ANY way to set the focus to the MDI Parent when you click on the background of the form?

+1  A: 

That background is a separate control, try to find it in MainForm.Controls and assign it's click event.

Henk Holterman
+1  A: 

You may want to look at the Win32 WM_MDIACTIVATE message. Now that we've discussed a possible solution, the real question can begin:

I think you should look long and hard at what your trying to accomplish. You risk (not necessarily will, but risk) creating a behavior that is abnormal and confusing to users. Why do you want to move the focus? What will you once it gets moved? How will you indicate to the user that this has been done? How will then get out of this state?

csharptest.net
Basically, I'm using Janusys UI Suite. And the UIPanelManager is awesome. But, my users are complaining that the pop outs are too sticky, you can't just click anywhere to make them pop back in - anywhere being the MDI Parent. They want to click on the background of the MDI Parent to auto hide the pop out panels. Thank you Henk, for the life of me I couldn't figure out how to set the focus on click, and I already tested and confirmed what you wrote.