Mega Code Archive

 
Categories / Delphi / Graphic
 

How to utilize animated cursors

Title: How to utilize animated cursors 1.} procedure TForm1.FormCreate(Sender: TObject); begin Screen.Cursors[crMyCursor] := LoadCursorFromFile('c:\mystuff\mycursor.ani'); Cursor := crMyCursor; end; {*****************************************************************} {2.} { by Blodgett} Const CURSOR_HOURGLASS = 1; {...} procedure TForm1.LoadCursors; var h : THandle; begin if FileExists('..\Images\YourAnimagedCursor.ani') then begin h := LoadImage(0, '..\Images\YourAnimatedCursor.ani', IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE or LR_LOADFROMFILE); if h 0 then Screen.Cursors[1] := h; end; end; procedure TForm1.BitBtn1Click(Sender: TObject); var FCurrentCursor: Integer; begin //1st - Load Cursors Information LoadCursors; //2nd - Set FCurrentCursor variable // to current screen cursor. FCurrentCursor := Screen.Cursor; //3rd - Set Screen.Cursor to your CONST Value. // this is your animated cursor. Screen.Cursor := CURSOR_HOURGLASS; //4th - Do something ... sleep(2000); //5th - Set Screen.Cursor to original cursor. Screen.Cursor := FCurrentCursor; end;