csdn_文档中心_如何制作和使用帮助文件.htm

来自「csdn10年中间经典帖子」· HTM 代码 · 共 513 行 · 第 1/3 页

HTM
513
字号
              Declare Function WinHelp Lib "user32" Alias 
            "WinHelpA"<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (ByVal hwnd 
            As Long, <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ByVal 
            lpHelpFile As String, <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            ByVal wCommand As Long, <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; ByVal dwData As Long) As Long ' <BR><BR>&nbsp; &nbsp; 必 须 同 一 
            行; 为WIN95,NT<BR>&nbsp; &nbsp; ' Declare Function WinHelp Lib "User" 
            (<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ByVal hwnd As 
            Integer, <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ByVal 
            lpHelpFile As String, <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            ByVal wCommand As Integer, <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; dwData As Any) As Integer ' 必 须 同 一 行; 为WIN3.X<BR><BR>&nbsp; 
            &nbsp; (2) 窗 体 文 件<BR>&nbsp; Private Sub Form_Load()<BR>&nbsp; 
            &nbsp; &nbsp; &nbsp; App.HelpFile = 
            "d:\winword\dxchlp.hlp"<BR>&nbsp; &nbsp; End Sub<BR><BR>&nbsp; 
            &nbsp; Private Sub mnuContents_Click()<BR>&nbsp; &nbsp; &nbsp; 
            &nbsp; i% = WinHelp(Form1.hwnd, App.HelpFile, HELP_CONTENTS, 
            0)<BR>&nbsp; &nbsp; End Sub<BR><BR>&nbsp; &nbsp; Private Sub 
            mnuKeySearch_Click()<BR>&nbsp; &nbsp; &nbsp; &nbsp; i% = 
            WinHelp(Form1.hwnd, App.HelpFile, HELP_KEY, 0)<BR>&nbsp; &nbsp; End 
            Sub<BR><BR>DELPHI<BR>&nbsp; 进 入DELPHI, 选File/New Project, 出 现 一 空 白 
            窗 体Form1, 加 一 个 菜 单 控 制Mainmenu1 到Form1, 双 击Mainmenu1, 设 置 其 一 级 菜 
            单, 有 二 项:(Caption 分 别 为:)File ,Help, 而File 的 下 一 级 菜 单Exit,Help 的 下 
            一 级 菜 单 为Contents, KeySearch, About, 对 应 的Name 属 性 分 别 为: 
            File1,Help1,Exit1,Contents1,KeySearch1,About1。 <BR><BR>&nbsp; &nbsp; 
            因 为 要 用 到About 关 于 窗 口, 所 以 加 入 一 新 窗 体, 其Name 属 性 为AboutBox, 再 加 入 
            一BitBtn 按 钮OKButton 到AboutBox 窗 体,OKButton 的Caption 属 性 为OK,Glyph 属 
            性 为 一 确 定 图 片 或 干 脆 为 空。 <BR><BR>&nbsp; &nbsp; 假 定 帮 助 文 件 
            是D:\WINWORD\DXCHLP.HLP。 <BR><BR>&nbsp; &nbsp; 程 序 代 码 如 下: 
            <BR>&nbsp; &nbsp; program Delhelp;<BR>&nbsp; &nbsp; uses 
            Forms,<BR>&nbsp; &nbsp; &nbsp; &nbsp; Unihelp in 'UNIHELP.PAS' 
            {Form1},<BR>&nbsp; &nbsp; &nbsp; &nbsp; Uniabout in 'UNIABOUT.PAS' 
            {AboutBox};<BR><BR>&nbsp; &nbsp; {$R *.RES}<BR>&nbsp; &nbsp; 
            begin<BR>&nbsp; &nbsp; &nbsp; &nbsp; Application.CreateForm(TForm1, 
            Form1);<BR>&nbsp; &nbsp; &nbsp; &nbsp; 
            {Application.CreateForm(TAboutBox, AboutBox);}<BR>&nbsp; &nbsp; 
            &nbsp; &nbsp; {注意注掉这一行,因为AboutBox是在运行时产生的,详见代码}<BR>&nbsp; &nbsp; 
            &nbsp; Application.Run;<BR>&nbsp; &nbsp; end.<BR><BR>&nbsp; &nbsp; 
            unit Unihelp;<BR>&nbsp; &nbsp; interface<BR>&nbsp; &nbsp; &nbsp; 
            &nbsp; uses SysUtils, WinTypes, WinProcs, Messages, Classes, 
            Graphics, Controls,Forms, Dialogs, Menus,uniAbout;<BR><BR>&nbsp; 
            &nbsp; type<BR>&nbsp; &nbsp; TForm1 = class(TForm)<BR>&nbsp; &nbsp; 
            &nbsp; &nbsp; MainMenu1: TMainMenu;<BR>&nbsp; &nbsp; &nbsp; &nbsp; 
            File1: TMenuItem;<BR>&nbsp; &nbsp; &nbsp; &nbsp; Help1: 
            TMenuItem;<BR>&nbsp; &nbsp; &nbsp; &nbsp; contents1: 
            TMenuItem;<BR>&nbsp; &nbsp; &nbsp; &nbsp; KeySearch1: 
            TMenuItem;<BR>&nbsp; &nbsp; &nbsp; &nbsp; About1: 
            TMenuItem;<BR>&nbsp; &nbsp; &nbsp; &nbsp; Exit1: 
            TMenuItem;<BR>&nbsp; &nbsp; &nbsp; &nbsp; procedure 
            Exit1Click(Sender: TObject);<BR>&nbsp; &nbsp; &nbsp; &nbsp; 
            procedure contents1Click(Sender: TObject);<BR>&nbsp; &nbsp; &nbsp; 
            &nbsp; procedure KeySearch1Click(Sender: TObject);<BR>&nbsp; &nbsp; 
            &nbsp; &nbsp; procedure About1Click(Sender: TObject);<BR>&nbsp; 
            &nbsp; private<BR>&nbsp; &nbsp; &nbsp; &nbsp; { Private declarations 
            }<BR>&nbsp; &nbsp; public<BR>&nbsp; &nbsp; &nbsp; &nbsp; { Public 
            declarations }<BR>&nbsp; &nbsp; end;<BR><BR>&nbsp; &nbsp; 
            var<BR>&nbsp; &nbsp; &nbsp; &nbsp; Form1: TForm1;<BR><BR>&nbsp; 
            &nbsp; implementation<BR>&nbsp; &nbsp; {$R *.DFM}<BR><BR>&nbsp; 
            &nbsp; procedure TForm1.Exit1Click(Sender: TObject);<BR>&nbsp; 
            &nbsp; begin<BR>&nbsp; &nbsp; &nbsp; &nbsp; Close;<BR>&nbsp; &nbsp; 
            end;<BR><BR>&nbsp; &nbsp; procedure TForm1.contents1Click(Sender: 
            TObject);<BR>&nbsp; &nbsp; begin<BR>&nbsp; &nbsp; &nbsp; &nbsp; 
            Application.HelpFile := 'd:\winword\dxchlp.hlp';<BR>&nbsp; &nbsp; 
            &nbsp; &nbsp; Application.HelpCommand(Help_Contents,0); { 显 示 帮 助 目 
            录}<BR>&nbsp; end;<BR><BR>&nbsp; &nbsp; procedure 
            TForm1.KeySearch1Click(Sender: TObject);<BR>&nbsp; &nbsp; 
            begin<BR>&nbsp; &nbsp; &nbsp; &nbsp; Application.HelpFile := 
            'd:\winword\dxchlp.hlp';<BR>&nbsp; &nbsp; &nbsp; &nbsp; 
            Application.HelpCommand(Help_PartialKey,0); { 显 示 关 键 字 搜 
            索}<BR>&nbsp; end;<BR><BR>&nbsp; &nbsp; procedure 
            TForm1.About1Click(Sender: TObject);<BR>&nbsp; &nbsp; var<BR>&nbsp; 
            &nbsp; &nbsp; &nbsp; myAbout:TAboutbox;<BR>&nbsp; &nbsp; 
            begin<BR>&nbsp; &nbsp; &nbsp; &nbsp; 
            myAbout:=TAboutbox.Create(Self);{myAbout 是 类TAboutbox 的 一 个 实 
            例}<BR>&nbsp; &nbsp; &nbsp; myAbout.ShowModal; { 显 示“ 关 于”}<BR>&nbsp; 
            end;<BR><BR>&nbsp; &nbsp; end.<BR><BR>&nbsp; &nbsp; unit 
            Uniabout;<BR><BR>&nbsp; &nbsp; interface<BR>&nbsp; &nbsp; &nbsp; 
            &nbsp; uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, 
            StdCtrls,Buttons, ExtCtrls;<BR><BR>&nbsp; &nbsp; type<BR>&nbsp; 
            &nbsp; TAboutBox = class(TForm)<BR>&nbsp; &nbsp; &nbsp; &nbsp; 
            OKButton: TBitBtn;<BR>&nbsp; &nbsp; &nbsp; &nbsp; procedure 
            OKButtonClick(Sender: TObject);<BR>&nbsp; &nbsp; private<BR>&nbsp; 
            &nbsp; &nbsp; &nbsp; { Private declarations }<BR>&nbsp; &nbsp; 
            public<BR>&nbsp; &nbsp; &nbsp; &nbsp; { Public declarations 
            }<BR>&nbsp; &nbsp; end;<BR><BR>&nbsp; &nbsp; var<BR>&nbsp; &nbsp; 
            &nbsp; &nbsp; AboutBox: TAboutBox;<BR><BR>&nbsp; &nbsp; 
            implementation<BR>&nbsp; &nbsp; {$R *.DFM}<BR><BR>&nbsp; &nbsp; 
            procedure TAboutBox.OKButtonClick(Sender: TObject);<BR>&nbsp; &nbsp; 
            begin<BR>&nbsp; &nbsp; &nbsp; &nbsp; Close;<BR>&nbsp; &nbsp; 
            end;<BR><BR>&nbsp; &nbsp; end.<BR><BR>&nbsp; &nbsp; 以 上 可 用 调 用 动 态 
            联 结 库 的 方 法,DELPHI 中 公 用 动 态 联 结 库, 常 数 等 用 不 着 声 明, 可 拿 来 就 用, 在 上 
            面 的 窗 体 中 再 加 入 二 个 按 钮,Content,Search, 输 入 以 下 代 码: <BR><BR>&nbsp; 
            &nbsp; procedure TForm1.ContentClick(Sender: TObject);<BR>&nbsp; 
            &nbsp; begin<BR>&nbsp; &nbsp; &nbsp; &nbsp; 
            WINHELP(form1.ClientHandle,<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; 'd:\winword\dxchlp.hlp',<BR>&nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            HELP_CONTENTS,0);<BR>&nbsp; &nbsp; end;<BR><BR>&nbsp; &nbsp; 
            procedure TForm1.SearchClick(Sender: TObject);<BR>&nbsp; &nbsp; 
            begin<BR>&nbsp; &nbsp; &nbsp; &nbsp; 
            WINHELP(form1.ClientHandle,<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; 'd:\winword\dxchlp.hlp',<BR>&nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HELP_KEY,0);<BR>&nbsp; 
            &nbsp; end;<BR><BR>VFP<BR>&nbsp; VFP 中 有 内 建 的 菜 单 帮 助 命 令, 另 要 将 帮 
            助 文 件 设 到 自 己 的 帮 助 文 件 处, 语 句 是:SET HELP TO 
            Drive:\Path\helpfile.hlp, 在 菜 单 位 中 显 示 帮 助 目 录 的 菜 单 项# 是_mst_help, 
            显 示 帮 助 中 关 键 字 搜 索 的 菜 单 项# 是_mst_hpsch, 现 举 一 例: 进 入VFP, 选“ 文 件”/“ 
            新 建”/“ 项 目”, 新 建 一 主 程 序main.prg, 输 入 以 下 代 码: <BR><BR>&nbsp; &nbsp; 
            SET DEFAULT TO D:\WINWORD\VFP<BR>&nbsp; &nbsp; SET HELP TO 
            D:\WINWORD\DXCHLP.HLP<BR>&nbsp; &nbsp; PUSH MENU _MSYSMENU<BR>&nbsp; 
            &nbsp; SET SYSMENU OFF<BR>&nbsp; &nbsp; DO 
            MainMenu.MPR<BR><BR>&nbsp; &nbsp; 新 建 一 主 程 序 主 菜 单MainMenu, 一 级 菜 单 
            有File 和Help, 再 设File 的 子 菜 单Exit,Help 的 子 菜 单Contents 
            和Search,Contents 的 菜 单 项# 是_mst_help, 而Search 的 菜 单 项# 是_mst_ 
            hpsch,Exit 过 程 输 入 以 下 代 码: <BR><BR>&nbsp; &nbsp; POP MENU _MSYSMENU 
            TO MASTER<BR>&nbsp; &nbsp; CLEAR EVENTS<BR>&nbsp; &nbsp; SET SYSMENU 
            TO DEFAULT<BR><BR>&nbsp; 以 上 程 序 在P133 兼 容 机, 中 文WORD6.0, 中 
            文WINDOWS95, 中 文Visual Foxpro3.0,Visual Basic4.0,Delphi1.0 上 运 行 通 
            过。<BR><BR><BR><BR>Copyright &amp;copy; 上海聚声计算机系统工程有限责任公司 1999-2000, 
            All Rights Reserved 
  <BR><BR><BR><BR><BR></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE align=center bgColor=#006699 border=0 cellPadding=0 cellSpacing=0 
