Link to home
Start Free TrialLog in
Avatar of Lescha
Lescha

asked on

Help in Dialog-Based Application

I have a Dialog-based MFC application. I want to add a good help to it. So I'd appreciate a thorough algorithm on the following points:

1) How do I write a text file for a Help? How do I divide it into sections, mark links, etc.?

2) How do I compile that file? What output files will I get?

3) How do I embed the help into the program? What functions do I use and how -exactly- do I use them?

I would only accept and grade an answer that I can follow step-by-step; on the other hand, I give this question many points and will grade it as 'excellent'.
Avatar of vattal
vattal

While creating the project in the App Wizard check the option "Generate Help" in the 2nd or 3rd step. This will give u a .rtf file, .hpj file, .hlp file. etc
Build u r project. This will create a default help files.
Open ur rtf file in word and add ur text there. After this I can tell u about links, adding footnotes, context sensitive help and compling in Help Workshop etc
I will continue after u finist this

Adarsh S
i think the html help file is better for you.

if you work with VC6, the HTML help workshop and front page express will make you create help file easyly.
Avatar of Lescha

ASKER

For "vattal": my application is almost ready, I don't want to re-create it. How do I add the help files you mentioned at this stage?

Avatar of Lescha

ASKER

For "wyy_cq": Ok, HTML sounds good. But how do I embed it into the program once it's ready? (I need to somehow display the topics upon pressing F1 in different parts of application). Also: will it require using a web browser for the users of my application? If so, it's no good. If not, how will it work?
ASKER CERTIFIED SOLUTION
Avatar of Anchaneya
Anchaneya

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I've an answer for Lescha!!
If you want a help file to be incorporated into an existing project follow the steps below!
BTW...pls. note that its a bit roundabout way and laborious method too!
If you are ready for that please do the following!
1. Create a dummy proj with help option enabled as "vattal" told!
2. Copy the /hlp dir into ya project directory.
3. Change the names of the .hlp,.cnt,.hm, .hpj, .log to the required project name
4. Open the .cnt file in the notepad and change the
":Base ---.hlp" to ":Base projname.hlp"
Note: If you don't do that the help file on the execution will not have a contents tab in the help dlg at all!
5. Copy the .cnt and .hlp to ya debug dir
6. Go to the Menu IDR_MAINFRAME and add a menu item for help
with "Help Topics" as description and id as "IDC_HELP" or something!
7. Go to the CMainframe.cpp and declare four message maps.
ON_COMMAND(ID_HELP_FINDER, CMFrameWnd::OnHelpFinder)
ON_COMMAND(ID_HELP, CMFrameWnd::OnHelp)
ON_COMMAND(ID_CONTEXT_HELP, CMFrameWnd::ContextHelp)
ON_COMMAND(ID_DEFAULT_HELP, CMFrameWnd::OnHelpFinder)

Note: If you don't do that you will not get the help at all though you may have .hlp and .cnt!
8. Open the .hpj in the "hcw" and click at MAP button and remove the #include of previous proj and include the current proj.hm. Do not forget to include \..\...\ProgrameFiles\...\AfxHelp.hm.
Note: If you don't do that then you'll get an error saying AfxHelp.hm is not found!
9. Verify whether Options, Files, MAPs are ok according to the current proj or not.
10. save and Compile the hpj.
11. Now you should be able to run the help on the click of the button!!
Heyyy !! There is one more thing! If you do the above steps then you need to separately write the help file and compile again and again and put the .hlp and .cnt in the debug & parent directory

If you wanna make ya proj itself compile the help juz like any other proj as though you had pressed the options mentioned like "vattal" you need to do one more thing!!

You need to Open the .dsp file in the notepad and edit ya dsp file !!!!!
Do the following for that!!
Open ya test proj .dsp and origproj.dsp in the notepad and find the code that compiles the help, cut, copy paste that code into ya project !! U R READY FOR THE SHOW!

Have a nice time doing help!
I assume that you know how to work in the rtf file! If you don't please let me know!!!
THIS HAS TO WORK....!!!! YOU OWE ME A PAAARTTTEEEYYY !!!!
Rgds,
Anchaneya

Avatar of Lescha

ASKER

Anchaneya,

my application is dialog-based, not SDI or MDI. Could you please re-phrase the 6&7 of your answer for a dialog-based application? Thanks.

And also - what is "hcw"?
Buddy!
I'm xtremely sorry! I forgot that you were in Dialog Based Application.
No 6 will be nothing but a button with caption "Help" and ID as "ID_HELP" !
No 7 will be nothing but the same message handlers but that will call the base class's help functions like CDialgo::OnHelp(), CDialog::OnHelpIndex() etc.
Note: For context sensitive help for each ID you need to generate HIDs for all IDs that you wanna provide Help thru HM!
Lastly, "hcw" is "help workshop!". You don't need to do anything other than juz dbl clk on hpj file. You will get hcw automatically.
I hope I added some sense!
Rgds,
Anchaneya
Avatar of Lescha

ASKER

Anchaneya,

things are becoming clearer, IOU1 ;)

Three things:

1) What/how should I write in .rtf? Are the changes updated automatically when I compile the .hpj?

2) I tried to edit the .dsp as you said but it refused to load it into the Visual Studio. ;( Oh well, it's not really a problem, I'll just copy the files every time I update them.

3) The 'OnHelp' MSDN topic says something about 'help context associated with current dialog'. How do I do that? How do I actually tell the program which help topic to display?

Please notice I increased the points for the question.

