module1.bas
来自「一个简易的c++的编辑器」· BAS 代码 · 共 68 行
BAS
68 行
Attribute VB_Name = "Module1"
'Tool For SC++
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const EM_REPLACESEL = &HC2
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
Sub Main()
Dim cmdLine As New CCommandLine
Dim i As Long, hEdit As Long, s As String, j As Long, b() As Byte
If cmdLine.Count > 1 Then
hEdit = Val("&H" & cmdLine.Item(1))
Select Case cmdLine.Item(2)
Case "/insertdate" '插入日期
SendMessage hEdit, EM_REPLACESEL, True, ByVal FormatDateTime(Now, vbLongDate)
Case "/insertfilename" '插入文件名
SendMessage hEdit, EM_REPLACESEL, True, ByVal cmdLine.Item(3)
Case "/insertcomment" '插入函数头注释
s = s & "//" & String(50, "=") & vbCrLf
s = s & "//名 称: " & vbCrLf
s = s & "//功 能: " & vbCrLf
s = s & "//参 数: " & vbCrLf
s = s & "//返回值: " & vbCrLf
s = s & "//备 注: " & vbCrLf
s = s & "//作 者: " & vbCrLf
s = s & "//时 间: " & FormatDateTime(Now, vbLongDate) & " " & FormatDateTime(Now, vbLongTime) & vbCrLf
s = s & "//" & String(50, "=") & vbCrLf
SendMessage hEdit, EM_REPLACESEL, True, ByVal s
Case "/insertfile" '插入文件
Dim dlgOpen As New CFileDialog
dlgOpen.Filter = "所有文件|*.*|文本文件|*.txt|C语言代码|*.c;*.cpp;*.h|"
If dlgOpen.ShowOpen Then
Open dlgOpen.FileName For Binary As 1
s = Input(LOF(1), 1)
Close 1
SendMessage hEdit, EM_REPLACESEL, True, ByVal s
End If
Set dlgOpen = Nothing
Case "/getasc" '取ASC码
s = ""
b = StrConv(cmdLine.Item(3), vbFromUnicode)
For i = 0 To UBound(b)
s = s & "0x" & Hex$(b(i)) & ","
Next
s = Left(s, Len(s) - 1)
SendMessage hEdit, EM_REPLACESEL, True, ByVal s
End Select
If StrComp(cmdLine.Item(1), "/google", vbTextCompare) = 0 Then
s = "http://www.google.com/search?q=" & cmdLine.Item(2) & "&hl=zh-CN&inlang=zh-CN&ie=GB2312"
ShellExecute 0, vbNullString, s, vbNullString, vbNullString, 1
ElseIf StrComp(cmdLine.Item(1), "/msdn", vbTextCompare) = 0 Then
s = "http://search.microsoft.com/search/results.aspx?qu=" & cmdLine.Item(2) & "&View=msdn&st=b&c=0&s=1&swc=0'"
ShellExecute 0, vbNullString, s, vbNullString, vbNullString, 1
End If
End If
10:
Set cmdLine = Nothing
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?