国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

VB編程實用精典小技巧3例

2019-11-18 17:41:02
字體:
來源:轉載
供稿:網友
一、利用API獲取窗口的標題
新建窗體Form1和按鈕Command1ぴ詿疤迥?櫓刑砑尤縵麓碼:
OptionExplicit
PrivateDeclareFunctionGetWindowTextLib"us—
er32"Alias"GetWindowTextA"(ByValhwndAs
Long,ByVallpStringAsString,ByValcchAs
Long)AsLong
'在窗體聲明節中加入API函數“GetWindowText”的說明
'函數將向lpstring中載入要獲得的窗體caption
PrivateSubCommand1_Click()
DimreturncodeAsLong
DimcaptextAsString
DimcaplenAsLong
captext=String$(100,0)
caplen=99
returncode=GetWindowText(ByValme.hwnd,
ByValcaptext,ByValcaplen)
printreturncode
Printcaptext
Printcaplen
EndSub

二、獲取鼠標在當前窗口(客戶區)的屏幕坐標そ立一新項目窗體form1并添加控件文本框Text1、Text2ぴ詿疤迥?櫓惺淙耄邯
OptionExplicit
PrivateDeclareFunctionGetCursorPosLib"user32"
(lpPointAsPOINTAPI)AsLong
PrivateTypePOINTAPI
XAsLongYAsLong
EndType
DimptAsPOINTAPI
DimreturncodeAsLong
PrivateSubForm_Load()
Text1.Text=""
Text2.Text=""
MaxButton=False
MinButton=False
Form1.WindowState=2
EndSub
PrivateSubForm_MouseMove(ButtonAsInteger,
ShiftAsInteger,XAsSingle,YAsSingle)
'注意pt結構是按引用傳遞的
returncode=GetCursorPos(pt)
Text1.Text=pt.X
Text2.Text=pt.Y
EndSub

三、記錄Windows使用時間
建立新項目窗口form1,輸入代碼:
PrivateSubForm_Load()
form1.visible=false
Openapp.paht+"memo.txt"ForAppendAs#1
Print#1,"啟動windows:"&CStr(Now)
Close#1
EndSub
PrivateSubForm_Unload(CancelAsInteger)
Openapp.paht+"memo.txt"ForAppendAs#1
Print#1,"關閉windows:"&CStr(Now)
Close#1
End
EndSub
最后將此程序加入啟動組即可。

->


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 仙居县| 黎川县| 收藏| 宝鸡市| 安吉县| 棋牌| 石景山区| 崇阳县| 安图县| 普陀区| 阿合奇县| 尼勒克县| 伊川县| 景谷| 兴义市| 崇阳县| 山阳县| 万全县| 临清市| 岳池县| 疏勒县| 保康县| 茶陵县| 佛山市| 乌苏市| 铜梁县| 江都市| 西安市| 莫力| 色达县| 乌兰察布市| 天柱县| 沧州市| 临朐县| 清涧县| 泗洪县| 台东市| 威宁| 岢岚县| 彭州市| 宿州市|