【BCB】【問題】請教如何改變滑鼠移動方式 ? |
尚未結案
|
hicke
一般會員 發表:2 回覆:3 積分:1 註冊:2005-04-25 發送簡訊給我 |
想要設計滑鼠往上移動,
而螢幕上的指標卻往下跑,
而滑鼠往下移,
指標卻會往上跑得程式,
但是卻無法達到預期效果,
請問要如何將程式修改呢?
謝謝!
void __fastcall TForm1::OnMouseMove(TObject *Sender, TShiftState Shift,int X, int Y)
{
TPoint pt;
int i;
i=Y-pt.y; //滑鼠移動i單位
Y=pt.y-i; //讓滑鼠的座標往反方向移動
pt=Form1->ClientToScreen(Point(X,Y));
SetCursorPos(pt.x,pt.y); //設定滑鼠座標位置
Y=pt.y;
}
|
windblown
中階會員 發表:0 回覆:117 積分:98 註冊:2003-11-14 發送簡訊給我 |
void __fastcall TForm1::OnMouseMove(TObject *Sender, TShiftState shift,int X, int Y) { static TPoint aOldPoint; // 以 static 來紀錄舊的位置 static bool isFirst = true; // 是否為第一次 TPoint aCurrPoint; aCurrPoint = Form1->ClientToScreen(Point(X,Y)); if ( isFirst ) { isFirst = false; aOldPoint = aCurrPoint; } else { SetCursorPos(aCurrPoint.x, 2*aOldPoint.y-aCurrPoint.y); // 相反方向 aOldPoint = aCurrPoint; } } |
hicke
一般會員 發表:2 回覆:3 積分:1 註冊:2005-04-25 發送簡訊給我 |
|
windblown
中階會員 發表:0 回覆:117 積分:98 註冊:2003-11-14 發送簡訊給我 |
原來你要的是「整個螢幕」呀!! 這樣的話,你就要用 Hook 的方法,請參考
http://delphi.ktop.com.tw/quicksearch.exe/quicksearch?SearchStr=hook mousemove
|
hicke
一般會員 發表:2 回覆:3 積分:1 註冊:2005-04-25 發送簡訊給我 |
經過兩個多禮拜的研究
還是搞不太懂HOOK
而一般的C++的書也很少看到有介紹HOOK
而在研究的過程中用Sleep函式放慢滑鼠的移動速度
發現還需要在程式中加上一行否則
鼠標會不斷的上下震盪直到鼠標跑出From之外
還有請問要怎麼用HOOK改寫呢
void __fastcall TForm1::OnMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { static TPoint aOldPoint; // 以 static 來紀錄舊的位置 static bool isFirst = true; // 是否為第一次 TPoint aCurrPoint; aCurrPoint = Form1->ClientToScreen(Point(X,Y)); if ( isFirst ) { isFirst = false; aOldPoint = aCurrPoint; } else { SetCursorPos(aCurrPoint.x, 2*aOldPoint.y-aCurrPoint.y); // 相反方向 aOldPoint = aCurrPoint; isFirst = true; // } }發表人 - hicke 於 2005/05/25 10:50:57 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |