Display Custom Help in .NET

Display Custom Help in .NET

Sinc
Advisor Advisor
1,667 Views
10 Replies
Message 1 of 11

Display Custom Help in .NET

Sinc
Advisor
Advisor
I'm trying to add custom help to a C#.NET application. The first thing I'm trying to do is add a "Help" button to a dialog box, similar to those found throughout Autocad.

I added a button handler that uses a line like the following to attempt to display the help topic:

Help.ShowHelp("MyCustomHelp.chm", "CustomHelpTopic.htm");

However, I can only get it to work if I include the complete path to the .chm file. Naturally, I do not want to hardcode this path, so I'm guessing I need to find the .chm file, then get the full pathname to the file and use that in the call to ShowHelp(). Is this what I need to do, or is there a simpler way?

Also, how should I go about getting it so that the correct help file is displayed when the user hits F1 after running one of my custom .NET commands? In other words, do the equivalent of the SHOWFUNHELP command from AutoLisp?
Sinc
0 Likes
1,668 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
For AutoCAD extensions, I usually use the Location
property of the app's running Assembly to find other
related files.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:[email protected]...
I'm trying to add custom help to a C#.NET application. The first thing I'm trying to do is add a "Help" button to a dialog box, similar to those found throughout Autocad.

I added a button handler that uses a line like the following to attempt to display the help topic:

Help.ShowHelp("MyCustomHelp.chm", "CustomHelpTopic.htm");

However, I can only get it to work if I include the complete path to the .chm file. Naturally, I do not want to hardcode this path, so I'm guessing I need to find the .chm file, then get the full pathname to the file and use that in the call to ShowHelp(). Is this what I need to do, or is there a simpler way?

Also, how should I go about getting it so that the correct help file is displayed when the user hits F1 after running one of my custom .NET commands? In other words, do the equivalent of the SHOWFUNHELP command from AutoLisp?
0 Likes
Message 3 of 11

Sinc
Advisor
Advisor
I've discovered that the following will correctly display my help file:

Autodesk.AutoCAD.ApplicationServices.Application.InvokeHelp("MyCustomHelp.chm", "CustomHelpTopic");


Note that I omit the ".htm" from the topic name. This seems to work.

Now for the other part. I would expect it to be implemented similar to the way commands are defined, by including a directive like this in the code:

[CommandMethod("MYCOMMAND")]

I would expect to link a help file to the command in some similar way. But I'm still fumbling in the dark for this one.
Sinc
0 Likes
Message 4 of 11

Sinc
Advisor
Advisor
And in fact, I do see that I can add more attributes to that CommandMethod directive.

Unfortunately, I have not been able to find any documentation describing the attributes. I see the documentation for the CommandMethodAttribute class, but it isn't very helpful - all it does is list the class members, without describing any of the members or providing any examples. What exactly are "GroupName" and "LocalizedNameId"? And the one that's really throwing me is the ContextMenuExtensionType - what exactly should I do with this?
Sinc
0 Likes
Message 5 of 11

Anonymous
Not applicable
You need to delegate to the native ObjectARX docs
in many cases, because most things (including the
ones you mention here) are simply exposing the
equivalent native functionality that is described in
great detail in ObjectARX docs.

ContextMenuExtensionType is the type of a class that
derives from ContextMenuExtension. If you give it a
type, the runtime creates an instance of it and uses
it to extend the right-click context menu that appears
while your command is active.

The GroupName is the name of the command group
the command belongs to (see the native ObjectARX
docs for what a command group is).

The LocalizedNameId is the string resource identifier
of the localized name of the command. If provided,
the localized name of the command is obtained from
the resource, which can be stored in a locale-specific
satellite resource assembly.

If you set the HelpFileName and HelpTopic properties
of the CommandMethod attribute, does AutoCAD show
your help when your command is active?


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:[email protected]...
And in fact, I do see that I can add more attributes to that CommandMethod directive.

Unfortunately, I have not been able to find any documentation describing the attributes. I see the documentation for the CommandMethodAttribute class, but it isn't very helpful - all it does is list the class members, without describing any of the members or providing any examples. What exactly are "GroupName" and "LocalizedNameId"? And the one that's really throwing me is the ContextMenuExtensionType - what exactly should I do with this?
Message 6 of 11

Sinc
Advisor
Advisor
So far, I haven't been able to get it to work. The only method signature that lets me pass the helpfile name and helpfile topic also requires me to pass in all those other parameters. And whenever I try, I get "Command not found" errors when I try to run the command from within Civil-3D. If I specify nothing but GlobalName, my command works fine, but as soon as I try to specify all those other parameters, I get nothing.

So something is wrong, but I haven't been able to figure it out yet. I get no error messages. Do I need to pass an actual type to that ContextMenuExtentionType argument, or is there some sort of null value I can use?

And I must be looking in the wrong place. I have downloaded the 2008 ObjectARX documents, but could find no greater detail there. Maybe I just need to look through them more.
Sinc
0 Likes
Message 7 of 11

Anonymous
Not applicable
This should work:

[CommandMethod(
"MYGROUP",
"MYCOMMAND",
null, // localizedNameId
CommandFlags.Modal,
null, // ContextMenuExtensionType
"MyHelpFile.chm",
"myhelptopic"
)]


You can use anything for the group (first argument).

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:[email protected]...
So far, I haven't been able to get it to work. The only method signature that lets me pass the helpfile name and helpfile topic also requires me to pass in all those other parameters. And whenever I try, I get "Command not found" errors when I try to run the command from within Civil-3D. If I specify nothing but GlobalName, my command works fine, but as soon as I try to specify all those other parameters, I get nothing.

So something is wrong, but I haven't been able to figure it out yet. I get no error messages. Do I need to pass an actual type to that ContextMenuExtentionType argument, or is there some sort of null value I can use?

And I must be looking in the wrong place. I have downloaded the 2008 ObjectARX documents, but could find no greater detail there. Maybe I just need to look through them more.
0 Likes
Message 8 of 11

Sinc
Advisor
Advisor
Ah, OK, it was just the compiler trying to be helpful. Whenever I would try to type "null" for the ContextExtensionMenuType, it would helpfully change it to "Nullable" for me. I managed to use "null" despite the compiler's help, and now my command works again.

Unfortunately, the help function does not work. When I hit F1 after running the command, I get the Search tab of the default Autocad help, and not the help for my command.
Sinc
0 Likes
Message 9 of 11

Sinc
Advisor
Advisor
Well, that's interesting. It appears that I can't get ANY context-sensitive help at all.

I even tried using default Autocad commands, and starting up Land Desktop 2007 and trying to get context-sensitive help there. Nothing. Every time I hit F1, I get the Search tab of the default Civil-3D or Land Desktop help.

We ARE supposed to be able to do that, right? Run a command, hit F1, and see the help file for the command we just ran? I know it used to work like that in 2004...
Sinc
0 Likes
Message 10 of 11

Sinc
Advisor
Advisor
OK, I found that hitting F1 while the command is active calls up the correct help file. Obviously, I don't use this method of invoking help very often. I had been thinking it did the same thing even after the command had finished running, but evidently not.

So I guess it is working. Thanks, Tony.
Sinc
0 Likes
Message 11 of 11

Anonymous
Not applicable
The help information associated with a commandmethod
attribute is for automating access to help for that command,
while the command is in progress 🙂

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:[email protected]...
OK, I found that hitting F1 while the command is active calls up the correct help file. Obviously, I don't use this method of invoking help very often. I had been thinking it did the same thing even after the command had finished running, but evidently not.

So I guess it is working. Thanks, Tony.
0 Likes