Access API使用集锦
2005-10-31 12:35:48 来源:WEB开发网把以下API函数的声明添入模块文件的general declarations区域,如果您使用的是VB4-32或VB5,也可以把此声明添入Form1的general declarations中,并把所有的“Public”更换为“Private”。
Option Explicit
Public Declare Function SendMessageLong Lib _"user32" Alias "SendMessageA" _(ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ByVal lParam As Long) As Long
Public Const EM_GETLINECOUNT = &HBA
Form Code
Sub Text1_Change()
Dim lineCount as Long
On Local Error Resume Next
'得到/显示文本行数
lineCount = SendMessageLong(Text1.hwnd, EM_GETLINECOUNT, 0&, 0&)
Label1 = Format$(lineCount, "##,###")
End Sub
注释:为了使本程序成功,请在设计阶段把文本框的Multiline属性设为True。
怎样使程序的标题条闪烁?
建立新的项目文件,添加模块文件,并填写如下代码:
Public Declare Function FlashWindow _Lib "user32" (ByVal hwnd As Long, _ByVal bInvert As Long) As Long
在窗体中添加两个按钮和一个计时器,并用设置以下属性:
command1.caption="开始"
command2.caption="停止"
timer1.interval=500 '每0.5秒闪烁一次
timer1.enabled=false
Private Sub Timer1_Timer()
a& = FlashWindow(Me.hwnd, 1)
End Sub
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
更多精彩
赞助商链接