How to create a tri-pane HTML Help window with WIN32 SDK programming

Source: Internet
Author: User
Tags definition valid win32 knowledge base

HTML help enables users to use a tool bar, view directories, and help topics in one of the helping Windows. Currently, there are two ways to create a Tri-pane type of HTML Help window:

Create a window using HTML Help Workshop

Using the HTML Help API to programmatically create a window

This article describes how to create a tri-pane HTML Help window using both of these methods.

Use a predefined window

It is easy to create and modify a project's window definition in an HTML Help Workshop environment, for additional information about window definitions, refer to Microsoft Knowledge Base article: Q189084 howto:create a tri-pane window with HTML help works Hop

This article assumes that in your application development tool for Visual C + +, you have to use HTML Help in your own program, and you must rely on the API functions provided by HTML Help; To invoke these API functions, you must include the Htmlhelp.h file and hhct the library file Rl.lib or Htmlhelp.lib are linked to their own program code. As soon as you install the HTML Help Workshop environment, these files are stored in the \include and \lib directories under HTML Help Workshop.

In the following demo code, Sample.chm is a compiled HTML Help file with a window definition called "Mywindow," which demonstrates how to invoke the HTML Help API function in an MFC program:

// CMainFrame message handler
  void CMainFrame::OnHelp()
  {
   // display the topic "intro.htm" in the window defined
   // in the HTML Help Workshop
    HtmlHelp(m_hWnd,"sample.chm::\\intro.htm>mywindow",
     HH_DISPLAY_TOPIC,0);
  }

Using the HTML Help API

In order to create a three-pane window, you must first create and fill in the Hh_wintype structure. The HH_WINTYPE structure is defined in HtmlHelp.h and is described in detail in the HTML Help Workshop documentation. Here is an example:

Sample Code


  ///////////////////////////////////////////


//Create an HH_WINTYPE structure.


  {


Hh_wintype M_hhwintype;


//Initialize all structure to zero.


ZeroMemory (&m_hhwintype, sizeof (Hh_wintype));


//Define a custom message for use with idnotify.


//You are responsible for ensuring so this ID


//Does not conflict and other WINDOWS/MFC messages.


#define IDD_HELPTAB 69999


//Set the size of the structure.


m_hhwintype.cbstruct = sizeof (Hh_wintype);


//Set up the properties of the HTML window:


//Tripane window, sync topic with INDEX/TOC, and so forth.


//Note:fsvalidmembers-hhwin_param_properties must is set.


m_hhwintype.fswinproperties = Hhwin_prop_tri_pane |


Hhwin_prop_auto_sync;


//Put back, home, FORWARD, and EXPAND buttons on toolbar pane.


//Note:fsvalidmembers-hhwin_param_tb_flags must is set.


m_hhwintype.fstoolbarflags = Hhwin_button_back |


Hhwin_button_home | Hhwin_button_forward |


Hhwin_button_expand;


//The file is in the right pane. The full path isn't needed.


m_hhwintype.pszfile = "intro.htm";


Full Paths or CHM locations of various files (if used).


//To specify that's a file is within a CHM and use the following


//Syntax: "Chmfilename.chm::\\filename.xxx"


//Home Page:


m_hhwintype.pszhome = "c:\\mypath\\intro.htm";


//Table of Contents:


M_hhwintype.psztoc = "C:\\MYPATH\\CONTENTS.HHC";


//Index:


M_hhwintype.pszindex = "C:\\MYPATH\\INDEX.HHK";


//expansion width of navigation Pane (left pane):


//Note:fsvalidmembers-hhwin_param_nav_width must is set.


m_hhwintype.inavwidth = 175;


//Initial display state:


//Note:fsvalidmembers-hhwin_param_showstate must is set.


m_hhwintype.nshowstate = Sw_restore;


//TOC should be activated.


Note:fsvalidmembers-hhwin Param_cur_tab must is set.


m_hhwintype.curnavtype = Hhwin_navtype_toc;


//Tabs on top.


//Note:fsvalidmembers-hhwin_param_tabpos must is set.


m_hhwintype.tabpos = hhwin_navtab_top;


//ID to use in WPARAM in wm_notify:


m_hhwintype.idnotify = Idd_helptab;


//Title of help Window:


m_hhwintype.pszcaption= "My Title";


//Indicate which fields in structure are valid.


m_hhwintype.fsvalidmembers = Hhwin_param_styles |


Hhwin_param_properties | Hhwin_param_rect |


Hhwin_param_tb_flags | Hhwin_param_nav_width |


Hhwin_param_showstate | Hhwin_param_tabpos |


Hhwin_param_cur_tab;


//Specify the name of the window definition.


M_hhwintype.psztype = "Mywindowname";


//This call creates the "new type" from the "values in
"

//the HH_WINTYPE structure. This is example assumes that


//A valid CHM file, "Sample.chm", exists.


HtmlHelp (m_hwnd, "C:\\mypath\\sample.chm",


Hh_set_win_type, (DWORD) &m_hhwintype);


  }


//Display The default topic in the window this was defined above


//MFC ' s CFRAMEWND::ONHELP message handler.


void Cmainframe::onhelp ()


  {


HtmlHelp (m_hwnd, "Sample.chm>mywindowname",


hh_display_topic,0);


  }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.