473,322 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Context Sensitive help by context id

If you were like me trying to figure out how to launch context
sensitive help topic by the context id, here is the link:

http://weblogs.asp.net/kencox/archiv...12/228349.aspx

and if link doesn't work, basically here is the article:

An Exploration Into Launching Context-Sensitive HTML Help with Topic
IDs in VB.NET
I spent this evening investigating the HTML Help API as implemented in
..NET. At work, I'm implementing HTML Help in a .NET 1.1 application.

It kept bugging me that I couldn't get any of the Help.ShowHelp
overloads to support context-sensitive Help that uses integers as
context/topic IDs. I'm referring to HTML Help projects that have a
[Map] section with declarations such as

[MAP]
#define HID_FIVE 5
#define HID_TEN 10

and an [ALIAS] section that turns the mapped values into topic names
like these

[ALIAS]
HID_FIVE=Topic_5.htm
HID_TEN=Topic_10.htm

When you use the HTML Help API in VB.NET, you can pass the Int32 value
to the HTML Help API (HtmlHelpA()) like this to launch a specific
topic:

Private Declare Function HTMLHelp_ContextId _
Lib "hhctrl.ocx" Alias "HtmlHelpA" _
(ByVal hWnd As IntPtr, _
ByVal lpHelpFile As String, _
ByVal wCommand As Int32, _
ByVal dwData As Int32) As Int32

Private Sub Button3_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button3.Click
Dim RetVal As Int32
Const HH_HELP_CONTEXT = &HF
RetVal = HTMLHelp_ContextId _
(IntPtr.Zero, "CHM_Checker_Help.chm", _
HH_HELP_CONTEXT, 5)
End Sub

Likewise, if you use Interop, you can launch a specific topic like
this:

<System.Runtime.InteropServices.DllImport _
("hhctrl.ocx",
CharSet:=System.Runtime.InteropServices.CharSet.Au to)> _
Public Shared Function HtmlHelp _
(ByVal hwndCaller As System.Runtime.InteropServices.HandleRef, _
<System.Runtime.InteropServices.MarshalAs _
(System.Runtime.InteropServices.UnmanagedType.LPTS tr)> _
ByVal pszFile As String, ByVal uCommand As Int32, _
ByVal dwData As Int32) As Int32
End Function

Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
Dim RetVal As Int32
Const HH_HELP_CONTEXT = &HF
Dim hr As New System.Runtime.InteropServices.HandleRef(Me,
Me.Handle)
RetVal = HtmlHelp(hr, "CHM_Checker_Help.chm", _
HH_HELP_CONTEXT, 10)
End Sub

When I looked at Help.ShowHelp in System.Windows.Forms using Reflector,
I saw that it is a wrapper around hhctrl.ocx as used in the preceding
InterOp sample. It takes diversions along the way through private
subroutines such as MapCommandToHTMLCommand and ShowHTML10Help.

But why couldn't I get ShowHelp to launch a specific topic? It seemed
like this should work:
Private Sub Button2_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button2.Click
Dim intContextID As Integer
intContextID = 10
' Doesn't work!
Help.ShowHelp(Me, "CHM_Checker_Help.chm", _
HelpNavigator.Topic, intContextID)
End Sub

Then I realized that the command value for context ID Help calls needs
to be 15 but MapCommandToHTMLCommand was unable to return the command
value of 15 when it processed any of the HelpNavigator enum values,
including HelpNavigator.Topic. As it turns out, if you hardcode 15 into
the ShowHelp routine it works!:

Private Sub Button2_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button2.Click
Dim intContextID As Integer
intContextID = 10
' This works but is slow
Help.ShowHelp(Me, "CHM_Checker_Help.chm", _
15, intContextID)
End Sub

When I compared the versions of MapCommandToHTMLCommand in .NET 1.1 and
the beta of .NET 2.0, I saw that this oversight/bug has been rectified.
The HelpNavigator enumeration in 2.0 includes a new value,
HelpNavigator.TopicId. And when MapCommandToHTMLCommand encounters it,
it now returns the value of 15 that we need.

BTW, the one thing you'll surely notice is how s-l-o-w Help.ShowHelp()
is when you open a context-sensitive topic by passing an integer. When
I get more time, I'm going to document the speed difference which
probably is caused by wrappers around wrappers and lots of Try/Catch
stuff to make sure the Help engine doesn't blow up.

Ken
Microsoft MVP [ASP.NET]

Nov 22 '05 #1
0 2419

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: | last post by:
When passing values from one page to another using context.items collection & server.transfer, how secure is this data? This is using the notion that you add an item to the context.items...
0
by: Denise L. Moss-Fritch | last post by:
Has anyone developed context sensitive help for a C# application? According to our programming staff, the development side is not able to provide links without adding hard coded links (topic names)...
10
by: chessc4c6 | last post by:
Can someone explain to me hoe both C and C++ are context sensitive??
0
by: tbatwork828 | last post by:
If you were like me trying to figure out how to launch context sensitive help topic by the context id, here is the link: http://weblogs.asp.net/kencox/archive/2004/09/12/228349.aspx and if...
0
by: ctyrrell | last post by:
Does anyone know of any restrictions of controls on Access forms that makes them ineligible for Context-Sensitive help? Are some types of controls not able to be made context-sensitive? I have...
5
by: TD | last post by:
Hey All, I am hooking up our custom html (.chm) help file to our Access xp application, and, despite reading several posts and manuals on this, I still have a gap in my understanding... OK, so...
0
by: Renee | last post by:
Hi there, does any one know how to create context sensitive help for Groupbox control with HelpProvider class? I can create context sensitive help for any control easily except for Groupbox. ...
0
by: raaco | last post by:
Hi all, It seems there is some context sensitive help when writing html, however if I do something like this Dim myDoc = AxWebBrowser1.Document Dim myCollection = myDoc.all.tags("td") I do...
0
by: Shawn K. N. | last post by:
Hi. We were able to have context sensitive help using RoboHelp for ASP applications, but now that we are using .Net our scripting is no longer working. Can someone help us find the initial scripting...
2
by: Keith Hutchison | last post by:
G'day Is it possible to do custom context sensitive menus within MS Access. If yes, does anyone have a sample example? Thanks in advance Keith
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.