.CHM Help File is Displayed Topmost Over the .NET Application's Window
If you integrate a .CHM help file with your .NET application which can be written in C# or VB.NET, you might have noticed that the HTML Help's viewer window is displayed topmost over the application's window.
Using the Help.ShowHelp() Method
No matter if you have disabled the topmost option for the Main window in your help authoring tool, or pass Null or Nothing value to the Help.ShowHelp() method, it will still be show topmost.
Fortunately, there is a non-obvious yet simple solution to this problem.
Make the HTML Help (CHM) Viewer's Window be Displayed Normally
The HTML Help (CHM) Viewer's window opened by HelpProvider is always on top of the parent window control, which is specified by Control instance in the first parameter of the Help.ShowHelp() method.
As a solution to this problem, we can write a function that will create a temporary (hidden) form.
public static class AppHelp {
private static Form mFrmTemp = new Form();
public static void ShowChm() {
Help.ShowHelp(mFrmTemp, "my_help_file.chm");
}
}
How it works?
In the above solution, we create a temp form that will be used as the HTML Help's parent form. When we call the CHM help file, the HTML Help viewer will be displayed topmost over the temp form. However, now it will NOT be on top of the application's windows.
Now we can use the described method call the .CHM help in other places of the application.
That's the trick!
Comments