We help IT Professionals succeed at work.

Implement Context Sensitive .chm help in C#

Sheritlw
Sheritlw asked
on
I have another question out there with no answer yet.  The other question is Showing Help .chm and Topic ID.  
I need sample code to successfully implement a .chm help file into a C# program.  When users click a button, I detect what form is currently active and then want to launch the help file Topic ID associated with the form.
I have two questions, both are worth 500 points.  Put the correct answer in both questions and it will be worth 1000 points.
Comment
Watch Question

Commented:
I am not sure that you are alllowed to ask 2 same questions in the hope of giving more points to experts.  It doesn't mean that much to me as I am not after points :-)

Have a read at these

http://www.helpscribble.com/dotnet.html

This one is for VB but I think there is not much code involved when setting up context sensitive help

http://support.microsoft.com/default.aspx?scid=kb;en-us;821777

Good luck

Commented:
Sorry, the first url requires that you buy a product.  I didn't notice it before.  If you have a .chm file ready I can try to implement the c# code if you send me the help file.  post it to ee-stuff

Author

Commented:
What is ee- stuff?

Author

Commented:
I found the ee-stuff and uploaded the eQualify.chm
Thanks so much for your help

Commented:
You need to post the url of where you posted the file so I can get it.  Plus I am going home now it 18:05 here, will carry on tomorrow though.

Author

Commented:
ok, will look at it.  
Thanks again

Commented:
I have time now to try this.  Can you post the url, otherwise let me know if you have found an answer in the other question.

Author

Commented:
I couldn't figure out the URL.   I uploaded the file with the title of the project Implement Context Sensitive .chm help in C#.  I was going to upload another one, but couldn't see where I could get the URL.  
I have not found a solution, although I've been trying for days.  If you have any idea on how to upload and get the URL, I will do again.
Thanks,
Sheri
 

Commented:
When you upload the file, the URL should be in the Browser address box - I think - I haven't done this for awhile.

Commented:
I tried searching but I can't find your file.  try logging into ee-stuff, do you get list of files you uploaded?

Author

Commented:
There is a file there, but it is not mine or from my user name.  Can I email the file to you?
Sheri

Commented:
sure hassan dot hussain at dbt dot co dot uk

Let me have some topic numbers too to test

Author

Commented:
sent, did you get?

Commented:
Got it, working on it.

Author

Commented:
great thanks.  It's 4 here so I am going to get some sleep.  
Thanks again
Sheri

Commented:
Don't yet.  I have an answer for you

Commented:
It is simple!  no need for help provider or all that.

In your button click just add this

            Help.ShowHelp(this, @"C:\Solutions\eQualify.chm", HelpNavigator.TopicId, "1030");

And that is it.  Just change the path to file to your correct path and the 1030 topic id for the correct topic

Author

Commented:
You are great!!!
This is what I've got thus far.
 
string sPath;
      sPath = Application.StartupPath + "\\eQualify.chm";
      Help.ShowHelp(this, @sPath, HelpNavigator.TopicId, "1030");

Now how do I tell in a MDI application what form has focus or should I make another question?

Sheri

Commented:
Sorry, was not at work and still not.  What you need is

this.ActiveMdiChild

See explanation here

http://msdn2.microsoft.com/en-us/library/4s6dtf7z(VS.80).aspx

Commented:
If I understand your problem correctly, maybe you should have a method like this

Commented:
 In your MID Parent form put the method below then in your button click you can replace
Help.ShowHelp(this, @sPath, HelpNavigator.TopicId, "1030");

with

Help.ShowHelp(this, @sPath, HelpNavigator.TopicId, GetActiveFormTopicID);
   

        private string GetActiveFormTopicID()
        {
            if (this.ActiveMdiChild != null)
            {
                switch (this.ActiveMdiChild.Name)
                {
                    case "Form2": return "200";
                    case "Form3": return "300";
                    default: return string.Empty;
                }
            }
            else
                return string.Empty;
        }

Commented:
You will obviously channge Form2 and Form3 etc to your actual form names.  you could use form caption/text instead of form name.

Commented:
Don't know if you still have a problem with this but I noticed that in my comment

Help.ShowHelp(this, @sPath, HelpNavigator.TopicId, "1030");
should be
Help.ShowHelp(this, sPath, HelpNavigator.TopicId, "1030");

and

Help.ShowHelp(this, @sPath, HelpNavigator.TopicId, GetActiveFormTopicID);
should be
Help.ShowHelp(this, sPath, HelpNavigator.TopicId, GetActiveFormTopicID);

Remove the @ character

Explore More ContentExplore courses, solutions, and other research materials related to this topic.