Wednesday, May 16, 2007

Help not always on top!

Today I was asked whether it was possible to show the help in a non-modal manner. After a little searching on the internet, I found the following solution, posted in a forum by Rodger Constandse. It's a little trick but it works faboulous:

Create a new Form (once for an application). Call CreateControl() on it in order to create a handle to it, but it will not show up. See the following code-example:

public class MyApp
// Create a form as the parent for the Help window.
private Form m_HelpFormParent = new Form();

public MyApp()
// Enforce creation of a handle to the form

public ShowHelp(string url, HelpNavigator command, object parameter)
// Call ShowHelp with the form created for this purpose as parent
Help.ShowHelp(HelpFormParent, url , command , parameter );


Praveen said...

Dear Jan,

I tried the same and its not working for me. What trick I am missing in this?


Jan van de Pol said...

Dear Praveen,

Which part is not working? Is the help showing up at all? Or is it still modal? Can you post the (relevant) code?

Best regards,

Anonymous said...

Kudos to the author of this article. This works by allowing the main screen of my application (MyApp) to become the top level window. But, if you have your help open when a modal dialog opens (using ShowDialog), the help goes to the background. If you try to click on the help window, it causes the dialog's title bar to flash and the help screen is inactive. It does not receive mouse clicks. To help, you will need to make your dialog modal. I tried to close the help window before activiating the dialog, but could not find the process in my task manager nor in the Process class. It seems the only way to close the help from your program is by closing the program. Does anyone out there know how we can control and close the help window from within our application?

Mike Garrett said...

Awesome, that works a treat!! Thanks for your help!!