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

首頁(yè) > 開(kāi)發(fā) > 綜合 > 正文

用ImessageFilter實(shí)現(xiàn)截獲鍵盤(pán)動(dòng)作

2024-07-21 02:29:08
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

imessagefilter 接口
imessagefilter 接口允許應(yīng)用程序在消息被調(diào)度到控件或窗體之前捕獲它。

可以將實(shí)現(xiàn) imessagefilter 接口的類添加到應(yīng)用程序的消息泵中,以在消息被調(diào)度到控件或窗體之前將

它篩選出來(lái)或執(zhí)行其他操作。若要將消息篩選器添加到應(yīng)用程序的消息泵中,請(qǐng)使用 application 類中的

addmessagefilter 方法。


application.addmessagefilter 方法

添加消息篩選器以便在向目標(biāo)傳送 windows 消息時(shí)監(jiān)視這些消息。
[visual basic]
public shared sub addmessagefilter( byval value as imessagefilter )

參數(shù)
value
您要安裝的 imessagefilter 接口的實(shí)現(xiàn)。
備注
使用消息篩選器來(lái)防止引發(fā)特定事件,或在將某事件傳遞給事件處理程序之前使用消息篩選器對(duì)其執(zhí)行特

殊操作。消息篩選器對(duì)特定線程是唯一的。
若要防止調(diào)度某消息,傳遞給該方法的 value 參數(shù)實(shí)例必須用處理該消息的代碼重寫(xiě) prefiltermessage 方法

。該方法必須返回 false。
警告 向應(yīng)用程序的消息泵添加消息篩選器會(huì)降低性能。
示例
[visual basic, c#, c++] 必須先提供 imessagefilter 接口的一個(gè)實(shí)現(xiàn),然后才可以使用消息篩選器。

下面的類創(chuàng)建一個(gè)名為 testmessagefilter 的消息篩選器。此篩選器阻止與鼠標(biāo)左鍵有關(guān)的所有消息。
[visual basic]
' creates a message filter.
public class testmessagefilter
implements imessagefilter

public function prefiltermessage(byref m as system.windows.forms.message) _
as boolean implements imessagefilter.prefiltermessage
' blocks all the messages relating to the left mouse button.
if ((m.msg >= 513) and (m.msg <= 515)) then
console.writeline("processing the messages : " & m.msg)
return true
end if
return false
end function
end class

 

用esc鍵退出程序

  
   implements imessagefilter

  private sub form1_load(byval sender as system.object, byval e as system.eventargs) handles

mybase.load
'assign message to app and form
application.addmessagefilter(me)
end sub


  public function prefiltermessage(byref m as system.windows.forms.message) as boolean

implements imessagefilter.prefiltermessage

dim keycode as keys = ctype(m.wparam.toint32(), keys) and keys.keycode
if keycode = keys.escape then
end  '結(jié)束程序。我們?cè)诖丝梢哉{(diào)用各種方法、過(guò)程。
end if
   end function



發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 祁东县| 喀什市| 历史| 山东省| 陕西省| 宁夏| 婺源县| 虎林市| 东明县| 若尔盖县| 太原市| 区。| 樟树市| 柞水县| 阿图什市| 平阴县| 鄱阳县| 赤壁市| 远安县| 资溪县| 长治县| 丹江口市| 东明县| 区。| 佳木斯市| 和静县| 米泉市| 依兰县| 江安县| 喀喇沁旗| 新蔡县| 江津市| 凭祥市| 墨竹工卡县| 安国市| 江都市| 咸宁市| 宁夏| 隆德县| 鲁山县| 措勤县|