Page 1 of 2

Mr. Linares -> Error Message on .CHM-Help

Posted: Thu Aug 28, 2008 2:32 pm
by byte-one
I am just updated to 8.08. When I use the CHM-Help-Feature there are an error-message on folder dialogs, when I press F1. (Argument error: == )
No help-IDs are defined.

This could be the required changes:

  • function chmHelpTopic( cnTopic )

    local cHelpFile := GetHelpFile()
    local cHelpTopic := GetHelpTopic()
    local nCmd := 0

    if Empty( cHelpFile )
    MsgStop( "No Help file available", " Attention" )
    return .F.
    endif

    if PCount() == 0
    // display contents with default topic
    nCmd := HH_DISPLAY_TOC
    cnTopic := nil
    else
    do case

    case cnTopic == "N" // help id of topic
    should be ->>> case valtype(cnTopic) == "N"



    nCmd := HH_HELP_CONTEXT

    case cnTopic == "C" // help topic name
    should be ->>> case valtype(cnTopic) == "C"


    nCmd := HH_DISPLAY_TOPIC
    cnTopic := ExtHtm( cnTopic )



Another problems:
1.) If I define a Help-ID for a dialog, the help-item with this ID are not shown with F1, always the index. In tests the ::nHelpId from this dialog in Windows-class are empty instead the defined help-id!
2.) When I call the help on an dialog with help-ID and with a folder in this dialog then first shown for a short time the right help-ID and then also the helpindex.
3.) Another point of interest are help-IDs for the folder-dialogs! (oFld:aDialogs[1...,2...,]:nHelpId := 22) and the help-ID from the parent dialog from folder.

Please check this.

Posted: Sat Aug 30, 2008 10:40 am
by byte-one
Mr. Linares, is there any suggestion for this problem?
Functioning CHM-Help is a MUST for an professional programm.

I will test all functions and make changes for our FWH if required.

Posted: Sat Aug 30, 2008 6:36 pm
by Antonio Linares
Günther,

Yes, you are right, many thanks for your feedback :-)

This is the right code as you have commented:

Code: Select all

      do case
         case ValType( cnTopic ) == "N"
              // help id of topic
              nCmd = HH_HELP_CONTEXT
              
         case ValType( cnTopic ) == "C"
              // help topic name
              nCmd     = HH_DISPLAY_TOPIC
              cnTopic  = ExtHtm( cnTopic )   // Add .htm extn.
                                             // Prg can use either .hlp or .chm
         ...
We are also reviewing your other commented issues, thanks

Posted: Sat Aug 30, 2008 7:40 pm
by Antonio Linares
Günther,

>
1.) If I define a Help-ID for a dialog, the help-item with this ID are not shown with F1, always the index. In tests the ::nHelpId from this dialog in Windows-class are empty instead the defined help-id!
>

This example is working fine here:

test.prg

Code: Select all

#include "FiveWin.ch" 

function Main() 

   local oDlg, oFld 
    
   SET HELPFILE TO "fwclass.chm" 
    
   DEFINE DIALOG oDlg SIZE 400, 300 HELPID "classes_hierarchy"

   @ 0.5, 1 FOLDER oFld OF oDlg SIZE 188, 138 ;
      PROMPTS "One", "Two", "Three"
      
   ACTIVATE DIALOG oDlg CENTERED 

return nil 
Image

Posted: Sat Aug 30, 2008 7:46 pm
by Antonio Linares
>
2.) When I call the help on an dialog with help-ID and with a folder in this dialog then first shown for a short time the right help-ID and then also the helpindex.
>

This is not observed in our previous example.

Could you please modify our example to show it ? thanks

Posted: Sun Aug 31, 2008 8:38 pm
by byte-one
Antonio, I define the dialog not in function main()! I define the dialog with nHelpId from a main-window with menu! It seems, all both (dialog and then main-window) ::help()-functions are calling!?
Can you show me the logic of the help-call from CONTROL (popup-help) to DIALOG to WINDOW?

