




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、1 一個(gè)鼠標(biāo)類#region 一個(gè)鼠標(biāo)類 2 /*/ <summary> 3 / Mouse Control 4 / Made by Michael 5 / date 2008-0
2、1-30 6 / </summary> 7 class Mouse 8 9 internal const byte SM_MOUSEPRESENT = 19; 10
3、; internal const byte SM_CMOUSEBUTTONS = 43; 11 internal const byte SM_MOUSEWHEELPRESENT = 75; 12 13 inter
4、nal struct POINTAPI 14 15 internal int x; 16 internal int y;
5、;17 18 19 internal struct RECT 20 21 internal int
6、160;left; 22 internal int top; 23 internal int right; 24 &
7、#160;internal int bottom; 25 26 27 System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SwapMouseButton") 28
8、0; internal extern static int SwapMouseButton(int bSwap); 29 30 System.Runtime.InteropServices.DllImport("user32", EntryPoint = "ClipCursor") 31
9、; internal extern static int ClipCursor(ref RECT lpRect); 32 33 System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = &qu
10、ot;GetCursorPos") 34 internal extern static int GetCursorPos(ref POINTAPI lpPoint); 35 36 System.Runtime.InteropServices.DllImport("user32.
11、dll", EntryPoint = "ShowCursor") 37 internal extern static bool ShowCursor(bool bShow); 38 39 System.Runtime.InteropServices.DllImport(&
12、quot;user32.dll", EntryPoint = "EnableWindow") 40 internal extern static int EnableWindow(int hwnd, int fEnable); 41 42 System
13、.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "GetWindowRect") 43 internal extern static int GetWindowRect(int hwnd, ref RECT lpRect); 44
14、60;45 System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetCursorPos") 46 internal extern static int SetCursorPos(int x,
15、160;int y); 47 48 System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "GetSystemMetrics") 49 internal extern static int&
16、#160;GetSystemMetrics(int nIndex); 50 51 System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetDoubleClickTime") 52 internal ext
17、ern static int SetDoubleClickTime(int wCount); 53 54 System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "GetDoubleClickTime") 55
18、160; internal extern static int GetDoubleClickTime(); 56 57 System.Runtime.InteropServices.DllImport("kernel32.DLL", EntryPoint = "Sleep") 58 &
19、#160; internal extern static void Sleep(int dwMilliseconds); 59 60 /得到鼠標(biāo)相對(duì)與全屏的坐標(biāo),不是相對(duì)與你的Form的,且與你的分辨率有關(guān)系 61 62 public static int
20、FullScreenPosition_X 63 64 get 65 66
21、; POINTAPI _POINTAPI = new POINTAPI(); 67 68 GetCursorPos(ref _POINTAPI); 69 70
22、0; return _POINTAPI.x; 71 72 73 74 public
23、160;static int FullScreenPosition_Y 75 76 get 77 78
24、0; POINTAPI _POINTAPI = new POINTAPI(); 79 80 GetCursorPos(ref _POINTAPI); 81 82
25、60; return _POINTAPI.y; 83 84 85 86 &
26、#160; /隱藏 顯示 鼠標(biāo) 87 public static void Hide() 88 89 ShowCursor(false);
27、160;90 91 92 public static void Show() 93 94 ShowCu
28、rsor(true); 95 96 97 /將鼠標(biāo)鎖定在你的Form里 不過你得將你的Form先鎖了,Form Resize 就失效了 98 public
29、0;static void Lock(System.Windows.Forms.Form ObjectForm) 99 100 RECT _FormRect = new RECT();101102
30、160; GetWindowRect(ObjectForm.Handle.ToInt32(), ref _FormRect);103104 ClipCursor(ref _FormRect);105 106107
31、160; public static void UnLock()108 109 RECT _ScreenRect = new RECT();110111
32、 _ScreenRect.top = 0;112 _ScreenRect.left = 0;113 _ScreenRect.bottom = System.Windows.Forms.Screen.
33、PrimaryScreen.WorkingArea.Bottom;114 _ScreenRect.right = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Right;115116 ClipCursor(ref
34、0; _ScreenRect);117 118119 /鼠標(biāo)失效,不過失效的好像不只是鼠標(biāo),小心哦 120 public static void Disable(System.Windows.Forms.Form ObjectForm)121
35、160; 122 EnableWindow(ObjectForm.Handle.ToInt32(), 0);123 124125 public static void
36、160;Enable(System.Windows.Forms.Form ObjectForm)126 127 EnableWindow(ObjectForm.Handle.ToInt32(), 1);128 129
37、; / 得到你的鼠標(biāo)類型 130 public static string Type131 132 get133 &
38、#160; 134 if (GetSystemMetrics(SM_MOUSEPRESENT) = 0)135
39、0; 136 return "本計(jì)算機(jī)尚未安裝鼠標(biāo)"137 138
40、60; else139 140
41、;if (GetSystemMetrics(SM_MOUSEWHEELPRESENT) != 0)141 142
42、160; return GetSystemMetrics(SM_CMOUSEBUTTONS) + "鍵滾輪鼠標(biāo)"143 144
43、0; else145 146
44、 return GetSystemMetrics(SM_CMOUSEBUTTONS) + "鍵鼠標(biāo)"147 148
45、0; 149 150 151152 / 設(shè)置鼠標(biāo)雙擊時(shí)間153 public static void DoubleClickTime_Set(int MouseDoubleClickTime)154 155
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 普定縣中醫(yī)醫(yī)院招聘筆試真題2024
- 活動(dòng)總結(jié)范文2020社區(qū)活動(dòng)總結(jié)
- 項(xiàng)目部二級(jí)安全教育內(nèi)容
- 湘藝版二年級(jí)下冊(cè)教案-第四課 排排坐
- 2025年抗滴蟲病藥項(xiàng)目合作計(jì)劃書
- 2025年雙頭應(yīng)急燈合作協(xié)議書
- 2025年機(jī)器人及具有獨(dú)立功能專用機(jī)械項(xiàng)目建議書
- 多國(guó)教育資源協(xié)作的醫(yī)療應(yīng)用案例研究
- 2025年虛擬演播室制作設(shè)備項(xiàng)目發(fā)展計(jì)劃
- 企業(yè)采購決策中的智慧供應(yīng)鏈建設(shè)研究
- 物業(yè)員工夏季防暑培訓(xùn)
- 2025-2030益智玩具行業(yè)市場(chǎng)深度分析及前景趨勢(shì)與投資研究報(bào)告
- 吉林會(huì)考地理試題及答案
- 小學(xué)科學(xué)探究式學(xué)習(xí)活動(dòng)方案
- 《計(jì)算機(jī)視覺技術(shù)》課件
- 2025至2030年P(guān)P環(huán)保料托盤項(xiàng)目投資價(jià)值分析報(bào)告
- 防洪防汛安全教育知識(shí)培訓(xùn)
- 用電檢查員技能培訓(xùn)課件-三相四線計(jì)量裝置錯(cuò)接線分析及操作
- 遠(yuǎn)景能源考試題目及答案
- DB42-T 2046-2023 水文自動(dòng)測(cè)報(bào)站運(yùn)行維護(hù)技術(shù)規(guī)范
- 常年法律顧問勞動(dòng)法專項(xiàng)法律服務(wù)工作方案
評(píng)論
0/150
提交評(píng)論