Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Context sensitive help in VFP application

Status
Not open for further replies.

IoanaPirvu

Technical User
Apr 21, 2006
8
GB
Hi!

I'm developing a help system for a VFP application using an authoring tool(Help&Manual) and I have some problems integrating the help with the application.

I want the help to appear as popup window for the field and as the entire help for the forms.

The tool I use allows me to generate 2 help files (one .chm and the other one .hlp - for the pop-ups) but I don't know how to call both of them. SET HELP TO is only for one file.
I managed to call the help file using the HelpContextID. It works for the .chm file or for the .hlp file. I need both of them and I don't know how to do it.

Another option offered bu the authoring tool is to generate only the .chm file. The popup topics are stored inside the .chm file in a special internal plain text file and must be accesed with special call from the application. Again, I don't know how to do this.

I'm not a VFP programmer an I could really need some help, some code on this.

Thank you very much!

 
Given that you want the help to appear in popup windows, the easiest option is to forget about CHM files. Popup help works much better with HLPs. Compile the entire help project to a single HLP, and reference that file in your SET HELP command.

Like you, I like to use a mix of popup help and the full help viewer. And, like you, I use Help & Manual. My own solution is to use WhatsThisHelp for the popup help. For the full help viewer, I have a Help button on each form, which fires HELP ID thisform.HelpContextID

