J
James Hancock
In case any of you have been as frustrated with the Help implimentation in
..NET as me, here's a way around the stupidity of using the current window as
the parent for the help window (yes, you can't go back and forth and look in
the help file and then do what it says in the program! That would be to damn
easy!).
I found the best possible way to do all of this stuff. You could extend this
to handle events etc. if you wished but this is all I needed.
Here's all you need:
[DllImport("hhctrl.ocx", CharSet=CharSet.Auto, SetLastError=true)]
static extern IntPtr HtmlHelpW(
IntPtr hwnd,
string HelpFile,
int Command,
int TopicID);
[DllImport("hhctrl.ocx", CharSet=CharSet.Auto, SetLastError=true)]
static extern IntPtr HtmlHelpA(
IntPtr hwnd,
string HelpFile,
int Command,
int TopicID);
[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
static extern IntPtr GetDesktopWindow();
private const int HH_DISPLAY_TOC = 0x0001;
private const int HH_DISPLAY_INDEX = 0x0002;
private const int HH_DISPLAY_SEARCH = 0x0003;
private const int HH_DISPLAY_TOPIC = 0x000;
So you would call it like this:
if (System.Environment.OSVersion.Platform == System.PlatformID.Win32NT) {
HtmlHelpW(GetDesktopWindow(), "help.chm", HH_DISPLAY_TOPIC, 342342);
} else {
HtmlHelpA(GetDesktopWindow(), "help.chm", HH_DISPLAY_TOPIC, 342342);
}
GetDesktopWindow() forces it to be bound to the desktop so no stupidity.
The A is for Win9x and the W is for NT. (obviously)
If anyone is interested, I'll write up a small class.
James Hancock
..NET as me, here's a way around the stupidity of using the current window as
the parent for the help window (yes, you can't go back and forth and look in
the help file and then do what it says in the program! That would be to damn
easy!).
I found the best possible way to do all of this stuff. You could extend this
to handle events etc. if you wished but this is all I needed.
Here's all you need:
[DllImport("hhctrl.ocx", CharSet=CharSet.Auto, SetLastError=true)]
static extern IntPtr HtmlHelpW(
IntPtr hwnd,
string HelpFile,
int Command,
int TopicID);
[DllImport("hhctrl.ocx", CharSet=CharSet.Auto, SetLastError=true)]
static extern IntPtr HtmlHelpA(
IntPtr hwnd,
string HelpFile,
int Command,
int TopicID);
[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
static extern IntPtr GetDesktopWindow();
private const int HH_DISPLAY_TOC = 0x0001;
private const int HH_DISPLAY_INDEX = 0x0002;
private const int HH_DISPLAY_SEARCH = 0x0003;
private const int HH_DISPLAY_TOPIC = 0x000;
So you would call it like this:
if (System.Environment.OSVersion.Platform == System.PlatformID.Win32NT) {
HtmlHelpW(GetDesktopWindow(), "help.chm", HH_DISPLAY_TOPIC, 342342);
} else {
HtmlHelpA(GetDesktopWindow(), "help.chm", HH_DISPLAY_TOPIC, 342342);
}
GetDesktopWindow() forces it to be bound to the desktop so no stupidity.
The A is for Win9x and the W is for NT. (obviously)
If anyone is interested, I'll write up a small class.
James Hancock