HTMLHelp problem

HTMLHelp problem

Postby Dietmar Jahnel » Fri Jun 08, 2007 8:51 am

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
User avatar
Dietmar Jahnel
 
Posts: 83
Joined: Mon Oct 17, 2005 10:33 am
Location: Austria

Postby Otto » Fri Jun 08, 2007 9:51 am

Search the internet for:

Windows6.0-KB917607-x86.msu

Regards
Otto
User avatar
Otto
 
Posts: 6327
Joined: Fri Oct 07, 2005 7:07 pm

Postby Dietmar Jahnel » Sun Jun 10, 2007 9:11 am

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
User avatar
Dietmar Jahnel
 
Posts: 83
Joined: Mon Oct 17, 2005 10:33 am
Location: Austria

Postby Antonio Linares » Sun Jun 10, 2007 11:10 am

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  Expand view
#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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sun Jun 10, 2007 11:25 am

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&)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sun Jun 10, 2007 11:35 am

SOLVED! No GPFs! :-)

Effectively the key is to use the right parameters and also a PASCAL declaration was missing:
Code: Select all  Expand view
#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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Dietmar Jahnel » Fri Aug 10, 2007 5:10 pm

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
User avatar
Dietmar Jahnel
 
Posts: 83
Joined: Mon Oct 17, 2005 10:33 am
Location: Austria

Postby Antonio Linares » Fri Aug 10, 2007 8:57 pm

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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Dietmar Jahnel » Sat Aug 11, 2007 10:04 am

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
User avatar
Dietmar Jahnel
 
Posts: 83
Joined: Mon Oct 17, 2005 10:33 am
Location: Austria

Postby Antonio Linares » Sat Aug 11, 2007 10:21 am

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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sat Aug 11, 2007 10:37 am

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  Expand view
#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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Dietmar Jahnel » Sat Aug 11, 2007 10:53 am

Looks good - as soon as the FreeLibrary( hDLL ); is removed from HB_FUNC( HTMLHELP ).
Right?

Thanks,
Dietmar
User avatar
Dietmar Jahnel
 
Posts: 83
Joined: Mon Oct 17, 2005 10:33 am
Location: Austria

Postby Antonio Linares » Sat Aug 11, 2007 11:51 am

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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Dietmar Jahnel » Sat Aug 11, 2007 12:07 pm

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
User avatar
Dietmar Jahnel
 
Posts: 83
Joined: Mon Oct 17, 2005 10:33 am
Location: Austria

Postby Antonio Linares » Sat Aug 11, 2007 12:39 pm

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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 48 guests