Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Jumping to an anchor in CHM<br> Tested with Delphi2010 - DelphiXE2 - Windows XP</p> <p>How to jump to an <strong>anchor</strong> in a chm file (Compiled HTML Help) with Delphi.</p> <p><strong>Yes, it is possible with a HtmlHelp() command to jump to an anchor.</strong><br> <code>&lt;a name="my_anchor"&gt;&lt;/a&gt;</code></p> <pre><code> HtmlHelp(0,hpPath+'::/Overview.htm#UsingtheMenus&gt;main',HH_DISPLAY_TOPIC,DWORD(nil)); </code></pre> <p><strong>The LINK in :</strong> Overview.htm </p> <ul> <li>Note: This link is <strong>not needed</strong> to jump via the delphi program to<br> the anchor.(Only for testing).</li> </ul> <p>Overview.htm</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"&gt; &lt;HTML&gt; [...] &lt;BODY bgColor=#f7f8e2&gt; &lt;H1&gt;Overview&lt;/H1&gt; &lt;A HREF="Overview.htm#UsingtheMenus"&gt;Using the Menus&lt;/A&gt; [...] </code></pre> <p><strong>The ANCHOR in :</strong> Overview.htm</p> <pre><code>[...] &lt;A NAME="UsingtheMenus" &lt;/A&gt; &lt;P&gt;&lt;STRONG&gt;Using the Menus and Toolbars&lt;/STRONG&gt; [...] </code></pre> <p><strong>If anyone wants to try it.</strong></p> <p>Here are more information and a testprogram:</p> <p><img src="https://i.stack.imgur.com/tj58L.jpg" alt="enter image description here"></p> <p>Run Project1.exe and select <strong>without :</strong></p> <p><img src="https://i.stack.imgur.com/AZZAh.jpg" alt="enter image description here"></p> <p>The Unit1.pas / the command</p> <pre><code>procedure TForm1.Button2Click(Sender: TObject); begin HtmlHelp(0,hpPath+'::/Overview.htm#UsingtheMenus&gt;main',HH_DISPLAY_TOPIC,DWORD(nil)); end; </code></pre> <ul> <li>click the Button <code>Overview.htm#UsingtheMenus</code></li> </ul> <p>The Result:</p> <p>The Help file is opened and the <code>overview.htm</code> appears. It was <strong>jumped to the anchor.</strong></p> <p><img src="https://i.stack.imgur.com/mUyKL.jpg" alt="enter image description here"></p> <hr> <p>Download source Project1.exe D2010 and XE2.<br> Download source sample.chm HtmlHelp project.</p> <p><a href="http://moskito-x.de/stack/stackdwl.html" rel="nofollow noreferrer"><strong>Download</strong></a></p> <hr> <p><strong>Now let's test the other 2 Buttons</strong></p> <pre><code>procedure TForm1.HelpKeywordClick(Sender: TObject); begin Application.HelpKeyword('UsingtheMenus'); end; procedure TForm1.HelpContextClick(Sender: TObject); begin Application.HelpContext(IDH_UsingtheMenus); end; </code></pre> <ul> <li>Click the Button <code>HelpKeyword('UsingtheMenus')</code></li> </ul> <p>The Result:</p> <p>The Help file is opened and the <code>FirstTopic.htm</code> appears. The text <code>UsingtheMenus</code> is inserted into the searchfield. <strong>No jump to the anchor!</strong></p> <hr> <ul> <li>Click the Button <code>HelpContext(IDH_UsingtheMenus)')</code></li> </ul> <p>The same result except the search box is empty.</p> <hr> <p><strong>The last 2 clicks demonstrate here:</strong><br> There are <strong>no secret IDs or keywords</strong> in the file HelpFile2\sample.chm available.</p> <hr> <p><strong>Now we change the help file so</strong> that in addition to <code>Overview.htm#UsingtheMenus</code> the other two methods lead to success.</p> <ul> <li>Close the App 'Project.exe`</li> <li>Run 'Project.exe` again.</li> <li>Make sure the <code>with</code> is selected.</li> </ul> <p>Now we use "sample.chm" in folder HelpFile\<br> with the following settings.</p> <p>sample.h</p> <p><code>#define IDH_Creating_Projects_and_Topics 1005</code><br> <code>#define IDH_Overview 1003</code><br> <code>#define IDH_UsingtheMenus 1009</code></p> <p>sample.ali</p> <p><code>IDH_Overview=Overview.htm</code><br> <code>IDH_welcom=FirstTopic.htm</code><br> <code>IDH_UsingtheMenus=Overview.htm#UsingtheMenus</code></p> <p>sample.hcc</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"&gt; &lt;HTML&gt; [...] &lt;LI&gt; &lt;OBJECT type="text/sitemap"&gt; &lt;param name="Name" value="Using the Menus"&gt; &lt;param name="Local" value="Overview.htm#UsingtheMenus"&gt; &lt;/OBJECT&gt; [...] &lt;/HTML&gt; </code></pre> <p>sample.hhk</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"&gt; &lt;HTML&gt; [...] &lt;LI&gt; &lt;OBJECT type="text/sitemap"&gt; &lt;param name="Name" value="Using the Menus"&gt; &lt;param name="Name" value="Using the Menus"&gt; &lt;param name="Local" value="Overview.htm#UsingtheMenus"&gt; &lt;/OBJECT&gt; [...] &lt;/HTML&gt; </code></pre> <p>If we compile "sample.chm", we get an error message.</p> <p><code>HHC3015: Warning: An alias has been created to "Overview.htm#UsingtheMenus" but the file does not exist.</code></p> <p>This is normal because the file "Overview.htm#UsingtheMenus" does not really exist !</p> <p><strong>Let's try it</strong></p> <p>Do not forget, the "Help window" after trying each of the following, to close again. Otherwise you can not track the different states.</p> <ul> <li>Click the Button <code>HelpKeyword('UsingtheMenus')</code></li> </ul> <p><img src="https://i.stack.imgur.com/okcjb.jpg" alt="enter image description here"></p> <p>The Result:<br> The Help file is opened and the <code>FirstTopic.htm</code> appears. The text <code>UsingtheMenus</code> is inserted into the searchfield. The text <code>UsingtheMenus</code> is selected in the listbox<br> If you click <code>Show</code><br> It was <strong>jumped to the anchor.</strong></p> <hr> <ul> <li>Click the Button <code>HelpContext(IDH_UsingtheMenus)')</code></li> </ul> <p>The Result:</p> <p>The Help file is opened and the <code>overview.htm</code> appears. It was <strong>jumped to the anchor.</strong></p> <hr> <ul> <li>click the Button <code>Overview.htm#UsingtheMenus</code></li> </ul> <p>The Result:</p> <p>Same result as above.<br> The Help file is opened and the <code>overview.htm</code> appears. It was <strong>jumped to the anchor.</strong></p> <hr> <p><strong>Now we can use one of three methods to jump to the desired mark.</strong></p> <hr> <p>If anyone is interested in the functioning of the other buttons, then read on and get more information.</p> <p>will be continued tomorrow.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload