I am setting up a simple ‘boot menu’ for my app, where the (experienced) user can check or uncheck various run options. The boot menu is a simple borderless form shown modally and with
- Quit button
- Continue button, as well as
- boot options checkboxes
I display this boot option dialog as I am starting my app if the user is holding the F8 key – I’ve discovered that Windows does not use F8, so you can actually hold down F8 while clicking on a shortcut to my exe and my boot dialog opens. Herein lies the probem.
My form does not become the active application – rather the Explorer window hosting the shortcut that I clicked on does. If I click on my form (boot dialog) it gets the focus. How can I make my boot dialog form ‘pull’ Windows into focusing it?
In general you cannot take focus. From Raymond Chen’s Old New Thing blog:
The problem is that the user has been giving input to a program that is not yours. You’re not entitled to have focus just cause you want it.
It may not be the answer you want, but it is the answer. And Microsoft has been working hard to thwart programs that try to steal focus. Any solution you come up with is breaking the rules, and might not work at any point in the future.