Solved

Envoking Help File

Posted on 1998-05-08
7
256 Views
Last Modified: 2010-08-05

Hi Experts.  I am having some C++ problems envoking a help file in the same directory.

I guess I'm just not an expert.
Can anyone tell me how to envoke oscar.hlp from the same directory.

I called the winhelp function but I can't get it to compile I recieve errors such as:
error C2660: 'WinHelpA'  function does not take 3 parameters

What is WinHelpA mean when I'm calling WinHelp?

I got this from the help in MVC++ 5
A problem similar to the one shown above occurs when you mistakenly call a Windows API function directly from within an MFC member function, rather than calling the equivalent MFC member function of the same name. Since the two functions are identical in name this error may occur frequently. Either of the two following methods will solve this error:
•Adjust the function call to conform to the format of the member function call.
•Use the scope resolution operator (::) to tell the compiler to look for the function name in the global name space.

I am using MFC but I don't understand? I tried :: but same thing!

Anyways the question is how do I envoke help?  I don't care how?

Moreover.  This program was written in an earlier version I also am not able to get the help file generated to work
automatically in the compile as my new programs do.  Im soomeone could tell me how to do this that would be best.
You know so it reades your resource.h

--Here is my function that I call to envoke the help file in the same directory.

void CMainFrame::OnAppHelp()
{
      ::WinHelp("oscar.hlp",HELP_CONTENTS,0 );
}

0
Comment
Question by:tmcconec
  • 3
  • 3
7 Comments
 
LVL 11

Accepted Solution

by:
alexo earned 50 total points
ID: 1174964
WinHelp() takes 4 arguments.
WinHelp translates to either WinhelpA (ASCII) or WinHelpW (Unicode) by a #define in windows.h

A description of WinHelp follows...
0
 
LVL 11

Expert Comment

by:alexo
ID: 1174965
The WinHelp function starts Windows Help (WINHELP.EXE) and passes additional data indicating the nature of the help requested by the application. The application specifies the name and, where required, the directory path of the help file to display.

BOOL WinHelp(
    HWND hWndMain,      // handle of window requesting Help
    LPCTSTR lpszHelp,      // address of directory-path string
    UINT uCommand,      // type of Help
    DWORD dwData       // additional data
   );      
 
Parameters:

hWndMain - Identifies the window requesting Help. The WinHelp function uses this handle to keep track of which applications have requested Help.

lpszHelp - Points to a null-terminated string containing the path, if necessary, and the name of the Help file that the Help application is to display.
The filename may be followed by an angle bracket (>) and the name of a secondary window if the topic is to be displayed in a secondary window rather than in the primary window. The name of the secondary window must have been defined in the [WINDOWS] section of the Help project (.HPJ) file.

uCommand - Specifies the type of help requested. For a list of possible values and how they affect the value to place in the dwData parameter, see the Remarks section.

dwData - Specifies additional data. The value used depends on the value of the uCommand parameter. For a list of possible values, see the Remarks section.
 
Return Values
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE.

Remarks

Before closing the window that requested Help, the application must call WinHelp with the uCommand parameter set to HELP_QUIT. Until all applications have done this, Windows Help will not terminate. Note that calling WinHelp with the HELP_QUIT command is not necessary if you used the HELP_CONTEXTPOPUP command to start Help
The following table shows the possible values for the uCommand parameter and the corresponding formats of the dwData parameter:

HELP_COMMAND - Executes a Help macro or macro string.
dwData = Address of a string that specifies the name of the Help macro(s) to execute. If the string specifies multiple macros names, the names must be separated by semicolons. You must use the short form of the macro name for some macros because Help does not support the long name.

HELP_CONTENTS - Displays the topic specified by the Contents option in the [OPTIONS] section of the .HPJ file. This is for backward compatibility. New applications should provide a .CNT file and use the HELP_FINDER command.
dwData = Ignored, set to 0.

HELP_CONTEXT - Displays the topic identified by the specified context identifier defined in the [MAP] section of the .HPJ file.
dwData = Unsigned long integer containing the context identifier for the topic.

HELP_CONTEXTPOPUP - Displays, in a pop-up window, the topic identified by the specified context identifier defined in the [MAP] section of the .HPJ file.
dwData = Unsigned long integer containing the context identifier for a topic.

HELP_FORCEFILE - Ensures that WinHelp is displaying the correct help file. If the incorrect help file is being displayed, WinHelp opens the correct one; otherwise, there is no action.
dwData = Ignored, set to 0.

HELP_HELPONHELP - Displays help on how to use Windows Help, if the WINHELP.HLP file is available.
dwData = Ignored, set to 0.

HELP_INDEX - Displays the Index in the Help Topics dialog box. This command is for backward compatibility. New applications should use the HELP_FINDER command.
dwData = Ignored, set to 0.

HELP_KEY - Displays the topic in the keyword table that matches the specified keyword, if there is an exact match. If there is more than one match, displays the Index with the topics listed in the Topics Found list box.
dwData = Address of a keyword string.

HELP_MULTIKEY - Displays the topic specified by a keyword in an alternative keyword table.
dwData = Address of a MULTIKEYHELP structure that specifies a table footnote character and a keyword.

