Page 1 of 2

How to use HELPBUTTON?

Posted: Sun May 22, 2016 9:00 am
by kcarmody
I have not been able to figure out how to use the HELPBUTTON clause of the DEFINE WINDOW command. There is no sample for this in HMG, but an old discussion on this forum (http://hmgforum.com/viewtopic.php?f=5&t=1312) points to a demo in MiniGui (SAMPLES\BASIC\HELP) which uses both HELPBUTTON and SET HELPFILE with an .HLP file. But .HLP files are obsolete and are not supported in Windows 7 or later without a special download.

I tried modifying this demo to use a .CHM file, but I have not been able to get this to work. This modified version is below. It displays a help button ("?") in the upper right corner next to the close button ("x"), but clicking on the help button does nothing except change the mouse cursor.

I believe that both HMG and MiniGui supported .CHM files under XP. I am now using Windows 7. So it seems that pressing F1 should display HelpDemo.chm, but instead it displays a box titled "Windows Help and Support" that says "Why can't I get Help from this program?" and then explains that I have to download an .HLP reader. So for some reason F1 seems to be looking for an .HLP file, even though I have done SET HELPFILE to a .CHM file.

As a workaround to SET HELPFILE, I can use ON KEY F1 ACTION <.CHM launcher>. I have tried this and it works. But I do not see any way to use HELPBUTTON. Does anyone know this?

TIA for your help!

Code: Select all

// Modified version of help demo in MiniGui SAMPLES\BASIC\HELP\Demo.prg

#include "hmg.ch"

#define IDH_0001   10001
#define IDH_0002   10002
#define IDH_0003   10003

Function Main()

  DEFINE WINDOW Form_1 ;
    AT 0,0 ;
    WIDTH 600 HEIGHT 400 ;
    TITLE 'Help Demo' ;
    ICON 'demo.ico' ;
    MAIN ;
    FONT 'MS Sans Serif' SIZE 10 ;
    HELPBUTTON

    SET HELPFILE TO 'HelpDemo.chm' 

    DEFINE MAIN MENU 
      POPUP '&File'
        ITEM 'Open' ACTION MsgInfo('Open Click!')
        SEPARATOR
        ITEM 'Exit' ACTION Form_1.Release
      END POPUP
      POPUP '&Help'
        ITEM '&Help '   ACTION DISPLAY HELP MAIN 
        ITEM '&Context'   ACTION DISPLAY HELP CONTEXT IDH_0001
        ITEM '&PopUp Help'  ACTION DISPLAY HELP POPUP IDH_0002
        SEPARATOR
        ITEM '&About'   ACTION MsgInfo ( MiniGUIVersion(), "About" )
      END POPUP
    END MENU

    DEFINE STATUSBAR FONT 'MS Sans Serif' SIZE 9
      STATUSITEM "F1 - Help" WIDTH 100
      CLOCK 
      DATE 
    END STATUSBAR

    @ 100,120 LABEL Label VALUE "Press F1..."

    @ 150,100 BUTTON Button_1 ;
    CAPTION 'Button_1' ;
    ACTION MsgInfo('Click Button_1!') ;
    HELPID IDH_0002

    @ 200,100 BUTTON Button_2 ;
    CAPTION 'Button_2' ;
    ACTION MsgInfo('Click Button_2!') ;
    HELPID IDH_0003

  END WINDOW

  CENTER WINDOW Form_1

  ACTIVATE WINDOW Form_1

Return Nil

Re: How to use HELPBUTTON?

Posted: Sun May 22, 2016 1:35 pm
by kcarmody
I found that I can get F1 to work with a .CHM file by
  • adding a line to the demo program, and
  • modifying _hmg_DisplayHelpTopic(), which is in SOURCE\h_help.prg, lines 81-106.
But HELPBUTTON still does not work.

The line I added to the demo program is:

Code: Select all

    ON KEY F1 ACTION DISPLAY HELP MAIN
and the new version of _hmg_DisplayHelpTopic() is:

Code: Select all

*-----------------------------------------------------------------------------*
Procedure _hmg_DisplayHelpTopic ( xTopic , nMet)
*-----------------------------------------------------------------------------*
local cFile

	If empty(_HMG_SYSDATA [ 217 ])
		Return		
	endif

  _HMG_SYSDATA [ 168 ] := xTopic
	_HMG_SYSDATA [ 170 ]   := nMet

  if HB_URIGHT ( ALLTRIM(HMG_UPPER(_HMG_SYSDATA [ 217 ])) , 4 ) == '.CHM'

    cFile := _HMG_SYSDATA [ 217 ]
    if xTopic != nil
      cFile += '::/' + xTopic
    endif
    if nMet == nil
      nMet := 0
    endif
    _Execute( GetActiveWindow(), "open" , "hh.exe" , cFile , , SW_SHOW )

  else

    if xTopic == nil
      xTopic := 0
    endif
    if nMet == nil
      nMet := 0
    endif
    WinHelp( _HMG_SYSDATA [ 181 ] , _HMG_SYSDATA [ 217 ] , 1 , nMet , xTopic )

  endif

Return 

Re: How to use HELPBUTTON?

Posted: Sun May 22, 2016 2:45 pm
by bpd2000
Interesting

Re: How to use HELPBUTTON?

Posted: Sun May 22, 2016 3:24 pm
by kcarmody
I've now found that, if I make a patch to Events(), then I can delete the following line from the demo and F1 will still work:

Code: Select all

    ON KEY F1 ACTION DISPLAY HELP MAIN
The Events() patch is to replace the following line in SOURCE\h_windows.prg, line 973

Code: Select all

			WinHelp ( hwnd , _HMG_SYSDATA [ 217 ] , 1  , 2 , _HMG_SYSDATA [ 35 ][i] )
with this code:

Code: Select all

      cTemp := _HMG_SYSDATA [ 217 ]
      xTemp := _HMG_SYSDATA [ 35 ][i]
      if HB_URIGHT ( ALLTRIM(HMG_UPPER(cTemp)) , 4 ) == '.CHM'
        _Execute( hwnd , "open" , "hh.exe" , cTemp + if( ValType( xTemp ) == 'C', '::/' + xTemp, '' ) , , SW_SHOW )
      else
        WinHelp ( hwnd , cTemp , 1  , 2 , xTemp )
      Endif
I have also made _hmg_DisplayHelpTopic() a bit safer. The following should replace SOURCE\h_help.prg, lines 81-106:

Code: Select all

*-----------------------------------------------------------------------------*
Procedure _hmg_DisplayHelpTopic ( xTopic , nMet)
*-----------------------------------------------------------------------------*
local cFile

	If empty(_HMG_SYSDATA [ 217 ])
		Return		
	endif

  _HMG_SYSDATA [ 168 ] := xTopic
	_HMG_SYSDATA [ 170 ]   := nMet

  if HB_URIGHT ( ALLTRIM(HMG_UPPER(_HMG_SYSDATA [ 217 ])) , 4 ) == '.CHM'

    cFile := _HMG_SYSDATA [ 217 ]
    if ValType( xTopic ) == 'C'
      cFile += '::/' + xTopic
    endif
    if nMet == nil
      nMet := 0
    endif
    _Execute( _HMG_SYSDATA [ 181 ] , "open" , "hh.exe" , cFile , , SW_SHOW )

  else

    if xTopic == nil
      xTopic := 0
    endif
    if nMet == nil
      nMet := 0
    endif
    WinHelp( _HMG_SYSDATA [ 181 ] , _HMG_SYSDATA [ 217 ] , 1 , nMet , xTopic )

  endif

Return 
These changes make F1 work without ON KEY, but MOUSEBUTTON still does nothing.

Re: How to use HELPBUTTON?

Posted: Sun May 22, 2016 4:28 pm
by kcarmody
Sorry, I misunderstood the purpose of HELPBUTTON. I thought it would bring up help immediately, but it actually just sets a mode where the application displays help for a control when you click on it.

http://ux.stackexchange.com/questions/3 ... -this-help

This is in fact what happens with the demo! But only so long as you make the changes to Events() and _hmg_DisplayHelpTopic() that I showed before in this thread.

I've added these changes to my proposed patch at http://kevincarmody.com/hmg. This patch also includes a bug fix for an HFCL function, GetRichEditFileType(). http://hmgforum.com/viewtopic.php?f=43&t=4738

Re: How to use HELPBUTTON?

Posted: Tue May 24, 2016 9:34 am
by Tiger
The link of "HmgChangeProposal.zip" is not work ...

How to use HELPBUTTON?

Posted: Fri Mar 24, 2017 10:48 pm
by Pablo César
Hello Kevin,

I'm sorry I have not seen your topic before. :|

I really liked the help adaptation in HMG. :)
Has Claudio or anyone else been expressed their comments in favor of this proposal ?

