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
m_HelpFormParent.CreateControl();
}

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 );
}
}