How to prevent program losing focus?

  • Thread starter Thread starter Morten Wennevik
  • Start date Start date
M

Morten Wennevik

I'm pretty sure this has been mentioned a few times, but so far I haven't
found anything.

I am trying to "lock" a program to always focus, non closable etc, but
overriding OnDeactivate and calling Activate() only works 1 time, and
never again. After the initial refocus it never seems to fire. What else
needs to be done?

Is it possible to just cancel a deactivation completely?
 
Hi Morten,
Well, to start with, it's better to use web form in that case. You will need
to customize your control, through html editing. Normally, there are no drop
down lists available when editing your control, but you can use "Item
Template" to create a control similar to the combo box. As for the test box,
there is this option when editing html to create your control.
 
You can handle the "Validating" event. Set the control's property of "Causes
validation" to true, as well as the control that follows. And repeat that
for every other control. And, on the Validating eventhandler, set the
CancelEventArgs.Cancel=True;

This will keep the control focused, disallowing that you lose focus. You can
do the same thing to the whole form, or any button on it.
 
I'm afraid web would not be an option as I am going to use some intricate
userinteracted controls which I'm not sure would work in a web page.

As for the validating, it still allows other programs to get focus
(ALT-TAB) :(
 
Except there are cases when the user for good reasons should not have
control of the application. Not to mention that there are several such
programs around already.
 
Back
Top