• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 534
  • Last Modified:

How to execute a .cnt (Help file)

If you have something better let me know.
I use this :
Global Const HELP_QUIT = 2
Global Const HELP_INDEX = 3
Global Const HELP_HELPONHELP = 4
Global Const HELP_PARTIALKEY = &H105

Declare Function WinHelp Lib "user32" Alias "WinHelpA" _
      (ByVal hwnd As Long, ByVal lpHelpFile As String, _
      ByVal wCommand As Long, ByVal dwData As Long) As Long

Sub HelpFile(frmForm As Form, nHelpCmd As Integer)
   
   Dim i As Integer
   Dim nFlag As Integer
   Dim aData As Variant
   '
   If Len(LTrim(RTrim(App.HelpFile))) = 0 Then
      MsgBox "No Help File Available"
      GoTo HelpFile_Exit
   End If
   '
   Select Case nHelpCmd
      Case Is = HELP_QUIT
         nFlag = True
      Case Is = HELP_INDEX
         nFlag = True
      Case Is = HELP_HELPONHELP
         nFlag = True
      Case Is = HELP_PARTIALKEY
         nFlag = True
      Case Else
         nFlag = False 'invalid command!
   End Select
   '
   If nFlag = True Then
      If nHelpCmd = HELP_PARTIALKEY Then
         i = WinHelp(frmForm.hwnd, App.HelpFile, nHelpCmd, "")
      Else
         i = WinHelp(frmForm.hwnd, App.HelpFile, nHelpCmd, 0&)
      End If
   Else
      MsgBox "Invalid Help Command Value"
   End If
   '
HelpFile_Exit:

End Sub

0
dosyl
Asked:
dosyl
  • 5
  • 5
1 Solution
 
paulstampCommented:
No need to use APIs.. the common dialog control allows access to the App's help file. Set the HelpFile property and the HelpCommand to one of the cdlHelp constants (see object browser for full list - includes all the commands in your example)

An example is below :

CommonDialog1.HelpFile = app.path & "\myhelp.hlp"
CommonDialog1.HelpCommand = cdlHelpContents
      CommonDialog1.ShowHelp  
0
 
dosylAuthor Commented:
paulstamp
I have the same problem with your code. It is always the first topic is displayed not the .cnt why?

Another thing, i don't understand why the value of cdlHelpContents=3 and cdlHelpIndex=3, if i take this constants i'll display always the same thing(I believe).
0
 
paulstampCommented:
Sorry - you're right... that code works with the old style help files. This works though :


Const HelpCNT = &HB

With CommonDialog1
      .HelpFile = "tdbg6.hlp"
      .HelpCommand = HelpCNT Or cdlSetHelpntents
      .ShowHelp
End With

Note HelpCNT is not an intrinsic constant so you do need to set it in your declarations
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
dosylAuthor Commented:
paulstamp
This time, it'working, but i don't understand what cdlSetHelpntents(cdlSetHelpContents) does?

And i would like you tell me :
I don't understand why the value of cdlHelpContents=3 and cdlHelpIndex=3, if i take this constants i'll display always the same thing(I believe).

 
     
0
 
paulstampCommented:
The new example adds a new constant - cdlHelpContents and cdlHelpIndex both equal 3 because in old (Win 3.1) help files the index and contents were both the same thing. HelpCNT is a new constant which differentiates between the two - if you dont add this then you will get the index all the time.
0
 
dosylAuthor Commented:
I will accept your comment.
0
 
paulstampCommented:
Cheers!
0
 
dosylAuthor Commented:
paulstamp
    I want your idea. Because i have 15 forms, must i use commondialog on each form or use my APIs with the constant HelpCnt or another idea.
Thank's.
0
 
dosylAuthor Commented:
paulstamp
Another thing, if i want to open the helpfile on the Index tab or the Find tab, how do you do?
Please answer to my previous comment too.
0
 
paulstampCommented:
You should be able to use a single common dialog control and reference it from other places... ie frmMain.CommonDialog1.ShowHelp.

I'm not aware of any way of selecting different tabs on the contents dialog - sorry.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now