YOU CAN CODE!

 

With The Case Of UCanCode.net  Release The Power OF  Visual C++ !   HomeProducts | PurchaseSupport | Downloads  
Download Evaluation
Pricing & Purchase?
E-XD++Visual C++/ MFC Products
Overview
Features Tour 
Electronic Form Solution
Visualization & HMI Solution
Power system HMI Solution
CAD Drawing and Printing Solution

Bar code labeling Solution
Workflow Solution

Coal industry HMI Solution
Instrumentation Gauge Solution

Report Printing Solution
Graphical modeling Solution
GIS mapping solution

Visio graphics solution
Industrial control SCADA &HMI Solution
BPM business process Solution

Industrial monitoring Solution
Flowchart and diagramming Solution
Organization Diagram Solution

Graphic editor Source Code
UML drawing editor Source Code
Map Diagramming Solution

Architectural Graphic Drawing Solution
Request Evaluation
Purchase
ActiveX COM Products
Overview
Download
Purchase
Technical Support
  General Q & A
Discussion Board
Contact Us

Links

Get Ready to Unleash the Power of UCanCode .NET

 


UCanCode Software focuses on general application software development. We provide complete solution for developers. No matter you want to develop a simple database workflow application, or an large flow/diagram based system, our product will provide a complete solution for you. Our product had been used by hundreds of top companies around the world!

"100% source code provided! Free you from not daring to use components because of unable to master the key technology of components!"


VC++ MFC Tutorial: Adding Context Help to your application HtmlHelp

 
By kokholm. 

This short article demonstrates the ability to add Context Help to your application.

Introduction

Adding context help to your application expands the use and enhances the user experience. The context help can be recognized by the arrow cursor associated with the question mark. Dialog boxes supporting this can be recognized by the ? icon in the upper right-hand corner of the box. How to install Microsoft HTML Help 1.4 SDK... read the story at Microsoft.

User Enhancements

If the users have trouble understanding the function of some of the controls, the solution is to click the icon, move the cursor into the control of question, and left-click the mouse. Alternative is for controls that have input focus without generating a command message (like edit controls), is simply pressing the F1 key that has the same effect. A popup window appears containing help text that you declared.

Four steps

Adding context help using the HTML popup can be described in four steps:

  1. Enable the context help for the dialog at the 'Dialog Properties' 'Extended Styles' page.
  2. Assign help text for the control in your 'String Table'.
  3. Trap the WM_HELPINFO message in the dialog box class.
  4. Copy-paste the code below into your desired class.
BEGIN_MESSAGE_MAP(CDlg, CDialog)
 ON_WM_HELPINFO()
END_MESSAGE_MAP()

It is important that the ID used in your String Table is the same you named the control, try using the combo box at the 'String Properties' dialog.

Ready for Message Handler

The message handler for the WM_HELPINFO message goes like this:

afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);

BOOL CDlg::OnHelpInfo(HELPINFO* pHelpInfo) 
{
 // This method does all the work    
 ShowContextHelp(CWnd::FromHandle((HWND)pHelpInfo->hItemHandle), 
  pHelpInfo->MousePos, pHelpInfo->iCtrlId);

 // We will proceed the message, so skip the base class
 // return CDialog::OnHelpInfo(pHelpInfo);
 return TRUE;  
}

As mentioned in the comment, the ShowContextHelp(...) is the method that has our attention. The method takes three arguments: a pointer to the window, the POINT structure where the help request occurred, and the identification for the control.

Collapse
void CDlg::ShowContextHelp(CWnd* pWnd, POINT pt, int iCtrlID)
{
CString s;

 // Load help text from String Table
 if(s.LoadString(iCtrlID))
 {
  HH_POPUP hPop; // HTML Help popup structure

  // Initialize structure to NULLs    
  memset(&hPop, 0, sizeof(hPop)); 

  // Set size of structure
  hPop.cbStruct         = sizeof(hPop);        

  // Yellow background color
  hPop.clrBackground    = RGB(255, 255, 208);    

  hPop.clrForeground    = -1; // Font color    
  hPop.rcMargins.left   = -1;             
  hPop.rcMargins.bottom = -1;
  hPop.rcMargins.right  = -1;
  hPop.pt               = pt;    
  hPop.pszText          = s; // Message from String Table
  hPop.pszFont          = NULL; // Font
    
  HtmlHelp(pWnd->GetSafeHwnd(), NULL, 
   HH_DISPLAY_TEXT_POPUP, (DWORD)&hPop);
 } // End if found a help string for this request
} // End ShowContextHelp(...)

The HH_POPUP structure is used to display the context help in a popup window. The structure has members for setting the foreground/background colors, for adjusting where the popup will be displayed, and for selecting the font to use. If you skip the first parameter, by typing NULL, you will experience that the popup window is acting like a modeless dialog, which was not the intention.

The second parameter for the HtmlHelp(...) method points to a file object where the string resource also could be placed.

Hope you will find it useful.

 

 

Copyright ?1998-2009 UCanCode.Net Software , all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.

Please direct your questions or comments to webmaster@ucancode.net