Solved

calling Html Help workshop from a C++ app, using keyword lookup

Posted on 2007-03-20
10
940 Views
Last Modified: 2016-10-09
Hi!

i am trying to use html help workshop to manage the help of my application.
the help file is working well, but I have a problem calling it from the C++ app.

I use:
      HH_AKLINK query;
      HWND owner = theApp.GetMainFrame()->GetSafeHwnd();
      
      query.cbStruct = sizeof(query);
      query.fReserved = FALSE;
      query.pszKeywords = (LPCSTR)p_Lookup;
      query.pszUrl =       NULL ;
      query.pszMsgText =   NULL ;
      query.pszMsgTitle =  NULL ;
      query.pszWindow =    NULL ;
      query.fIndexOnFail = TRUE ;

      m_HelpHandle = HtmlHelp(owner, m_HelpFileName, HH_DISPLAY_INDEX,0) ;
      m_HelpHandle = HtmlHelp(owner, m_HelpFileName, HH_KEYWORD_LOOKUP,(DWORD)&query) ;

and i'd like the help file to open and point to the page talking about what is contained in "p_Lookup".

the help file opens correctly, and the keyword I am trying to lookup appears correctly in the index page, BUT the page itself is not displayed. (I have to press enter to display the selected entry).

to give a concrete example, I have a keyword "WaitWnd" in my help file. there is a page titled "WaitWnd", and there is an entry "WaitWnd" in the TOC, leading to this page.
when I run the lookup from the application, the help opens on the default page, but "WaitWnd" is already selected in the index tab. (as a result of query.fIndexOnFail = TRUE ; i guess), BUT the WaitWnd page is not displayed.

is there something I mistook? did you experience this situation before?

best regards,

Raph
0
Comment
Question by:ralph78
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 18756597
As far as I read the docs you have to give the pointer to the keyword(s) and not a pointer to the query.

m_HelpHandle = HtmlHelp(owner, m_HelpFileName, HH_KEYWORD_LOOKUP,(DWORD)query.pszKeywords) ;

Regards, Alex

0
 

Author Comment

by:ralph78
ID: 18757166
Hi Alex,

well, I don't think so.
here is the MSDN doc:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/htmlhelp/html/vsconcmdhhkeywordlookup.asp

and they use a pointer to the structure, not to the keyword.

just in case I tried your solution, but I ended up with both the help and my app frozen.

anyway, where did you get your information from? (maybe i could dig it further and find a way)

regards,

Raph
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 18757549
It was an article named 'HTMLHelp API Reference' in the MSDN that was shipped with VC6. Here they tell for the last argument of HtmlHelp( .., ..., ..., dwData):

HH_KEYWORD_LOOKUP Attempts to find the given keyword in a .HHK file. If found, the topic is displayed in the specified (or current, if not specified) window. If NULL, the .HHK file associated with the current window is used. If a string containing a window definition is used, but not a .HHK file, then the .HHK from the specified window is used, and if the topic is found, it will be displayed in that window. If a .HHK file is specified, that file will be used.  

I found the same article though now referencing to SDK 1.4  by Google : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/htmlhelp/html/vsconCmdhhkeywordlookup.asp


I see in your code two differences which may or may not be responsible for the fail:

1. The pLookup was casted before assignment while in the sample it is a const literal. What type has pLookup and where was the memory assigned? Is it possible that it can get invalid while the help was shown? You may test by using a const literal if there is a problem.

2. You call HtmlHelp twice. Once to show the index and once to lookup for the specific page. I assume the help was showed asynchronously what would mean that you see only the first call of HtmlHelp showing the index and the second was ignored. To verify this you only need to comment the first call.

Regards, Alex



***** Points to a string containing one or more keywords,keywords separated by a semi-colon. *****

I read a newer API reference (VC7) where the doc had changed.

HtmlHelp(
          GetDesktopWindow(),
          "c:\\myhelp.chm",
          HH_KEYWORD_LOOKUP,
          (DWORD)&link);    // HERE link is a struct and not a char array

 
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 18757589
Oh, some text was mixed up. I post again in the correct order:

It was an article named 'HTMLHelp API Reference' in the MSDN that was shipped with VC6. Here they tell for the last argument of HtmlHelp( .., ..., ..., dwData):

HH_KEYWORD_LOOKUP Attempts to find the given keyword in a .HHK file. If found, the topic is displayed in the specified (or current, if not specified) window. If NULL, the .HHK file associated with the current window is used. If a string containing a window definition is used, but not a .HHK file, then the .HHK from the specified window is used, and if the topic is found, it will be displayed in that window. If a .HHK file is specified, that file will be used.  
***** Points to a string containing one or more keywords,keywords separated by a semi-colon. *****

