Envoking Help File


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 );
}

tmcconecAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

alexoCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
alexoCommented:
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
alexoCommented:
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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

tmcconecAuthor Commented:
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
tmcconecAuthor Commented:
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
danny_pavCommented:
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
tmcconecAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.