Page 1 of 2
HTMLHelp problem
Posted: Fri Jun 08, 2007 8:51 am
by Dietmar Jahnel
I still get an GPF when I try the following (FWH 7.01):
MENUITEM ....
ACTION HTMLHelp( 0, "RIDA.CHM", 15, IDH_DATEN)
Any solution for Vista-PCs?
Dietmar
Posted: Fri Jun 08, 2007 9:51 am
by Otto
Search the internet for:
Windows6.0-KB917607-x86.msu
Regards
Otto
Posted: Sun Jun 10, 2007 9:11 am
by Dietmar Jahnel
Thanks Otto,
For now it is a possible solution.
But I think in the near fututre we will need a working HTMLHelp in FWH.
Antonio, your opinion on this topic?
Dietmar
Posted: Sun Jun 10, 2007 11:10 am
by Antonio Linares
Dietmar,
The problem is related to "hhctrl.ocx" itself. We have tested it this way to avoid a possible error from DLL FUNCTION command, and it keeps GPFing:
Code: Select all
#include "FiveWin.ch"
function Main()
local oWnd
DEFINE WINDOW oWnd TITLE "Test"
@ 2, 2 BUTTON "Help" SIZE 80, 20 ACTION HTMLHelp( 0, "fwclass.chm", 2, 1 )
ACTIVATE WINDOW oWnd
return nil
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
typedef LONG ( * PHTMLHELP ) ( HWND, LPSTR, LONG, LONG );
HB_FUNC( HTMLHELP )
{
HINSTANCE hDLL = LoadLibrary( "hhctrl.ocx" );
PHTMLHELP pHTMLHelp = ( PHTMLHELP ) GetProcAddress( hDLL, "HtmlHelpA" );
pHTMLHelp( ( HWND ) hb_parnl( 1 ), hb_parc( 2 ), hb_parnl( 3 ), hb_parnl( 4 ) );
FreeLibrary( hDLL );
}
#pragma ENDDUMP
Posted: Sun Jun 10, 2007 11:25 am
by Antonio Linares
Maybe the GPF is coming from here:
Declare Function HtmlHelp Lib "HHCtrl.ocx" Alias "HtmlHelpA" _
(ByVal hwndCaller As Long, _
ByVal pszFile As String, _
ByVal uCommand As Long, _
dwData As Any) As Long
...
dwData Specifies additional data depending on the value of uCommand. Note that in this declaration this argument is declared As Any, because this argument accepts several different data types. You must be careful to pass the correct data type or risk an invalid page fault (also known as general protection fault [GPF]).
Some samples:
Call HtmlHelp(0, "c:\help\Sample.chm", HH_DISPLAY_TOPIC, By Val "Topic1.htm")
Call HtmlHelp(0, "c:\help\Sample.chm>mso_small", HH_DISPLAY_TOPIC, By Val 2001&)
Posted: Sun Jun 10, 2007 11:35 am
by Antonio Linares
SOLVED! No GPFs!
Effectively the key is to use the right parameters and also a PASCAL declaration was missing:
Code: Select all
#include "FiveWin.ch"
function Main()
local oWnd
DEFINE WINDOW oWnd TITLE "Test"
@ 2, 2 BUTTON "Help" SIZE 80, 20 ACTION HTMLHelp( 0, "fwclass.chm", 0, "class_todbc.htm" )
ACTIVATE WINDOW oWnd
return nil
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
typedef LONG PASCAL ( * PHTMLHELP ) ( HWND, LPSTR, LONG, LPSTR );
HB_FUNC( HTMLHELP )
{
HINSTANCE hDLL = LoadLibrary( "hhctrl.ocx" );
PHTMLHELP pHTMLHelp = ( PHTMLHELP ) GetProcAddress( hDLL, "HtmlHelpA" );
pHTMLHelp( ( HWND ) hb_parnl( 1 ), hb_parc( 2 ), hb_parnl( 3 ), hb_parc( 4 ) );
FreeLibrary( hDLL );
}
#pragma ENDDUMP
Posted: Fri Aug 10, 2007 5:10 pm
by Dietmar Jahnel
Sorry for coming back to this one again:
The above sample is working fine.
But when I copy the code in one of the prg-files of our big application I'm getting the GPF again...
What am I doin wrong??
Thanks, Dietmar
Posted: Fri Aug 10, 2007 8:57 pm
by Antonio Linares
Dietmar,
Maybe you are linking FWH previous HtmlHelp() function. Rename the new one as _HtmlHelp() and call the new one, just to be sure you are not using the old one.
Posted: Sat Aug 11, 2007 10:04 am
by Dietmar Jahnel
Antonio,
I tried, bit it didn't change anything.
I send you a small sample where the same (new) _HTMHelp is called from a screen in a rc-file - now it GPFs...
Can this be the reason??
Dietmar
Posted: Sat Aug 11, 2007 10:21 am
by Antonio Linares
Dietmar,
I have just tested the sample that I published here and that was working ok and now it GPFs again on Vista.
It looks as Microsoft has changed something in recent Vista updates.
Posted: Sat Aug 11, 2007 10:37 am
by Antonio Linares
Ok, I found the solution
We can not free the DLL just after its use.
Here is a working sample using a dialog box and its working fine:
Code: Select all
#include "FiveWin.ch"
function Main()
local oDlg
local hDLL := LoadLibrary( "hhctrl.ocx" );
DEFINE DIALOG oDlg TITLE "Test"
@ 2, 2 BUTTON "Help" SIZE 60, 15 ACTION HTMLHelp( oDlg:hWnd, "fwclass.chm", 0, "class_tget.htm" )
ACTIVATE DIALOG oDlg CENTERED
FreeLibrary( hDLL )
return nil
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
typedef LONG PASCAL ( * PHTMLHELP ) ( HWND, LPSTR, LONG, LPSTR );
HB_FUNC( HTMLHELP )
{
HINSTANCE hDLL = LoadLibrary( "hhctrl.ocx" );
PHTMLHELP pHTMLHelp = ( PHTMLHELP ) GetProcAddress( hDLL, "HtmlHelpA" );
if( pHTMLHelp )
pHTMLHelp( ( HWND ) hb_parnl( 1 ), hb_parc( 2 ), hb_parnl( 3 ), hb_parc( 4 ) );
FreeLibrary( hDLL );
}
#pragma ENDDUMP
Posted: Sat Aug 11, 2007 10:53 am
by Dietmar Jahnel
Looks good - as soon as the FreeLibrary( hDLL ); is removed from HB_FUNC( HTMLHELP ).
Right?
Thanks,
Dietmar
Posted: Sat Aug 11, 2007 11:51 am
by Antonio Linares
Dietmar,
DLLs use an internal counter, so if they are loaded n times, they have to be freed n times. Thats why its better to load it and free it from the PRG too.
If it has been previously loaded more than once, a call to FreeLibrary() will not free it, it will just decrease the use counter
Posted: Sat Aug 11, 2007 12:07 pm
by Dietmar Jahnel
ok, I see - that make it a little bit more complicated...
But what I wanted to express is that the
FreeLibrary( hDLL ) line in HB_FUNC( HTMLHELP )
seems to cause the GPF - at least here in my programm I had to remove it.
Same with you??
Dietmar
Posted: Sat Aug 11, 2007 12:39 pm
by Antonio Linares
Dietmar,
No, here we keep the FreeLibrary() call into the C function, so it matches the previous LoadLibrary().
You need to keep a call to LoadLibrary() from the PRG. Do it as the beginning of your application and free it when you are going to exit from your application.
Keep it mind that you can NOT call FreeLibrary() meanwhile the help is shown, or you will have a GPF.