Disable Printing in HtmlHelp

I am performing maintenance on an outdated MFC application. We need to disable the "Print" button in the "Help" dialog box. The printer is not connected to the system, and the application crashes if the user clicks the Print button in the help window.

This code simply uses the standard method HtmlHelpAto invoke the Windows help dialog:

void CNiftyView::OnHelp() 
{
   CString csHelpFile;
   csHelpFile.Format( "%s/NiftyHelp.chm", NiftyDoc::GetHelpPath() );
   ::HtmlHelpA( m_hWnd, csHelpFile, HH_HELP_CONTEXT, IDH_NIFTY_SECTION );
}

I found information that we can suppress the Print button with some code in the HTML help stylesheet ( http://www.sagehill.net/docbookxsl/HtmlHelp.html ). But this will require recompiling the help file, and I would prefer not to. I also found some information saying that you can customize the HTML help viewer by manipulating each structure of the HH_WINTYPE panel, but no information on how you actually do this ( http://msdn.microsoft.com/en -us / library / ms524435% 28v = vs. 85% 29.aspx ).

Is there a way to disable this Print button in the HTML help viewer programmatically?

+5
source share
2 answers

CHM "" :

++ *:

HH_WINTYPE *pwt = NULL;
LPCWSTR pszFile = L"MyFile.chm";
LPCWSTR pszWin = L"MyFile.chm>Main"; // "Main" is the window type defined in the CHM file

// Get the window type definition
HWND hWndHelp = HtmlHelp(NULL, pszWin, HH_GET_WIN_TYPE, (DWORD) &pwt);

if (pwt) {
    // Copy the contents of the returned structure
    HH_WINTYPE wt = *pwt;

    // Remove the "Print" toolbar button from the window definition
    wt.fsToolBarFlags &= ~HHWIN_BUTTON_PRINT;
    wt.cbStruct = sizeof(wt); // force the correct size

    // Set the new window type
    hWndHelp = HtmlHelp(NULL, pszFile, HH_SET_WIN_TYPE, (DWORD) &wt);

    // Display help
    hWndHelp = HtmlHelp(NULL, pszFile, HH_DISPLAY_TOPIC, NULL);
}

++, . , .

HH_WINTYPE, HH_GET_WIN_TYPE HH_SET_WIN_TYPE:
HTML
HTML Help API Visual #

+6

, ""?

0

All Articles