If you have access to FoxPro Advisor, read my article "Help Without the Hassle" in the Feb 2005 issue (or see
Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 

But you use only the .hlp file?

I would preffer using the .chm file ....it looks nicer.

I'm searching for a code that allows me to acces the txt file generated by the H&M with the.chm file.
 

Well, it's your choice. With the CHM file, you get the modern functional help viewer, like the one in VFP. With HLP, you get a simpler viewer, but you can also do lightweight popups without having to launch the full viewer.

What is the txt file you are referring to?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi, Mike!
The text file is a special file generated by Help&Manual (the authoring tool I'm using). It is an internal file in the CHM(CSHelp.txt) and it contains the topics I designed to be popups.
If you have any hint on how to access this file from VFP....
Thanks!

This is what I got from the H&M support:

"The internal text popups are addressed with a special HTML Help API call. The call is basically:

Code:
HtmlHelp(0, nil, HH_DISPLAY_TEXT_POPUP, longint(@aHH_POPUP))

But that's a Pascal syntax. I don't know how to code this in VFP. aHH_POPUP is a record structure which specifies the help context number and some extra attributes."

Ioana
 

Ioana,

You don't need to get involved with API calls when displaying help. The features you need should be directly available within VFP.

Perhaps we can go back to the start, and you can explain exactly what you are trying to achieve. Just give me a simple statement of what you want to end up with, and I'll do my best to explain how to get there.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Enter topic text here.

Hi, Mike.

What I'm trying to do ...is to use one file (.chm if possible ...... set help to "myhelp.chm") for context sensitive help.
When I press F1 I want:
1. if I am positioned on a field I want a pop-up window to appear explaining that field
2. if I am positioned on a form I want the main help to appear in a different window focused on the topic explaining that particular form.
3. if I access the Help menu I want the main help file to appear focused on the first topic.

Help&Manual allows me to generate 2 files: one.chm and the other one .hlp (containing the pop-up topics) but I do not know how to switch between them.

Another option offered by H&M is to generate only one file (.chm)but which has an internal special text file containing the pop-up topics(CSHelp.txt. I do not know how to acces this file from VFP (i do not know how to access any text file from VFP)and make the connection with my field. The helpcontextid does not link to the topic id from the text file directly as for the .chm file.

I'm about to give up trying (mainly because I don't understand all the VFP coding )...but this matter still intrigues me.
 

Hi Ioana,

Please don't give up on this. Now that you have explained exactly what you want to achieve, I can assure you it's possible. If you stick with me, I'll show you how to do it.

I have a very similar system in one of my own applictions. The only difference is that I am using HLP help, whereas you want to use CHM, but even so, you can get to where you want to go.

First, the text file you mentioned isn't essential for creating the popups. Although it's possible to export it, it is mainly for the project's internal use. In fact, it's better not to try to use it, because it doesn't let you include different fonts, styles, colours or hyperlinks in your popups. Instead, proceed as follows.

The important thing is to keep track of the numeric context IDs you assign to your popup topics. These are the numbers that you enter in the Help Context Number box, to the right of the Topic Options page in H&M.

When you've written your topics and assigned the IDs, go ahead and build the project.

Now, in Visual FoxPro, fill in the WhatsThisHelpID properties of the individual controls. For each control, the property should match the corresponding popup topic's Help Context Number. Next, set the form's WhatsThisHelp property to .T.

As far as individual controls are concerned, that's all you need to do (apart from SET HELP TO MyHelpFile at the start of your application). When the user moves to a control and hits F1, you'll see your popup help topic.

For forms, you set the WhatsThisHelpID property in the same way. However, the user can't get to the help by hitting F1. This is because there's no way to be "positioned on the form". The form itself can't get focus. So you need to provide a toolbar button or a menu option to trigger the help. The menu option or button should execute code similar to the following:

IF _SCREEN.FormCount > 0
_SCREEN.ActiveForm.ShowWhatsThis
ENDIF

That will invoke the popup for the currently active form.

Finally, you want to be able to open the full help viewer from the Help menu. That's easy. Just execute HELP ID 1 (assuming 1 is the Context Number of your first topic).

Now, the only problem with all this is that the popup topics will display in the full help viewer if you are using CHM files. With HLP files, you only see the popup, and not the rest of the viewer, which is slicker and faster.

To get round that, either forego using CHMs, and compile only to HLPs. Or, generate both kinds of file. At the start of your program, SET HELP TO the HLP file. In the menu command (mentioned above) that brings up the full help viewer, do this:

SET HELP TO MyHelp.CHM
HELP TOPIC I
SET HELP TO MyHelp.HLP

That should give you the best of both worlds (I haven't actually tried to do that, but I expect it will work).

I know the above explanation is quite long, but if you take the time to work through it, you should end up with a slick Help system. If I have missed anything, or if you have any questions, come back and we can sort it out.

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks a lot! It works.You're a life saver.:)

But I used a comand button(I do not know how to create a button on the form's toolbar...it is possible?).
The help file appears maximized (it's ok ...but i would like it to not appear full screen)


...I have another question(s):).
Could I modify the functionality of the WhatsThisButton(the ? that appears if I set the WhatsThisButton property of the form to .T.) so clicking it will call the help file (like the command button I used)?

Can I modify the F1 functionality so as when I press F1, if the object which has the focus was not assigned a HelpContextId ..... the "no help topic is associated with this topic" not to appear. Instead another message or even the main help to appear.

Thank you once again.
Have a really nice day!

 


I used a comand button

It doesn't make any difference. However, if the button is on the form (the one you want the help for), you don't have to bother with SCREEN.ActiveForm. Just call THISFORM.ShowWhatsThis

The help file appears maximized (it's ok ...but i would like it to not appear full screen)

This is a function of the Help viewer. As far as I know, it is not controllable from VFP. In general with CHM help, the viewer will remember the state of the window from the previous time it was opened. So if your users maximises it, then closes it, it should re-open maximised next time.

Could I modify the functionality of the WhatsThisButton(the ? that appears if I set the WhatsThisButton property of the form to .T.) so clicking it will call the help file (like the command button I used)?

Not as far as I know.

Can I modify the F1 functionality so as when I press F1, if the object which has the focus was not assigned a HelpContextId ..... the "no help topic is associated with this topic" not to appear. Instead another message or even the main help to appear.

What I do is to have a default topic ID, with a custom "no help topic ... " message. I put this in the relevant property of all my base classes (this assumes that you are using a proper object-oriented set of classes).

But that doesn't allow me to bring up the main help screen -- just an alternative popup topic. To achieve that, you would have to trap the F1 key, using the Keypress event of your forms. That's not particularly difficult, but is outside the subject of this thread. If you need help in trapping keystrokes, I suggest you start a new thread for that.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top