I read a newer API reference (VC7) where the doc had changed.

HtmlHelp(
          GetDesktopWindow(),
          "c:\\myhelp.chm",
          HH_KEYWORD_LOOKUP,
          (DWORD)&link);    // HERE link is a struct and not a char array

I found the same article though now referencing to SDK 1.4  by Google : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/htmlhelp/html/vsconCmdhhkeywordlookup.asp


I see in your code two differences which may or may not be responsible for the fail:

1. The pLookup was casted before assignment while in the sample it is a const literal. What type has pLookup and where was the memory assigned? Is it possible that it can get invalid while the help was shown? You may test by using a const literal if there is a problem.

2. You call HtmlHelp twice. Once to show the index and once to lookup for the specific page. I assume the help was showed asynchronously what would mean that you see only the first call of HtmlHelp showing the index and the second was ignored. To verify this you only need to comment the first call.

Regards, Alex

 
0
 

Author Comment

by:ralph78
ID: 18771876
Hi Alex,

well, I agree with you: HtmlCall are asynchronous. I also feel weird to put two calls, but I just followed MS recommandations.
"# You must first call the HH_DISPLAY_TOPIC command before calling this command to ensure that the help window is created."

Anyway, even if I comment out the first call, the result will be the same.

As for the memory issue, p_Lookup is a CString, and was allocated outside of the call.
I also don't think this is the problem because when I set
query.fIndexOnFail = TRUE ;
the help does not show the proper page, BUT copies the content of p_Lookup in the "index" pane.
So i think htmlhelp forwards my keyword correctly, but fails to display the page.

anymore idea? :-)
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 18773196
>>>> anymore idea? :-)
No, I am sorry.

Do you have another helpfile where you know a valid page keyword? E. g. some sample helpfile. If it shows correctly you may edit that one rather than using your help file. Is there another way to check your helpfile rather tna open it programmatically?
0
 
LVL 7

Accepted Solution

by:
help-info earned 250 total points
ID: 19079692
I'm not a C++ programmer but struggle to this field from VB. I want to call multi-level keywords (no solution yet).
.. back to you and "query.fIndexOnFail = TRUE;" in your first question. A quote from MSDN above:
"Specifies whether to display the keyword in the Index tab of the HTML Help Viewer if the lookup fails. The value of pszWindow specifies the Help Viewer."

It seems to me only on fIndexFail = TRUE the search keyword is put to the input field of the Index tab on the left. The content in the topic pane on the right is not synchronised. So, I do following in VB and note I have two declarations (HTMLHelpTopic for String and HtmlHelpIndex  for Structure),

Private Declare Function HTMLHelpTopic Lib "hhctrl.ocx" Alias "HtmlHelpA" _
                 (ByVal hwndCaller As Long, ByVal pszFile As String, _
                ByVal uCommand As Long, ByVal dwData As String) As Long
             
Private Declare Function HtmlHelpIndex Lib "hhctrl.ocx" Alias "HtmlHelpA" _
                (ByVal hwndCaller As Long, ByVal pszFile As String, _
                ByVal uCommand As Long, dwData As HH_AKLINK) As Long

Public Sub ShowIndexKeyword(ByVal intHelpFile As Integer, ByVal sKeyword As String)
' -----------------------------------------------------------------------------------
Dim keyData As HH_AKLINK
  With keyData
    .cbStruct = Len(keyData)
    .fReserved = 0&
    .pszKeywords = sKeyword
    .pszUrl = vbNullString
    .pszMsgText = "No such keyword found: " + sKeyword
    .pszMsgTitle = "Keyword Not Found"
    .pszWindow = ""
    .fIndexOnFail = 0&        'FALSE
  End With

'--- first use HH_DISPLAY_INDEX to open the help window and put the keyword to index tab entry -------
  HTMLHelpTopic hwnd, HFile(intHelpFile), HH_DISPLAY_INDEX, sKeyword
'--- second use HH_KEYWORD_LOOKUP to sync the topic content pane -----------
'--- here is same keyword as first call, see:     .pszKeywords = sKeyword
  HtmlHelpIndex hwnd, HFile(intHelpFile), HH_KEYWORD_LOOKUP, keyData
End Sub

Please also read this for parameter declaration:
http://www.help-info.de/en/Help_Info_HTMLHelp/hh_api.htm#VBnet
and more C# related
http://www.help-info.de/en/Visual_Basic_net/vbnet_faq.htm

HTH
Best regards
Ulrich Kulle

0
 
LVL 6

Expert Comment

by:SeanDurkin
ID: 21436118
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup Zone:
  Accept: help-info {http:#19079692}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

Sean
EE Cleanup Volunteer
0
Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question