I would like to contribute with two ideas:
  1. Would you like to make it possible for the user (even at the managerial level) to edit the help on runtime? Htm files are texts. Of course if we want to improve the aesthetics by adding graphics and parameters, it would be conveninete an html editor.
     
  2. Would you like to emulate help files at compile time through ressource?
We know that the documentation part is the big challenge for all developers. But it is crucial point for presentation of professional work.

I did not know hh.exe and thanks to you I had the pleasure.
I make this test: hh.exe \hmg.3.4.3\DOC\hmgdoc.htm (so cool) :)

Congratulations, colleague Kevin, for your brilliant work.
Really good one ! Very profissional !
Image
Tiger wrote: Tue May 24, 2016 9:34 am The link of "HmgChangeProposal.zip" is not work ...
Http://kevincarmody.com/hmg/HmgChangeProposal.zip

I would like to see this adaption for HMG, as it does not make sense to use the current button help as it is now... :?

Claudio, Rathinagiri. Would someone please comment please?

How to use HELPBUTTON?

Posted: Fri Mar 24, 2017 11:03 pm
by Pablo César
Claudio, please could you tell us if this HelpButton Kevin's proposal was also been approved ?

Re: How to use HELPBUTTON?

Posted: Sat Mar 25, 2017 11:26 am
by kcarmody
Pablo César wrote: Fri Mar 24, 2017 10:48 pm I really liked the help adaptation in HMG. :)
Has Claudio or anyone else been expressed their comments in favor of this proposal ?
I have not seen any comments except from you.
Would you like to make it possible for the user (even at the managerial level) to edit the help on runtime? Htm files are texts. Of course if we want to improve the aesthetics by adding graphics and parameters, it would be conveninete an html editor.
For me, the only practical way to do this is to call a WYSIWYG HTML editor. These are complex applications that I do would not want to redevelop in HMG.
 
Would you like to emulate help files at compile time through ressource?
Again, for me the current setup is best, which calls hh.exe (the CHM file viewer), which in turn uses the Internet Explorer rendering engine. For CHM files, hh.exe adds several features that are not in IE. I do not myself want to redevelop a browser in HMG.
I did not know hh.exe and thanks to you I had the pleasure.
I make this test: hh.exe \hmg.3.4.3\DOC\hmgdoc.htm (so cool) :)
That is nice. I was not aware until now that hh.exe could display HTML files. However, all the HMG DOC files after the first one give a JavaScript error (on my W7 machine) when you use hh.exe to view them.
Congratulations, colleague Kevin, for your brilliant work.
Really good one ! Very profissional !
Thank you, Pablo, for your compliments to me and to so many other people on this forum.

Re: How to use HELPBUTTON?

Posted: Sat Mar 25, 2017 2:31 pm
by trmpluym
This tool is easy for creating CHM files:

https://dumah7.wordpress.com/2009/02/17 ... v-1-4-0-0/

Theo