width=770>
  <TBODY>
  <TR bgColor=#006699>
    <TD align=middle bgColor=#006699 id=white><FONT 
    color=#ffffff>对该文的评论</FONT></TD>
    <TD align=middle>
      <SCRIPT src="CSDN_文档中心_如何制作和使用帮助文件.files/readnum.htm"></SCRIPT>
    </TD></TR></TBODY></TABLE><BR>
<DIV align=center>
<TABLE align=center bgColor=#cccccc border=0 cellPadding=2 cellSpacing=1 
width=770>
  <TBODY>
  <TR>
    <TH bgColor=#006699 id=white><FONT 
color=#ffffff>我要评论</FONT></TH></TR></TBODY></TABLE></DIV>
<DIV align=center>
<TABLE border=0 width=770>
  <TBODY>
  <TR>
    <TD>你没有登陆,无法发表评论。 请先<A 
      href="http://www.csdn.net/member/login.asp?from=/Develop/read_article.asp?id=516">登陆</A> 
      <A 
href="http://www.csdn.net/expert/zc.asp">我要注册</A><BR></TD></TR></TBODY></TABLE></DIV><BR>
<HR noShade SIZE=1 width=770>

<TABLE border=0 cellPadding=0 cellSpacing=0 width=500>
  <TBODY>
  <TR align=middle>
    <TD height=10 vAlign=bottom><A 
      href="http://www.csdn.net/intro/intro.asp?id=2">网站简介</A> - <A 
      href="http://www.csdn.net/intro/intro.asp?id=5">广告服务</A> - <A 
      href="http://www.csdn.net/map/map.shtm">网站地图</A> - <A 
      href="http://www.csdn.net/help/help.asp">帮助信息</A> - <A 
      href="http://www.csdn.net/intro/intro.asp?id=2">联系方式</A> - <A 
      href="http://www.csdn.net/english">English</A> </TD>
    <TD align=middle rowSpan=3><A 
      href="http://www.hd315.gov.cn/beian/view.asp?bianhao=010202001032100010"><IMG 
      border=0 height=48 src="CSDN_文档中心_如何制作和使用帮助文件.files/biaoshi.gif" 
      width=40></A></TD></TR>
  <TR align=middle>
    <TD vAlign=top>百联美达美公司 版权所有 京ICP证020026号</TD></TR>
  <TR align=middle>
    <TD vAlign=top><FONT face=Verdana>Copyright &copy; CSDN.net, Inc. All rights 
      reserved</FONT></TD></TR>
  <TR>
    <TD height=15></TD>
    <TD></TD></TR></TBODY></TABLE></DIV>
<DIV></DIV><!--内容结束//--><!--结束//--></BODY></HTML>

⌨️ 快捷键说明

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