先上核心代码,稍后会打包
Private Sub Form_Load()
m_InitKeyWord
VBCode = MyTBox.Text
g_TextHwnd = MyTBox.hwnd
'复制文本框的字体,注意不能用Font属性,另外个别英文字体可能不支持,需进行编码转换
Me.FontName = MyTBox.FontName
Me.FontSize = MyTBox.FontSize
Me.FontBold = MyTBox.FontBold
Me.FontItalic = MyTBox.FontItalic
Me.ScaleMode = vbPixels
g_LineHeight = Me.TextHeight("0")
optColor(0).Value = True
Me.Show
SetHook
chkHook.Value = 1
End Sub
Private Sub Form_Unload(Cancel As Integer)
Unhook
End Sub
Private Sub chkHook_Click()
g_Hook = chkHook.Value
MyTBox.Refresh
End Sub
'VB关键字
Sub m_InitKeyWord()
g_KeyWord = Array("#Const", "#If", "#Else", "Let", "Const", "Dim", "Private", _
"Public", "New", "Static", "Option", "Not", "And", "Or", "Xor", "Eqv", "Imp", _
"Mod", "Like", "Is", "Error", "Raise", "On", "GoTo", "Resume", "Do", "Loop", "For", _
"Next", "Each", "While", "Wend", "With", "If", "Then", "Else", "ElseIf", "Select", _
"Case", "Switch", "Call", "Function", "Sub", "End", "Exit", "Get", "Set", "Property", _
"Open", "Close", "As", "Print", , "Input", "Line", "Put", "Seek", "TypeOf", "Nothing", _
"AddressOf", "ByRef", "ByVal", "Empty", "False", "Friend", _
"Optional", "Lock", "Step", "To", "True", "WithEvents", "Explicit", "Base", "Declare", _
"Type", "Lib", "Alias", "Enum", "ReDim", "Preserve", "Write", "Begin", "Erase", "GoSub", _
"Return", "Stop", "RaiseEvent", "Compare", "Debug", _
"CBool", "CByte", "CCur", "CDate", "CDbl", "CDec", "CInt", "CLng", _
"CSng", "CStr", "CVar", "LBound", "UBound", _
"Long", "Integer", "Single", "Double", "String", "Boolean", "Date", _
"Byte", "Currency", "Decimal", "Object", "Variant", "Any")
g_KeyLength = UBound(g_KeyWord) + 1
End Sub