forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

calling .CHM files from FTN95

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
steveDoyle



Joined: 04 Sep 2009
Posts: 108
Location: Manchester

PostPosted: Tue Jan 26, 2016 12:00 pm    Post subject: calling .CHM files from FTN95 Reply with quote

HI everybody

My apps call .CHM files from FTN95 via a MSVS C DLL. It has work flawlessly for many year son XP/win 7 (32 & 64). It crashes when the apps are used on win8/8.1/10 (apPs work so long as help disabled)


ftn95 call
CALL HTML_HELP(' ', 0, HH_INITIALIZE, IHELP_COOKIE)

C code


extern "C" int __declspec(dllexport) HtmlHelpX(int* help_handle,
char* help_topic, int* help_command, int* help_data)
{

HWND help_handlex = HWND(*help_handle);
LPCSTR help_topicx = help_topic;
UINT help_commandx = (UINT)(*help_command);
DWORD help_datax = (DWORD)(*help_data);
HWND hdlx;

hdlx = HtmlHelp(help_handlex, help_topicx, help_commandx, help_datax);
return (int)hdlx;

}


The C code is too much my for my 1-dimensional fortran brain. Im assuming that is the 32 vs 64 bit issue

any pointers appreciated

TIA

steve
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Tue Jan 26, 2016 9:56 pm    Post subject: Reply with quote

Steve,

This is what I do:

Code:
      INTEGER FUNCTION IHELPSYS()
C     --------------------------
       CHARACTER*(256) PNAME
       INCLUDE <WINDOWS.INS>
      IHELPSYS = 1
      CALL GET_PROGRAM_NAME@ (PNAME)
      CALL UPCASE@ (PNAME)
      N = LEN_TRIM (PNAME)
      IF (PNAME (N-5:N) .EQ. 'SS.EXE') THEN
      N = N - 6            ! Assumes SS.EXE
      CALL START_PPROCESS@('HH.EXE',PNAME(1:N)//'WSXHelp.chm')
      ELSE
      DO 10 I=1,N
      J = N + 1 - I
      IF (PNAME(J:J) .EQ. '\') GO TO 20
  10  CONTINUE
      RETURN
  20  CALL START_PPROCESS@('HH.EXE',PNAME(1:J)//'WSXHelp.chm')
      ENDIF
      END


HH.EXE is the standard Windows program for displaying .CHM files. I have a feeling that the 'ELSE' clause covers the case that somebody changed the name of the application ... I have no doubt that this routine could be improved immensely. It is a callback function.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7923
Location: Salford, UK

PostPosted: Wed Jan 27, 2016 8:59 am    Post subject: Reply with quote

I don't recognise HTML_HELP so I assume that it is a third party C function.

If you have its code then it might be possible to work out why it is failing. It looks like it is making calls into the Microsoft API function HtmlHelp. In theory you could do the same, either by making the call to HtmlHelp from FTN95 (which is tricky because it involves structures) or from a Silverfrost SCC compiled C function.

The route via HH.exe is almost certainly easier assuming that it provides all of the functionality that you need.
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Wed Jan 27, 2016 10:49 am    Post subject: Reply with quote

What I forgot to say is that my help file is installed in the same directory as the executable, so finding the path to the executable finds it to the help file, in case the user installed the whole lot other than in the default installation directory.

It could be somewhere else, that you could find relative to the executable's location, but I've never been that sophisticated.
Back to top
View user's profile Send private message
steveDoyle



Joined: 04 Sep 2009
Posts: 108
Location: Manchester

PostPosted: Thu Jan 28, 2016 5:10 pm    Post subject: Reply with quote

Hi

HTML_HELP is just my stub function so that i can access the windows API function HtmlHelp().

HTML_HELP{ftn95} -> HtmlHelpX() {MSVS C DLL} -> HtmlHelp() {WIn API}


I think most of my confusion comes from the API definitions for LPCSTR, DWORD etc.

when i step through the code in the debugger it is the actual call to HtmlHelp() that detonates.


Thanks for at the HH.EXE route but a quick scan of the web seems to indicate that there are issues on win 8/10 but i will try it as a possible alternative.

Thanks

steve
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Fri Jan 29, 2016 7:34 pm    Post subject: Reply with quote

I used Windows 8.1 fleetingly but upgraded that and other computers to Windows 10, and haven't had a moment's trouble with HH.EXE.

It's such a mainstream part of Windows that I can't see it not working in simple cases, but I've never tried it going straight for one of the particular topics. It is easy enough to try, so I honestly recommend that you give it a whirl.
Back to top
View user's profile Send private message
steveDoyle



Joined: 04 Sep 2009
Posts: 108
Location: Manchester

PostPosted: Fri Feb 05, 2016 12:36 pm    Post subject: Reply with quote

I tried the HH.exe route with varying degrees of success. If you use start_process@() then the help file seems to become the focus so it must be closed before proceeding in the app. I tried using WINEXEC() but this create a new instance every time the help was invoked and left then open when the app was shut down.

I finally managed to get HtmlHelp() to function on win 8/8.1/10 systems so everything is now working as required. It was basically a simple typo that had no effect in xp/7 but was essential for the 64-bit systems.

if you are interest i can email you a the code

thanks for all you inputs

steve
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Fri Feb 05, 2016 4:53 pm    Post subject: Reply with quote

Steve,

You need start_Pprocess ... which starts an independent process. It's that in my demo. One P starts a process that must complete before you can go back to your app.

Eddie
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group