HELP_PARTIALKEY - Displays the topic in the keyword table that matches the specified keyword, if there is an exact match. If there is more than one match, displays the Index tab. To display the Index without passing a keyword (the third result), you should use a pointer to an empty string.
dwData = Address of a keyword  string.

HELP_QUIT - Informs the Help application that it is no longer needed. If no other applications have asked for Help, Windows closes the Help application.
dwData = Ignored, set to 0.

HELP_SETCONTENTS - Specifies the Contents topic. The Help application displays this topic when the user clicks the Contents button.
dwData = Unsigned long integer containing the context identifier for the Contents topic.

HELP_SETINDEX - Specifies a keyword table to be displayed in the Index of the Help Topics dialog box.
dwData = Unsigned long integer containing the context identifier for the Index topic.

HELP_SETWINPOS - Displays the Help window, if it is minimized or in memory, and sets its size and position as specified.
dwData = Address of a HELPWININFO structure that specifies the size and position of either a primary or secondary Help window.

0
 
LVL 11

Expert Comment

by:alexo
ID: 1174966
The following example uses the WinHelp function to start the Windows Help application and open the Windows NT Help file to its Contents topic.

HWND hwnd;     // main window handle  
BOOL bResult   // for checking boolean function result
 
bResult = WinHelp(hWnd, "WINNT.HLP", HELP_CONTENTS, 0L);
 
This next example opens the Windows NT user Help file, searches the file for the topic associated with a keyword string, and then displays the topic.

HWND hwnd;     // main window handle  
BOOL bResult   // for checking boolean function result
 
bResult = WinHelp(hWnd, "WINNT.HLP", HELP_KEY, (DWORD) "finding topics");

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:tmcconec
ID: 1174967
Hi! Thanks for your answer I did read about these and try them earlier.

Just now I tried your last two suggestions...
i.e.
void CMainFrame::OnAppHelp()
{
//       HWND hWnd;     // main window handle  
  //   BOOL bResult;   // for checking boolean function result
       
    // bResult = WinHelp(hWnd, "WINNT.HLP", HELP_KEY, (DWORD) "finding topics");

       HWND hwnd;     // main window handle  
     BOOL bResult;   // for checking boolean function result
       
     bResult = WinHelp(hwnd, "WINNT.HLP", HELP_CONTENTS, 0L);

}

However I still recieve:
         
error C2660: 'WinHelpA' : function does not take 4 parameters

I'm sure it has something to do with this (quoted from error C2660 in help)
A problem similar to the one shown above occurs when you mistakenly call a Windows
API function directly from within an MFC member function, rather than calling the equivalent MFC member function of the same name. Since the two functions are identical in name this error may occur frequently. Either of the two following methods will solve this error:
   •Adjust the function call to conform to the format of the member function call.
   •Use the scope resolution operator (::) to tell the compiler to look for the function name in the global name space.

However, I can't find the MFC "Equivelant" fubction and :: does nothing.
0
 

Author Comment

by:tmcconec
ID: 1174968
Hi! Thanks for your answer I did read about these and try them earlier.

Just now I tried your last two suggestions...
i.e.
void CMainFrame::OnAppHelp()
{
//       HWND hWnd;     // main window handle  
  //   BOOL bResult;   // for checking boolean function result
       
    // bResult = WinHelp(hWnd, "WINNT.HLP", HELP_KEY, (DWORD) "finding topics");

       HWND hwnd;     // main window handle  
     BOOL bResult;   // for checking boolean function result
       
     bResult = WinHelp(hwnd, "WINNT.HLP", HELP_CONTENTS, 0L);

}

However I still recieve:
         
error C2660: 'WinHelpA' : function does not take 4 parameters

I'm sure it has something to do with this (quoted from error C2660 in help)
A problem similar to the one shown above occurs when you mistakenly call a Windows
API function directly from within an MFC member function, rather than calling the equivalent MFC member function of the same name. Since the two functions are identical in name this error may occur frequently. Either of the two following methods will solve this error:
   •Adjust the function call to conform to the format of the member function call.
   •Use the scope resolution operator (::) to tell the compiler to look for the function name in the global name space.

However, I can't find the MFC "Equivelant" fubction and :: does nothing.
0
 
LVL 3

Expert Comment

by:danny_pav
ID: 1174969
Here's what you want to do:
1. If you call ::WinHelp, that takes 4 arguments (add a HWND as the first)
   If you call WinHelp (CWnd::WinHelp) it takes the last 2 arguments and gets the help file name from CWinApp.

2.  If you are going to be making all of your help calls to that particular help file, maybe you should rename the help file to have the same name as the executable.  This is the name of the help file that CWinApp has by default. Or if changing the file's name is not feasible, then maybe you can change the name that CWinApp uses.  (this makes sense if you have 5 apps that all use 1 help file)  Then you want to change the name in InitInstance and change it back in ExitInstance, remembering to save the strings memory because the framework will delete it.  (you'll get a memory leak upon exit if you don't)

Danny
You want to call CWinApp:WinHe
0
 

Author Comment

by:tmcconec
ID: 1174970
Thank you!
What worked is :
HWND hWnd;     // main window handle  
BOOL bResult;   // for checking boolean function result
 
bResult = ::WinHelp(hWnd, "oscar.hlp", HELP_KEY, (DWORD) "finding topics");
       

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now