![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() ![]() |
Ein Dank an Marius Greul! Er schrieb:
If you do it yourself, yes. If you choose to use Help.ShowHelp(), no.
The following should work (however, it does not...)
Help.ShowHelp(this, @"htmlhelp.chm", HelpNavigator.AssociateIndex,
"example");
Just like you would do a keyword lookup with
Help.ShowHelp(this, @"htmlhelp.chm", HelpNavigator.KeywordIndex, "zoom");
The problem itself lies in hhctrl.ocx: If you ever tried to do an A-link
lookup in a Unicode enabled application, you will notice that it does not
work as expected. According to the structure HH_AKLINK in htmlhelp.h all
strings are TCHARs. However, this is only true for the HH_KEYWORD_LOOKUP
command. If use the HH_ALINK_LOOKUP command, you always have to pass the
strings as CHARs.
The implementation of the .NET Help class does not correct for this bug.
If you use HtmlHelp in a Unicode enabled application (i.e. you use VB .NET),
you will have to create two copies of HH_AKLINK. If you use the
HH_KEYWORD_LOOKUP command, marshal the strings as Unicode. If you use the
HH_ALINK_LOOKUP command, marshal the strings as Ansi.
I'm attaching some code for C#.
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public struct HH_KLINK
{
public int cbStruct; // sizeof this structure
public bool fReserved; // must be FALSE (really!)
public string pszKeywords; // semi-colon separated keywords
public string pszUrl; // URL to jump to if no keywords found (may be NULL)
public string pszMsgText; // Message text to display in MessageBox if pszUrl
is NULL and no keyword match
public string pszMsgTitle; // Message text to display in MessageBox if
pszUrl is NULL and no keyword match
public string pszWindow; // Window to display URL in
public bool fIndexOnFail; // Displays index if keyword lookup fails.
}
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)] // must
be ANSI!
public struct HH_ALINK
{
public int cbStruct; // sizeof this structure
public bool fReserved; // must be FALSE (really!)
public string pszKeywords; // semi-colon separated keywords
public string pszUrl; // URL to jump to if no keywords found (may be NULL)
public string pszMsgText; // Message text to display in MessageBox if pszUrl
is NULL and no keyword match
public string pszMsgTitle; // Message text to display in MessageBox if
pszUrl is NULL and no keyword match
public string pszWindow; // Window to display URL in
public bool fIndexOnFail; // Displays index if keyword lookup fails.
}
[DllImport("hhctrl.ocx", CharSet=CharSet.Auto, EntryPoint="HtmlHelp")]
public static extern int HtmlHelp(HandleRef hwnd, string file, uint command,
ref HH_KLINK klink);
[DllImport("hhctrl.ocx", CharSet=CharSet.Auto, EntryPoint="HtmlHelp")]
public static extern int HtmlHelp(HandleRef hwnd, string file, uint command,
ref HH_ALINK alink);
![]() |