📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "VB调用CHM帮助文件的两种方法"
ClientHeight = 3195
ClientLeft = 4950
ClientTop = 2250
ClientWidth = 4680
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "Form1.frx":0000
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
Begin VB.Frame Frame1
Caption = "作者:网络大盗"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1695
Left = 240
TabIndex = 2
Top = 1320
Width = 4095
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "QQ:67616520"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 180
Left = 1560
MouseIcon = "Form1.frx":030A
MousePointer = 99 'Custom
TabIndex = 7
Top = 1320
Width = 1080
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "E-mail:yhj0502@163.com"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 180
Left = 1560
MouseIcon = "Form1.frx":0614
MousePointer = 99 'Custom
TabIndex = 6
Top = 960
Width = 2070
End
Begin VB.Label Label3
AutoSize = -1 'True
BackColor = &H8000000A&
Caption = "中国海燕网"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 180
Left = 1560
MouseIcon = "Form1.frx":091E
MousePointer = 99 'Custom
TabIndex = 5
Top = 480
Width = 900
End
Begin VB.Label Label2
Caption = "联系作者:"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 4
Top = 960
Width = 975
End
Begin VB.Label Label1
Caption = "作者主页:"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 3
Top = 480
Width = 975
End
End
Begin VB.CommandButton Command2
Caption = "方法二"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2400
TabIndex = 1
Top = 240
Width = 1815
End
Begin VB.CommandButton Command1
Caption = "方法一"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 480
TabIndex = 0
Top = 240
Width = 1575
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "方法一:还可以按F1调出帮助文件"
ForeColor = &H000000FF&
Height = 180
Left = 840
TabIndex = 8
Top = 960
Width = 2940
End
Begin VB.Menu help
Caption = "方法一"
Begin VB.Menu h
Caption = "help"
End
End
Begin VB.Menu help2
Caption = "方法二"
Begin VB.Menu help22
Caption = "help"
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'方法一
Option Explicit
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_SHOW = 5
'方法二
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
Const HH_DISPLAY_TOPIC = &H0
Const HH_DISPLAY_INDEX = &H2
Const HH_HELP_CONTEXT = &HF
Const HH_DISPLAY_SEARCH = &H3
Const HH_DISPLAY_TEXT_POPUP = &HE
'接着指定CHM文件的名称和位置:
Private Sub Command1_Click()
Dim nRet As Integer
'如果这个工程没有帮助文件,显示消息给用户
'可以在“工程属性”对话框中为应用程序设置帮助文件
If Len(App.HelpFile) = 0 Then
MsgBox "无法显示帮助目录,该工程没有相关联的帮助。", vbInformation, Me.Caption
Else
On Error Resume Next
SendKeys "{F1}"
If Err Then
MsgBox Err.Description
End If
End If
End Sub
Private Sub Command2_Click()
HtmlHelpA Form1.hWnd, App.Path & "\help.CHM", 0, 0
End Sub
Private Sub Frame1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label3.ForeColor = &H80000012
Label4.ForeColor = &H80000012
Label5.ForeColor = &H80000012
End Sub
Private Sub h_Click()
Command1_Click
End Sub
Private Sub help22_Click()
Command2_Click
End Sub
Private Sub Label3_Click()
Call ShellExecute(Me.hWnd, "open", "http://chinahy.y365.com", "", "", SW_SHOW)
End Sub
Private Sub Label3_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label3.BorderStyle = 1
Label3.BackColor = &HC0FFFF
Label3.ForeColor = &HFF&
End Sub
Private Sub Label3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label3.ForeColor = vbRed
End Sub
Private Sub Label3_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label3.BorderStyle = 0
Label3.BackColor = &H8000000F
Label3.ForeColor = &H80000012
End Sub
Private Sub Label4_Click()
Call ShellExecute(Me.hWnd, "open", "mailto:yhj0502@163.com", "", "", SW_SHOW)
End Sub
Private Sub Label4_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label4.BorderStyle = 1
Label4.BackColor = &HC0FFFF
Label4.ForeColor = &HFF&
End Sub
Private Sub Label4_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label4.ForeColor = vbRed
End Sub
Private Sub Label4_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label4.BorderStyle = 0
Label4.BackColor = &H8000000F
Label4.ForeColor = &H80000012
End Sub
Private Sub Label5_Click()
Call ShellExecute(Me.hWnd, "open", "http://search.tencent.com/cgi-bin/friend/user_show_info?ln=67616520", "", "", SW_SHOW)
End Sub
Private Sub Label5_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label5.BorderStyle = 1
Label5.BackColor = &HC0FFFF
Label5.ForeColor = &HFF&
End Sub
Private Sub Label5_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label5.ForeColor = vbRed
End Sub
Private Sub Label5_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label5.BorderStyle = 0
Label5.BackColor = &H8000000F
Label5.ForeColor = &H80000012
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -