Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A practical method for VB.NET to call CHM help

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

VB.NET calls the practical method of CHM help, and I believe that many inexperienced people are at a loss about it. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

VB.NET calls CHM help in a number of ways. Then the specific method to be used should be chosen according to the different environment in our actual programming. First of all, let's get a preliminary understanding of these ways in which VB.NET calls CHM help, so that we can make a choice.

No matter how well an application is written, in many cases users will ask questions about how to use it. Visual Basic provides support for two different help systems: the traditional Windows help system (WinHelp) and the new HTML help (CHM help). When we have made the help file, we need to write code in the appropriate place in the program to make the call, and we will discuss several ways to call the CHM help file in the program.

When VB.NET calls the CHM help method, use the F1 key:

This method is the simplest and requires only the following code:

Private Sub Form_Load () App.HelpFile = app.path & "\ help.chm" 'call the help.chm help file in the same directory as the main program and press F1 to call End Sub

VB.NET calls CHM help method two using the SendKeys method:

Private Sub Form_Load () App.HelpFile = app.path & "\ help.chm" End Sub private Sub CmdHelp_Click () SendKeys "{F1}" 'send keystrokes to the active window End Sub

VB.NET calls the CHM help method three using the Shell function:

Private Sub CmdHelp_Click () Shell "hh.exe help.chm", vbNormalFocus' help.chm is the specified help file and may contain the path. End Sub

VB.NET calls CHM help method four using the HtmlHelp function:

Declare the following API first:

Option Explicit

Private Declare Function HtmlHelpA Lib "hhctrl.ocx"

(ByVal hwndCaller As Long, ByVal pszFile As String

ByVal uCommand As Long, ByVal dwData As Long) As Long

'hwndCaller specifies the caller's window, and pszFile specifies the file to be called

UCommand is the command sent to HtmlHelp, and dwData is the parameter of uCommand.

Then call in the procedure:

Private Sub CmdHelp_Click () dim i as string i = app.path & "\ help.chm" 'record the help.chm help file HtmlHelpA Form1.hWnd, I, 0,0 End Sub in the same directory as the main program with variable I

VB.NET calls CHM help method five uses the ShellExecute function:

Declare the following API first:

Option Explicit

'declare the API function to open a document asynchronously

Private Declare Function ShellExecute Lib

"shell32.dll" Alias "ShellExecuteA"

(ByVal hwnd As Long, ByVal lpOperation As String

ByVal lpFile As String, ByVal lpParameters As String

ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Const SW_SHOWNORMAL = 1

Then call in the procedure:

Private Sub CmdHelp_Click () dim an as long Dim b As String b = App.Path & "\ help.chm" 'record the help.chm help file a = ShellExecute (0, "open", b, ", SW_SHOWNORMAL) End Sub in the same directory as the main program with variable b

The above five VB.NET methods for calling CHM help have their own advantages and disadvantages, and from the simplicity of the code, the second method is recommended. Functionally, the fifth method is recommended, as it is not only used to open CHM help files, but also to open, print, or find a file or document in the same format (see the description of the API).

After reading the above, have you mastered the practical method of VB.NET calling CHM help? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report