Yura
Yura,
Actually ya increased points are very very less for the Qns that you've asked yaar..!Anyway, I'll write the answer for that! If U R :-)) then I'm :-)))) too!

I'll attack ya Qns from the bottom as the first Qn need more expln!

3) If you follow my "note:" of my yesterday's answer you shldn't be having a problem to include a help for a particular dialog. U needa generate HIDS in the .HM file and Have a footnote with the same HID in the .rtf file too!! If you wanna help topic covered for a dlg, you need to have a help topic for the dialog box and capture the gif of that dlg it in the .rtf file! Then you shld have the handler for "OnHelp" I mean..ON_CMD(ID_HELP..)
The Appln takes care of converting ya pressing 'F1' on the Dialog takes you to the corresponding Help topic!

2. No! If you edit a dsp file in the notepad and save it, it shldn't give any problems at all! App might ask a question for loading a new dsp but that shldn't refuse loading a changed .dsp file. I hope I understood the problem exactly! if I am not lemme know

1.
How you shld write in .rtf?
U know wat? you need to write to .rtf file using ya key board :-))))) !!!
what you shld write in .rtf?
All the help topics that you wanna cover in the .rtf
Use footnote # for giving a reference to a particular topic
use footnote K for the topic to appear in the Index
use footnote $ to appear in the Search of the Help tabs
Whatever is written on the .cnt file will become the contents of the help's content
If you want some topics to appear one by one you need to insert table and that shld be it!
Njoy!

Well, where R V going for the Party?

Sorry buddy! forgotta answer the second part of ya first Qn!!
If you had changed the .dsp and loaded the .dsw without any problems in the VC++ ide then you don't need to worry abt compiling again and again! Bcoz it shld work like any other Appln that is with help! To identify whether itz doing like that or not what you can do is... edit the .rtf file and save it. Then clean the debug area using the "clean" option. Then say "Rebuild All". If the Help workshop comes and goes and if you are able to see"Compiling help file" in the o/p window..itz fine U don't need to compile again and again! The compiler takes care of it. If itz not then you need to build the .hpj again and again when you make some change to the .rtf file.
So what I reccomend is to add the code in the dsp file and let the compiler take care of the change..
Rgds,
Anchaneya


Avatar of Lescha

ASKER

Anchaneya,

you see, I've never written a Help before. Could you please explain it to me? I mean, there're links that lead to other pages, link that create little pop-up explanations, and also topics (that I should later include in a map, right?) and also an index? How exactly do I do all that? What of that belongs to an rtf and what is the format?

As to your question, and I quote, "Well, where R V going for the Party?" - Since I'll be going to the Army soon, the only choice seems to be in the Holy Land ;) Tell me if you have an intention of visiting my country! ;)

Yura
Hey!!
Thatz grrea..ttt that U R gonna serve ya country !!
I also served for my country for a couple of years :-)))
( in AirForce! as a Pilot Officer). I am ya Senior :-)) So, now U need to gimme double the Trrreaat !! All the best buddy !!
As of ya tech Qn is concerned,
1. I've a book to guide you thru the Help process, in addition to my comments here! The Book is "Inside VC++" by Kruglinski, ch - 20! That would really help you!
BTW...the following may not be there in the book!
2. I donno where U R now?
I assume that
* the help coming on clicking of a help button
* U R able to write something on the .rtf file and compile it thru the program and not separately!
If the above is yes, then do the following!
a) Open the "hcw" and create a new .cnt file. It'll ask you whether to create a .hpj or .cnt file. You select a .cnt file.
b) Now you will get a blank .cnt file. Add the default file name as "Proj Name.hlp". Leave the Default Title.
c) Click on the button "Add Above" and add the Title first and click on "Add below" to add Topics under that Title!
d) while you are adding Titles hcw won't ask you for the ID but for the Topics it'll ask for Topic Ids and so give topic Ids related to Topics. These Ids are useful for giving the footnotes...I mean reference, in the .rtf file
Once this is complete save and close the .cnt file. Be sure to put that in the /hlp file.
e) Now open the hpj file in the hcw and add the file .cnt file that is in the /hlp directory. Save and compile!
f) Now what you need to do is nothing but adda topic and explanation!! Give reference to the topic. Thatz all!
g) B4 you make changes to .rtf make sure that the word is in the "hidden text visible" mode.
h) View Footnote mode.

From now onwards the topic will be there in the book.
a) Open the .rtf and change the << Your App>> to your Aplication Name.
b) Add topic Name that U wanna explain
c) Insert FootNote # before the Topic and the word will take you to the footnote side (bottom). Here you need to add the Topic id for that topic that you had mentioned B4 for that topic in the .cnt file
e) Insert footnote K after # but B4 Topic to add this string what U R gonna write for this topic to the index section. The Help take care of adding this to Index if yu specify the footnote
f) Insert footnote $ after K but B4 Topic to add this string that U R gonna write for this Topic to the Search DB.
The Help take care of adding this to Index if yu specify the footnote.
Save and compile the .hpj or Rebuild the proj if ya changed .dsp.
1. The help now shld have the contents file that you had written in the .cnt.
2. On clicking of the Index tab of help, you shld be able to identify the strings you'd written for the footnote K
3. On clicking of the Search tab of help, you shld be able to identify the strings you'd written for the footnote $
That iz it!

f)

Avatar of Lescha

ASKER

Please don't think I'm stalling... Write now I have to hard exams to pass and then I'll get back to my work and will evaluate your answer as soon as I have time to work with it.