Posted: Sun Aug 31, 2008 10:41 pm
by Antonio Linares
Günther,

> I define the dialog with nHelpId from a main-window with menu!

Please provide a small and self contained example to reproduce it, thanks

I don't fully understand what you are doing.

Posted: Mon Sep 01, 2008 9:24 am
by byte-one
Antonio, I have send to you an EXE and CHM what show you the problem to call an helpID from dialog.

Posted: Mon Sep 01, 2008 12:16 pm
by Antonio Linares
Günther,

It seems as your CHM does not have a topic 11. Please try this test. Here it is working fine and it shows "Installation" topic when F1 is pressed on the dialog. Please notice that the REDEFINE GET is commented.

test.prg

Code: Select all

#include "FiveWin.ch"

function Main()

   local oWnd, oMenu

   SET HELPFILE TO "skydrive.chm" 

   MENU oMenu 2007
      MENUITEM "Test" ACTION Test()
   ENDMENU

   DEFINE WINDOW oWnd MENU oMenu 

   ACTIVATE WINDOW oWnd
   
return NIL

function Test()

   local oDlg, cTest := "Hello   "
   
   DEFINE DIALOG oDlg RESOURCE "test" HELPID "Installation"
 
   // REDEFINE GET cTest ID 106 OF oDlg
 
   ACTIVATE DIALOG oDlg CENTERED
   
return nil

Posted: Mon Sep 01, 2008 12:19 pm
by Antonio Linares
Now, if we use the REDEFINE GET there is a bug in FWH, as the HelpTopic() of the GET is invoked, but the GET does not have a helpid, so the help index is shown!

This is the required fix for Class TDialog, so a control with no defined helpid will not be used to show help:

Code: Select all

METHOD Help( nWParam, nLParam ) CLASS TDialog

   local hWndChild := HelpCtrlHwnd( nLParam ), nAtChild

   static lShow := .f.

   ::lHelpIcon = .f.

   if ! lShow
      lShow = .t.
      if ( nAtChild := AScan( ::aControls, { | o | o:hWnd == hWndChild } ) ) != 0 .and. ;
         ! Empty( ::aControls[ nAtChild ]:nHelpID )
         ::aControls[ nAtChild ]:HelpTopic()
      else
         ::HelpTopic()
      endif
      lShow = .f.
   endif   

return nil

Posted: Mon Sep 01, 2008 12:21 pm
by Antonio Linares
Günther,

With the previous fix applied to Class TDialog, please uncomment the REDEFINE GET in my example and test it, you will see that the "Installation" topic (that belongs to the dialog) is invoked.

Posted: Tue Sep 02, 2008 10:53 am
by byte-one
Antonio, I have send to you another executable that shows the problem and modified dialog.prg and window.prg.
I also not understand the static variable lShow in the methods for help.

Posted: Tue Sep 02, 2008 11:22 am
by Antonio Linares
Günter,

You forgot to send me the source code for TestHelp.prg. Please send it to me.

> I also not understand the static variable lShow in the methods for help

To avoid recursive calls

Posted: Tue Sep 02, 2008 11:25 am
by Antonio Linares
Also, to manage CHMs you have to use strings for topics IDs, not numbers (unless you specify a DLL to search for strings based on IDs, which will make things more complex).

What tool are you using to build your CHM files ? We do recommend Help&Manual

Posted: Tue Sep 02, 2008 12:11 pm
by byte-one
As I use numbers or strings for helpid, the right CHM topic not is shown! I have send to you the files.

> I also not understand the static variable lShow in the methods for help
> To avoid recursive calls

But the lShow always on beginn of help-method is set to .f. !?

method help()
static lShow := .f.

if ! lshow
lshow := .t.
..
..
lshow := .f.
endif

This construct is for me not clear and in this form this cannot avoid recursions? Should lShow not be a CLASSDATA or so?