Re: [.NET] 如何設計滑鼠輔助線

看板Visual_Basic作者時間9年前 (2015/05/17 01:37), 9年前編輯推噓0(003)
留言3則, 2人參與, 最新討論串2/2 (看更多)
※ 引述《cool21540125 (cool21540125)》之銘言: : 請輸入專案類型(網站專案或者應用程式專案): : 在公司常要開啟某些財務報表,而有些數字都是密密麻麻的 : 因此,希望自寫一款有「滑鼠輔助線」功能的程式 : 當程式啟動時,螢幕上會出現一橫一豎的直線,以滑鼠的箭頭為交叉點(有點像狙擊鏡) : 滑鼠移到哪,輔助線就會以滑鼠指標為中心跟著移動 : 想請教各位前輩們,我想利用VB2010來撰寫 : 需要先從哪個方向作開始? : 自己寫程式都只會寫一些資料處理方面的應用... : 所以像是移動滑鼠,繪圖...自己幾乎是個新手 : 麻煩給個方向,感謝! 最簡單的做法,幾個API而己,沒有那麼難(VB6) Option Explicit Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hdc As Long) As Long Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As Any) As Long Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long Private Type POINTAPI x As Long y As Long End Type Dim Dc As Long Dim P0 As POINTAPI, P As POINTAPI Private Sub Form_Load() Dc = GetDC(0) Me.WindowState = 2 Timer1.Interval = 10 Me.Hide End Sub Private Sub Form_Unload(Cancel As Integer) ReleaseDC 0, Dc End Sub Private Sub Timer1_Timer() GetCursorPos P If Abs(P0.x - P.x) > 1 Or Abs(P0.y - P.y) > 1 Then P0 = P 'Form1.Caption = "mouse Cursor at " + CStr(P.x) + "," + CStr(P.y) Me.Show DoEvents Me.Hide MoveToEx Dc, 0, P.y, 0 LineTo Dc, GetSystemMetrics(0&), P.y MoveToEx Dc, P.x, 0, 0 LineTo Dc, P.x, GetSystemMetrics(1&) End If End Sub -- ████ █ ★ ████ █ █ █ █ █ █ █ █ █ 超 級 熱 烈 歡 迎 █ ████ █ █ █ ████ █ █ █ █ █ ███★ █ █ 歡迎到嘉義版! ★███ █ █ █ █ █ █ █ 訊馳電腦-路徑嘉義市林森西路496號(05)2244-526順發斜對面 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 218.166.150.180 ※ 文章網址: https://www.ptt.cc/bbs/Visual_Basic/M.1431797874.A.6FC.html ※ 編輯: chinoyan (218.166.150.180), 05/17/2015 01:40:39

05/17 11:25, , 1F
對新手而言一點教學意義都沒有
05/17 11:25, 1F

05/18 04:12, , 2F
我都沒用hook了,幾個api應用,google一下就懂了,
05/18 04:12, 2F

05/18 04:12, , 3F
範例都給了,只要肯GOOGLE,API的用途,怎麼會沒意義
05/18 04:12, 3F
文章代碼(AID): #1LLu1oRy (Visual_Basic)
討論串 (同標題文章)
文章代碼(AID): #1LLu1oRy (Visual_Basic)