csh_formview.shtml

来自「mfc资源大全包含MFC编程各个方面的源码」· SHTML 代码 · 共 126 行

SHTML
126
字号
<HTML>

<!-- Header information-->
<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="Author" CONTENT="Chris Maunder">
   <TITLE>Misc - Implementing ToolTip Style Context Sensitive Help in CFormView based Applications</TITLE>
</HEAD>

<!-- Set background properties -->
<body background="../fancyhome/back.gif" bgcolor="#FFFFFF" link="#B50029" vlink="#8E2323" alink="#FF0000">

<!-- A word from our sponsors... -->
<table WIDTH="100%">
<tr WIDTH="100%"><td align=center><!--#exec cgi="/cgi/ads.cgi"--><td></tr>
</table>


<!-- Article Title -->
<CENTER><H3><FONT COLOR="#AOAO99">
Implementing ToolTip Style Context Sensitive Help in CFormView based Applications
</FONT></H3></CENTER>
<CENTER><H3><HR></H3></CENTER>

<!-- Author and contact details -->
This article was contributed by <A HREF="mailto:yawar@isb.comsats.net.pk">Yawar Jawaad Maajed</A>.

<!-- Sample image and source code/demo project -->
<P>
&nbsp;<A HREF="csh.zip">Download Source Code and Example</A>
</p>
<br>

<!-- The article... -->

<p><B>Steps Required</B></P>

<P><B>1.</B> In your form view or in the dialogs
you are working with, turn &quot;Help ID&quot; property on for every control
you want to have context sensitive help.</P>

<CENTER><P><IMG SRC="csh1.gif" HEIGHT=162 WIDTH=403></P></CENTER>

<P><B>2.</B> #define a double word Array in your View class as
<FONT COLOR="#990000"><TT><PRE>static const DWORD m_nHelpIDs[];
</tt></PRE></FONT>

<P>and in your Implementation do the following:
<FONT COLOR="#990000"><TT><PRE>const DWORD COurView::m_nHelpIDs[] = 
{
	CONTROL ID, HELP ID GENERATED WITH MAKEHM TOOL,
	0,0
};
</tt></PRE></FONT>

<p>In our case declaration of help IDs array is as</P>

<FONT COLOR="#990000"><TT><PRE>static const DWORD m_nHelpIDs[];
</tt></PRE></FONT>

<P>and these IDs are defined as
<FONT COLOR="#990000"><TT><PRE>const DWORD CCSHView::m_nHelpIDs[] = 
{
	IDC_BUTTON_HELP ,HIDC_BUTTON_HELP,

	//define other controls IDs here.

	0,0
};
</tt></PRE></FONT>

<P><B>3.</B> Include <B>resource.hm</B> file in your View.CPP file.</P>

<P><B>4. </B>Open your application's HPJ (help project file) and add the
following line at the end of the file

<FONT COLOR="#990000"><TT><PRE>#include &lt;D:\Development\CSH\resource.hm&gt;</P>
</tt></PRE></FONT>

<P>The path will differ according to the location of your project.</P>

<P><B>5. </B>Now override two functions of your CFormView based class.
One is WM_CONTEXTMENU and other is WM_HELPINFO. </P>

<P>Fill the functions' bodies as follows.</P>

<FONT COLOR="#990000"><TT><PRE>
/////////////////////////////////////////////////////////////////////////////
// CCSHView message handlers

void CCSHView::OnContextMenu(CWnd* pWnd, CPoint point)
{
	::WinHelp(pWnd-&gt;m_hWnd, AfxGetApp()-&gt;m_pszHelpFilePath, HELP_CONTEXTMENU,
	          (DWORD)(LPVOID)m_nHelpIDs);</P>
}

BOOL CCSHView::OnHelpInfo(HELPINFO* pHelpInfo)
{
	return ::WinHelp((HWND)pHelpInfo-&gt;hItemHandle, AfxGetApp()-&gt;m_pszHelpFilePath,
	                 HELP_WM_HELP, (DWORD)(LPVOID)m_nHelpIDs); 
}
</tt></PRE></FONT>

<P><B>6.</B> Now Open Microsoft Word (or any other RTF word processor)
&quot;AfxCore.RTF&quot; file located in your projects HLP directory. This
file was generated by Application Wizard. </P>

<P><B>7.</B> In Tools menu click Options and then highlight &quot;View&quot;
tab. Then turn &quot;Hidden Text&quot; check box on which is in the group
&quot;Non Printing characters&quot;. Now Click &quot;Show/Hide&quot; button
<IMG SRC="csh2.gif" HEIGHT=31 WIDTH=59></P>

<P><B>8.</B> Now navigate to the end of file and press Ctrl + Enter to
enter a hard page break.</P>

<P><B>9.</B> Type help text here for the first control. In our case it
is IDC_BUTTON_HELP. We type &quot;Displays detailed help for the
application&quot; here. </P>

<P><B>10. </B>Now go to beginning of the line and insert a footnote with
a custom mark &quot;#&quot; and in the footnote type HIDC_BUTTON_HELP here.
Click in the view window again.</P>

<P><B>11. </B>Now to see a question mark icon in the title bar of the application
go to your application's CMainFrame class's add the following lines in
your CMainFrame::PreCreateWindow(厖

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?