Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const
- HighCursor = 13;
- type
- TForm1 = class(TForm)
- Timer1: TTimer;
- Label1: TLabel;
- procedure FormCreate(Sender: TObject);
- procedure Timer1Timer(Sender: TObject);
- private
- FCursorHandles: array [0..HighCursor] of HCURSOR;
- public
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- const
- OEMCursors: array [0..HighCursor] of Integer = (OCR_NORMAL, OCR_IBEAM,
- OCR_WAIT, OCR_CROSS, OCR_UP, OCR_SIZENWSE, OCR_SIZENESW, OCR_SIZEWE,
- OCR_SIZENS, OCR_SIZEALL, OCR_NO, OCR_HAND, OCR_APPSTARTING,
- 32651 {OCR_HELP?});
- CursorNames: array [0..HighCursor] of string = ('OCR_NORMAL', 'OCR_IBEAM',
- 'OCR_WAIT', 'OCR_CROSS', 'OCR_UP', 'OCR_SIZENWSE', 'OCR_SIZENESW',
- 'OCR_SIZEWE', 'OCR_SIZENS', 'OCR_SIZEALL', 'OCR_NO', 'OCR_HAND',
- 'OCR_APPSTARTING', 'OCR_HELP');
- procedure TForm1.FormCreate(Sender: TObject);
- var
- i: Integer;
- begin
- for i := 0 to HighCursor do
- FCursorHandles[i] := LoadImage(0, MakeIntResource(OEMCursors[i]),
- IMAGE_CURSOR, 0, 0, LR_DEFAULTCOLOR or LR_DEFAULTSIZE or LR_SHARED);
- end;
- procedure TForm1.Timer1Timer(Sender: TObject);
- function GetCursorName(Cursor: HCURSOR): string;
- var
- i: Integer;
- begin
- for i := 0 to HighCursor do
- if Cursor = FCursorHandles[i] then begin
- Result := CursorNames[i];
- Exit;
- end;
- Result := 'Unknown Cursor'; // A custom cursor.
- end;
- var
- CursorInfo: TCursorInfo;
- begin
- CursorInfo.cbSize := SizeOf(CursorInfo);
- if GetCursorInfo(CursorInfo) then
- Label1.Caption := GetCursorName(CursorInfo.hCursor)
- else
- Label1.Caption := 'Fail: ' + SysErrorMessage(GetLastError);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement