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

首頁 > 開發 > 綜合 > 正文

使用VB在應用程序中注冊熱鍵

2024-07-21 02:20:58
字體:
來源:轉載
供稿:網友
'窗體中
option explicit

private sub form_load()
dim ret as long
'記錄原來的window程序地址
prewinproc = getwindowlong(me.hwnd, gwl_wndproc)
'用自定義程序代替原來的window程序
ret = setwindowlong(me.hwnd, gwl_wndproc, addressof wndproc)
idhotkey = 1 'in the range &h0000 through &hbfff
modifiers = mod_alt '輔助鍵為alt
uvirtkey1 = vbkeyq '注冊的熱鍵為alt+q
'注冊熱鍵
ret = registerhotkey(me.hwnd, idhotkey, modifiers, uvirtkey1)
if ret = 0 then
msgbox "注冊熱鍵失敗,請使用其它熱鍵!", vbcritical, "錯誤"
end if
end sub

private sub form_queryunload(cancel as integer, unloadmode as integer)
dim ret as long
'取消message的截取,使之送往原來的window程序
ret = setwindowlong(me.hwnd, gwl_wndproc, prewinproc)
call unregisterhotkey(me.hwnd, uvirtkey1)
end sub

'模塊中

'以下程序放在模塊中
option explicit

declare function setwindowlong lib "user32" alias "setwindowlonga" (byval hwnd as long, byval nindex as long, byval dwnewlong as long) as long
declare function getwindowlong lib "user32" alias "getwindowlonga" (byval hwnd as long, byval nindex as long) as long
declare function callwindowproc lib "user32" alias "callwindowproca" (byval lpprevwndfunc as long, byval hwnd as long, byval msg as long, byval wparam as long, byval lparam as long) as long
declare function registerhotkey lib "user32" (byval hwnd as long, byval id as long, byval fsmodifiers as long, byval vk as long) as long
declare function unregisterhotkey lib "user32" (byval hwnd as long, byval id as long) as long

public const wm_hotkey = &h312
public const mod_alt = &h1
public const mod_control = &h2
public const mod_shift = &h4
public const gwl_wndproc = (-4)

public prewinproc as long
public modifiers as long, uvirtkey1 as long, idhotkey as long

private type talong
ll as long
end type

private type t2int
lword as integer
hword as integer
end type

public function wndproc(byval hwnd as long, byval msg as long, byval wparam as long, byval lparam as long) as long
dim lp as talong, i2 as t2int

if msg = wm_hotkey then
if wparam = idhotkey then
lp.ll = lparam
lset i2 = lp
if (i2.lword = modifiers) and i2.hword = uvirtkey1 then
form1.visible = not form1.visible
end if
end if
end if
'如果不是熱鍵信息則調用原來的程序
wndproc = callwindowproc(prewinproc, hwnd, msg, wparam, lparam)
end function


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 湾仔区| 新乡市| 宁明县| 平江县| 溆浦县| 建宁县| 垦利县| 团风县| 滦南县| 平泉县| 康平县| 临沧市| 正阳县| 宣城市| 盐边县| 独山县| 奈曼旗| 九台市| 土默特右旗| 上犹县| 库伦旗| 武冈市| 土默特右旗| 通道| 瑞丽市| 兴业县| 象山县| 延长县| 策勒县| 保山市| 利川市| 惠来县| 莱西市| 夹江县| 奉新县| 卢龙县| 克拉玛依市| 称多县| 个旧市| 北川| 故城县|