如何攔截游標閃爍訊息? |
尚未結案
|
m0210
一般會員 發表:31 回覆:29 積分:17 註冊:2002-08-23 發送簡訊給我 |
|
flyup
資深會員 發表:280 回覆:508 積分:385 註冊:2002-04-15 發送簡訊給我 |
The 2 functions you'll need are: GetCursorPos
SetSystemCursor (be very careful when working with this one). Both functions are documented in the Win32 SDK help file, available with Delphi sample: unit Unit1; interface uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls; type
TForm1 = class(TForm)
Timer1: TTimer;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
lbXPos: TLabel;
lbYPos: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
lbXPosWin: TLabel;
lbYPosWin: TLabel;
Bevel1: TBevel;
procedure Timer1Timer(Sender: TObject);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
NewArrow, NewHourGlass : HCursor;
OldArrow, OldHourGlass : HCursor;
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Timer1Timer(Sender: TObject);
var
CPos : TPoint;
begin
// This will retrieve the current position of the cursor,
// relative to the desktop.
// since there are no messages that will provide this
// information when the cursor is outside the current
// window, we have to put it inside a TTimer or call
// GetCursorPos whenever the information is wanted.
GetCursorPos(CPos);
lbXPos.caption := inttostr(CPos.x);
lbYPos.caption := inttostr(CPos.y);
end; procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
lbXPosWin.Caption := inttostr(x);
lbYPosWin.Caption := inttostr(y);
end; procedure TForm1.FormCreate(Sender: TObject);
begin // Load the new cursor from file.
// This could also be done if the cursors were stored
// in a resource in the executable or another DLL,
// but then we'd have to use LoadCursor instead.
NewArrow := LoadCursorFromFile('3dsarro.cur');
NewHourGlass := LoadCursorFromFile('3dswait.cur'); // BAckup the existing cursors, since they'll be destroyed
// once we call SetSystemCursor. Not doing this can cause
// an unrecoverable system crash.
OldArrow := LoadCursor(0, IDC_ARROW);
OldHourGlass := LoadCursor(0, IDC_WAIT); // Replace the system cursors with the ones we loaded from
// file. The new cursors will be valid as long as the
// application is running.
SetSystemCursor(NewArrow, OCR_NORMAL);
SetSystemCursor(NewHourGlass, OCR_WAIT); end; procedure TForm1.FormDestroy(Sender: TObject);
begin
// Right before the application is destroyed, we have to
// restore the backed-up cursors. The cursors we loaded
// from file will be destroyed with the rest of the
// application, so we need to set the cursors back to
// whatever they were before.
SetSystemCursor(OldArrow, OCR_NORMAL);
SetSystemCursor(OldHourGlass, OCR_WAIT);
end; end. 發表人 - flyup 於 2003/02/22 22:37:06
|
領航天使
站長 發表:12216 回覆:4186 積分:4084 註冊:2001-07-25 發送簡訊給我 |
|
flyup
資深會員 發表:280 回覆:508 積分:385 註冊:2002-04-15 發送簡訊給我 |
|
領航天使
站長 發表:12216 回覆:4186 積分:4084 註冊:2001-07-25 發送簡訊給我 |
|
flyup
資深會員 發表:280 回覆:508 積分:385 註冊:2002-04-15 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |