Connecting Winhelp to C++/MFC Programs

Total Page:16

File Type:pdf, Size:1020Kb

Connecting Winhelp to C++/MFC Programs Connecting WinHelp to C++/MFC Programs by Don Lammers Copyright 1999-2001 by Don Lammers. All rights reserved. Last updated 2001-02-22 Presented with author's permission by Shadow Mountain Tech Contents Scope.................................................................................................................................................................. 1 Acknowledgements............................................................................................................................................ 1 Connecting Context Sensitive WinHelp to C++/MFC Programs ...................................................................... 2 Calling WinHelp Directly from Your C++ Code............................................................................................. 11 Calling WinHelp from a Command Line......................................................................................................... 15 Training Cards from C++................................................................................................................................. 16 Resources......................................................................................................................................................... 18 Scope MFC provides several hooks for easily connecting to WinHelp. In addition, you can call the WinHelp API from anywhere in your program for additional access to help. The Connecting Context Sensitive WinHelp to C++/MFC Programs section shows how to connect to the built in hooks that MFC provides, and is therefore specific to programming with MFC. The remainder of the document should be easily adaptable to any version of C++, as it sets forth the Windows calls and command line interface for WinHelp. Acknowledgements The following information is from my own experimentation and from people who have walked this path before me. Thanks to all of the following: Microsoft Help WorkShop Help, Microsoft Knowledge Base, The Developer's Guide to WINHELP.EXE (Jim Mischel), Building Windows 95 Help (Nancy Hickman), Paul O'Rear, Developing Online Help for Windows 95 (Boggan, Farkas, and Welinske), Gordon F. MacLeod, Burt Abreu. Connecting WinHelp to C++/MFC Programs 1 Connecting Context Sensitive WinHelp to C++/MFC Programs MFC provides for calling WinHelp topics using the WinHelp function of the CWnd class, from which the Main Frame window of your program is derived if you use the App Wizard. In addition you can override dialog box routines to get control level F1 or right click help if needed. This section shows the steps necessary to hook context sensitive WinHelp into a program created using MFC. Create a Program with Built-In Help If you use the MFC App Wizard to create your project you can include WinHelp support for the main window as part of the automatically generated files. To create a new project with context sensitive help support: 1. From the Visual C++ File menu, choose New. 2. Choose MFC AppWizard (.exe). 3. When given the option, make sure that the Context Sensitive Help box is checked. 4. Continue through the process to set up the program the way you want. This creates the following: • An application with a menu and (if you requested it) a toolbar. • A help file with topics for each of the automatically generated menu items and toolbar buttons. The help author can use this framework as a starting point. • A .hm file with the topic ID to number mapping. This file can be used directly by WinHelp. • An operational What's This? Help button on the toolbar. Clicking this button puts the program into What's This? Help mode. Clicking on a menu or control then opens its help. • Shift-F1 hooked up to put the program into What's this? Help mode. • F1 hooked up to open general help for the child window with focus or the control (but not menu) on which the user is currently clicking. • When you create a dialog box, F1 hooked up to open a general help topic for the whole dialog box. • All help topics opened in the main WinHelp window. Note: • Since no dialog boxes are created in this process, you will need to add context sensitive help support for each dialog box as you create it. • Once you have the initial help file and .hm file, it is usually easier to have the help author add new topics using their preferred help authoring tool. You can still have the program generate the framework help each time you build, because that will give you appropriate additional topic mapping entries. Connecting WinHelp to C++/MFC Programs 2 Set the Help File Name The default help file name for an MFC generated program is the name of the executable with a .hlp extension. If your help file is named anything else, you need to set the m_pszHelpFilePath variable before using the built in help features of MFC so that the program knows the help file to call. To set the help file name for MFC calls: • Set the m_pszHelpFilePath variable member of the application class in the InitInstance function. m_pszHelpFilePath is a public variable of type const char*. According to MS, you should first free the memory associated with the default string (the app name with a .hlp extension). //First free the string allocated by MFC at CWinApp startup. //The string is allocated before InitInstance is called. free((void*)m_pszHelpFilePath); //Change the name of the .HLP file. //The CWinApp destructor will free the memory. m_pszHelpFilePath=_tcsdup(_T("d:\\somedir\\myhelp.hlp")); Tips: • m_pszHelpFilePath can be changed at runtime, so you can reset it in code as needed to call additional help files. • If you have more than one help file to call from the program you should put the code for changing help file names in a separate subroutine. This makes any changes during the project much easier to implement. • You can let the help author edit the help file name and window specification by putting them in a separate text file. Setting this file up in INI file format lets you use standard INI file commands to access this "text database." Make Sure WinHelp Can Find the Help File Make sure that WinHelp can always find the help file. Since your program can be started from shortcuts created by the user, the installation program should register the help file or you should call help from your program using the full path and file name. If the help system contains more than one .hlp file and a master Table of Contents (.cnt file), and not all of these are in the same folder, it will be necessary to register the help file and the master TOC to make the master TOC work, regardless of any other issues. To ensure that the program and WinHelp can always find the help file: • Register the help file by creating a string value under HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Help. The name of the string value is the help file name (without path) and the value is the path. • Always use the full path and file name when setting m_pszHelpFilePath, even if the help file is in the same folder as the program executable. Connecting WinHelp to C++/MFC Programs 3 Manually Add the Context Hooks If you already have a program and need to add help, you can manually edit the files to create the necessary hooks. To add context sensitive help manually: 1. Add the necessary message map entries in the message map of the Main Frame class. If you created the program with the MFC App Wizard and specified that you wanted context help, these items should already be in the file. ON_COMMAND(ID_HELP_FINDER, CMDIFrameWnd::OnHelpFinder) ON_COMMAND(ID_HELP, CMDIFrameWnd::OnHelp) ON_COMMAND(ID_CONTEXT_HELP, CMDIFrameWnd::OnContextHelp) ON_COMMAND(ID_DEFAULT_HELP, CMDIFrameWnd::OnHelpFinder) 2. Copy the What's This? Help icon into a button on your toolbar. This icon is available as a bitmap in C:\Program Files\Microsoft Visual Studio\Common\Graphics\Bitmaps\OffCtlBr\Small\Color\help.bmp. 3. Assign ID_CONTEXT_HELP to the What's This? Help button. Note: • This creates the same basic hooks in the program as the App Wizard, but does not generate a framework help file or the .hm file with the topic ID mapping. You will need to create a list of IDs for the help author to use. Override the Default Context Help Behavior The default WinHelp call made from the hooks automatically created by the App Wizard opens each help topic in the main WinHelp window. Unfortunately the current recommended behavior is: • Control level help is opened in a popup. • Window level help is opened in a secondary window. To create these conditions, you must override the default functions. To create currently recommended behavior: 1. In the Main Frame class, create an OnHelpInfo function using the Class Wizard: BOOL CMainFrame::OnHelpInfo(HELPINFO* pHelpInfo) { return TRUE; } This effectively disables the function, and is necessary because, in combination with the next override, all topics accessed through the F1 key will be called twice. Unfortunately you cannot use the OnHelpInfo function in the Main Frame since (unlike in dialog boxes) it is triggered only by the F1 key and not by Shift- F1 or the key. Connecting WinHelp to C++/MFC Programs 4 2. In the Main Frame class, create a WinHelp function using the Class Wizard: void CMainFrame::WinHelp(DWORD dwData, UINT nCmd) { CWinApp* theApp = AfxGetApp(); CString helpFilePath = theApp->m_pszHelpFilePath; switch ( dwData ) { case HIDR_MAINFRAME: case HIDR_MFCWIZTYPE: case HIDD_ABOUTBOX: case HIDD_TESTDLG: //Topics that need to go into a secondary window. helpFilePath = helpFilePath + ">second"; ::WinHelp(m_hWnd, helpFilePath, HELP_CONTEXT, dwData); break; case WHATEVER
Recommended publications
  • Context-Sensitive Help
    Module 15: Context-Sensitive Help Program examples compiled using Visual C++ 6.0 (MFC 6.0) compiler on Windows XP Pro machine with Service Pack 2. Topics and sub topics for this Tutorial are listed below: Context-Sensitive Help The Windows WinHelp Program Rich Text Format Writing a Simple Help File An Improved Table of Contents The Application Framework and WinHelp Calling WinHelp Using Search Strings Calling WinHelp from the Application's Menu Help Context Aliases Determining the Help Context F1 Help Shift-F1 Help Message Box Help: The AfxMessageBox() Function Generic Help A Help Example: No Programming Required The MAKEHELP Process Help Command Processing F1 Processing Shift-F1 Processing A Help Command Processing Example: MYMFC22B Header Requirements CStringView Class CHexView Class Resource Requirements Help File Requirements Testing the MYMFC22B Application Context-Sensitive Help Help technology is in a transition phase at the moment. The Hypertext Markup Language (HTML) format seems to be replacing rich text format (RTF). You can see this in the new Visual C++ online documentation via the MSDN viewer, which uses a new HTML-based help system called HTML Help. Microsoft is developing tools for compiling and indexing HTML files that are not shipped with Visual C++ 6.0. In the meantime, Microsoft Foundation Class (MFC) Library version 6.0 application framework programs are set up to use the WinHelp help engine included with Microsoft Windows. That means you'll be writing RTF files and your programs will be using compiled HLP files. This module first shows you how to construct and process a simple stand-alone help file that has a table of contents and lets the user jump between topics.
    [Show full text]
  • Storageworks RAID Array 200 Online Mgt Utility for Openvms AXP User's
    StorageWorks RAID Array 200 Online Management Utility for OpenVMS AXP User's Guide AA–Q6WVB–TE Digital Equipment Corporation Maynard, Massachusetts Second Printing, April 1995 The information in this document is subject to change without notice and should not be construed as a commitment by Digital Equipment Corporation. Digital Equipment Corporation assumes no responsibility for any errors that might appear in this document. The software, if any, described in this document is furnished under a license and may be used or copied only in accordance with the terms of such license. No responsibility is assumed for the use or reliability of software or equipment that is not supplied by Digital Equipment Corporation or its affiliated companies. Copyright 1995 by Digital Equipment Corporation. All rights reserved. Printed in the U.S.A. The following are trademarks of Digital Equipment Corporation: AXP, OpenVMS, StorageWorks, SWXCR, and the Digital logo. The following are third-party trademarks: Microsoft and MS-DOS are registered trademarks and Windows is a trademark of Microsoft Corporation. Intel, Intel486, and i486 are trademarks of Intel Corporation. All other trademarks and registered trademarks are the property of their respective holders. Contents Revision Record...................................................................................................................ix About This Guide ...............................................................................................................xi 1 Installing the RAID Array
    [Show full text]
  • Powerview Command Reference
    PowerView Command Reference TRACE32 Online Help TRACE32 Directory TRACE32 Index TRACE32 Documents ...................................................................................................................... PowerView User Interface ............................................................................................................ PowerView Command Reference .............................................................................................1 History ...................................................................................................................................... 12 ABORT ...................................................................................................................................... 13 ABORT Abort driver program 13 AREA ........................................................................................................................................ 14 AREA Message windows 14 AREA.CLEAR Clear area 15 AREA.CLOSE Close output file 15 AREA.Create Create or modify message area 16 AREA.Delete Delete message area 17 AREA.List Display a detailed list off all message areas 18 AREA.OPEN Open output file 20 AREA.PIPE Redirect area to stdout 21 AREA.RESet Reset areas 21 AREA.SAVE Save AREA window contents to file 21 AREA.Select Select area 22 AREA.STDERR Redirect area to stderr 23 AREA.STDOUT Redirect area to stdout 23 AREA.view Display message area in AREA window 24 AutoSTOre ..............................................................................................................................
    [Show full text]
  • Upgrading to Micro Focus Enterprise Developer 2.3 for Visual Studio Micro Focus the Lawn 22-30 Old Bath Road Newbury, Berkshire RG14 1QN UK
    Upgrading to Micro Focus Enterprise Developer 2.3 for Visual Studio Micro Focus The Lawn 22-30 Old Bath Road Newbury, Berkshire RG14 1QN UK http://www.microfocus.com Copyright © Micro Focus 2011-2015. All rights reserved. MICRO FOCUS, the Micro Focus logo and Enterprise Developer are trademarks or registered trademarks of Micro Focus IP Development Limited or its subsidiaries or affiliated companies in the United States, United Kingdom and other countries. All other marks are the property of their respective owners. 2015-09-16 ii Contents Upgrading to Enterprise Developer for Visual Studio .................................... 4 Licensing Changes ..............................................................................................................4 Resolving conflicts between reserved keywords and data item names .............................. 4 Importing Existing COBOL Code into Enterprise Developer ...............................................5 Recompile all source code .................................................................................................. 6 Upgrading from Net Express to Enterprise Developer for Visual Studio ............................. 6 An introduction to the process of upgrading your COBOL applications ................... 6 Compile at the Command Line Using Existing Build Scripts ....................................7 Debugging Without a Project ....................................................................................9 Create a project and import source ........................................................................10
    [Show full text]
  • Microsoft Staff and Student Advantage
    Microsoft Staff and Student Advantage Microsoft have launched Student Advantage to provide eligible staff and pupils with a free subscription of Microsoft Office 365 ProPlus. This allows staff and pupils to install Microsoft Office ProPlus on up to 5 devices simultaneously. This facility is available to all staff and pupils in Dundee schools exclusively through their Dundee Microsoft Office365 account. Use of this account is covered by the Acceptable Use Policy. Use is not compulsory and the facility is provided as-is. The information below is from Microsoft's Student Advantage and Office 365 FAQ blog post. What is included with Office 365 ProPlus subscription license? Office 365 ProPlus for PC (Office 2013 ProPlus base applications) Office 365 ProPlus for Mac (Office 2011 for Mac base applications) Office Mobile for iPhone/iPod Touch Office Mobile for Android Office 365 ProPlus Details How to download / What you Help and System Format get? Support Requirements Windows Server 2008 R2 Windows 7 Windows Server 2012 Windows 8 Download the application via your 32-bit Office can be installed webbased Dundee email account, See on 32-bit or 64-bit operating Below is a link to systems. details at the bottom of this page. What some excellent However 64-bit Office can you get: Word 2013 training guides on only be installed on 64-bit Excel 2013 Office 2013: operating system. To find out if you have 32-bit or PowerPoint 2013 What's new 64-bit Windows, click the start OneNote 2013 Learn the basics button, right-click Computer Office 365 Access 2013 Quick start guides then click Properties, then under ProPlus for Publisher 2013 Video tutorials System Type you should see PC Outlook 2013 Microsoft online help either 32-bit or 64-bit operating Lync 2013 resources system.
    [Show full text]
  • The Top 10 Mistakes to Avoid When Starting an Online Help Project
    Th e top 10 mistakes to avoid when starting an online help project Whitepaper Th e top 10 mistakes to avoid when starting an online help project Modern help authoring tools like RoboHelp® are very powerful and offer great flexibility to authors. However, the same power and flexibility can get new projects off to a bad start. Some mistakes are plain silly, while others can lead to hiring the wrong author, picking the wrong output format, or letting a project spin out of control in ways that call for expensive rework later. The risk involved in employing modern help authoring tools has existed ever since they appeared in 1991. Thereafter, these tools became even more powerful and feature-rich expanding the scope for errors. Two changes in the recent years can magnify the effect of such mistakes: • The ‘internalization’ of help into an accelerating documentation process In the past, help authors could make mistakes and had time to find, fix, and learn from them. But Test drive Adobe® RoboHelp 9 today, tighter time-to-market and ROI (return on investment) demands are eliminating the authors’ Try the full functionality of ability to make and learn from mistakes. It’s more important than ever to ‘get it right the first time’. RoboHelp 9 (as a part of Adobe Technical Communication Suite 3.5) • The shift from viewing online help as ‘documentation’ to ‘content’ for reuse beyond the in minutes—without downloading boundaries of the doc group the soft ware. Tutorials are also included. To test drive RoboHelp 9 Help authors now have to consider how their content may be used on a company web site, now, visit www.runaware.com/ on mobile devices, or can be found via Google searches, and more.
    [Show full text]
  • Windows 95 & NT
    Windows 95 & NT Configuration Help By Marc Goetschalckx Version 1.48, September 19, 1999 Copyright 1995-1999 Marc Goetschalckx. All rights reserved Version 1.48, September 19, 1999 Marc Goetschalckx 4031 Bradbury Drive Marietta, GA 30062-6165 tel. (770) 565-3370 fax. (770) 578-6148 Contents Chapter 1. System Files 1 MSDOS.SYS..............................................................................................................................1 WIN.COM..................................................................................................................................2 Chapter 2. Windows Installation 5 Setup (Windows 95 only)...........................................................................................................5 Internet Services Manager (Windows NT Only)........................................................................6 Dial-Up Networking and Scripting Tool....................................................................................6 Direct Cable Connection ..........................................................................................................16 Fax............................................................................................................................................17 Using Device Drivers of Previous Versions.............................................................................18 Identifying Windows Versions.................................................................................................18 User Manager (NT Only) .........................................................................................................19
    [Show full text]
  • Acronis Revive 2019
    Acronis Revive 2019 Table of contents 1 Introduction to Acronis Revive 2019 .................................................................................3 1.1 Acronis Revive 2019 Features .................................................................................................... 3 1.2 System Requirements and Installation Notes ........................................................................... 4 1.3 Technical Support ...................................................................................................................... 5 2 Data Recovery Using Acronis Revive 2019 .........................................................................6 2.1 Recover Lost Files from Existing Logical Disks ........................................................................... 7 2.1.1 Searching for a File ........................................................................................................................................ 16 2.1.2 Finding Previous File Versions ...................................................................................................................... 18 2.1.3 File Masks....................................................................................................................................................... 19 2.1.4 Regular Expressions ...................................................................................................................................... 20 2.1.5 Previewing Files ............................................................................................................................................
    [Show full text]
  • Defending Windows with Antivirus Software
    Defending Windows with Antivirus Software, December 7, 2017 With all the dangers lurking on the Internet, keeping your computer safe and clean is an important challenge. In this 90-minute session we will discuss strategies and technologies for keeping your computer safe in a networked world, with the emphasis on antivirus software. Malware The term malware is a contraction of malicious software. Put simply, malware is any piece of software that was written with the intent of doing harm to your data or device. https://www.avg.com/en/signal/what-is-malware Brief history https://en.wikipedia.org/wiki/Antivirus_software The roots of the computer virus date back as early as 1949, when the Hungarian scientist John von Neumann published the "Theory of self- reproducing automata." First computer virus ("Creeper") appeared in 1971 Term first coined in 1983. Before the Internet, computer viruses were typically spread by infected floppy disks. The late 80's and early 90's saw the birth of antivirus industry Common Malware Types https://www.veracode.com/blog/2012/10/common-malware-types-cybersecurity-101 Viruses, Worms, Trojan horses, Ransomware, Spyware, Adware, Rootkits, etc... Malware symptoms While the different types of malware differ greatly in how they spread and infect computers, they all can produce similar symptoms. Computers that are infected with malware can exhibit any of the following symptoms: Increased CPU usage Slow computer or web browser speeds Problems connecting to networks Freezing or crashing Modified or deleted files Appearance
    [Show full text]
  • Windows® Scripting Secrets®
    4684-8 FM.f.qc 3/3/00 1:06 PM Page i ® WindowsSecrets® Scripting 4684-8 FM.f.qc 3/3/00 1:06 PM Page ii 4684-8 FM.f.qc 3/3/00 1:06 PM Page iii ® WindowsSecrets® Scripting Tobias Weltner Windows® Scripting Secrets® IDG Books Worldwide, Inc. An International Data Group Company Foster City, CA ♦ Chicago, IL ♦ Indianapolis, IN ♦ New York, NY 4684-8 FM.f.qc 3/3/00 1:06 PM Page iv Published by department at 800-762-2974. For reseller information, IDG Books Worldwide, Inc. including discounts and premium sales, please call our An International Data Group Company Reseller Customer Service department at 800-434-3422. 919 E. Hillsdale Blvd., Suite 400 For information on where to purchase IDG Books Foster City, CA 94404 Worldwide’s books outside the U.S., please contact our www.idgbooks.com (IDG Books Worldwide Web site) International Sales department at 317-596-5530 or fax Copyright © 2000 IDG Books Worldwide, Inc. All rights 317-572-4002. reserved. No part of this book, including interior design, For consumer information on foreign language cover design, and icons, may be reproduced or transmitted translations, please contact our Customer Service in any form, by any means (electronic, photocopying, department at 800-434-3422, fax 317-572-4002, or e-mail recording, or otherwise) without the prior written [email protected]. permission of the publisher. For information on licensing foreign or domestic rights, ISBN: 0-7645-4684-8 please phone +1-650-653-7098. Printed in the United States of America For sales inquiries and special prices for bulk quantities, 10 9 8 7 6 5 4 3 2 1 please contact our Order Services department at 1B/RT/QU/QQ/FC 800-434-3422 or write to the address above.
    [Show full text]
  • ICUT MS Agreement 2[1].0 Order Form 8-15-2001
    Independent Colleges and Universities of Texas (ICUT)- Microsoft® Campus Agreement 2.0 Faculty/Staff Work-at-Home Media Order Form (revised 8-15-01; expires 8-31-2002) ICUT sponsors a Microsoft® Campus Agreement 2.0. Eligible schools: Abilene Christian U., Austin College, Baylor U., Concordia U. at Austin, East Texas Baptist U., Houston Baptist U., Howard Payne U., Jacksonville College, Jarvis Christian College, Le Tourneau U., Lon Morris College, Lubbock Christian U., Mc Murry U., Our Lady of the Lake U., St. Edward’s U., Southwestern Adventist U., Southwestern Christian College, Texas Christian U., Texas College, Trinity U., U. of Mary Hardin-Baylor, U. of St. Thomas. Participating colleges have paid the license fee for the media (CD-ROMs) available below that faculty/staff can order for work-at-home use. Because you are only paying for the media, the prices are very low. FCCC is providing the media and accepts both credit cards and personal checks; orders can be mailed or faxed. The license agreement with Microsoft® does not include free access to phone help from Microsoft®. Hardcopy manuals are not included but are available online from Microsoft®. There is also online help at www.microsoft.com and FCCC provides limited technical assistance by email. See the FCCC website (www.facultybuys.org) for additional information, including other discounted products and services. All disks are fully guaranteed; defective disks are replaced at no charge. All sets are fully licensed copies as long as your college Microsoft® Campus Agreement 2.0 is in place. Windows®98 SE Upgrade, Windows® Me Upgrade, and Windows® 2000 Upgrade require a previous version of Windows® on your computer.
    [Show full text]
  • Help for HTML Help
    Microsoft HTML Help Overview Microsoft® HTML Help consists of an online Help Viewer, related help components, and help authoring tools from Microsoft Corporation. The Help Viewer uses the underlying components of Microsoft Internet Explorer to display help content. It supports HTML, ActiveX®, Java™, scripting languages (JScript®, and Microsoft Visual Basic® Scripting Edition), and HTML image formats (.jpeg, .gif, and .png files). The help authoring tool, HTML Help Workshop, provides an easy-to-use system for creating and managing help projects and their related files. Features About creating help Satellite .dll files enable help in all supported languages. Now help will Newa flewatuaryess i nm thias trcelhea stehe language of the installed operating system. Microsoft® HTML Help version 1.3 contains these new features: There is now a single version of Hhupd.exe that works in all supported languages. NOTE: These enhancements are designed to make HTML Help fully compliant with the language features of Microsoft Windows® 2000. For more information on multiple language support in Windows 2000, see the Multilanguage Support white paper on the Microsoft Windows 2000 Web site. Introducing HTML Help help system or Web site. The HTML Help components HTML Help contains the following components: HTML Help ActiveX control: a small, modular program used to insert help navigation and secondary window functionality into an HTML file. The HTML Help Viewer: a fully-functional and customizable three- paned window in which online help topics can appear. Microsoft HTML Help Image Editor: an online graphics tool for creating screen shots; and for converting, editing, and viewing image files. The HTML Help Java Applet: a small, Java-based program that can be used instead of an ActiveX control to insert help navigation into an HTML file.
    [Show full text]