Depends, what cursors you want to change. You may want to change some of the standard cursors. Or the default (normal) cursor of some (or all) installer window controls.
Changing standard cursors
You can hardly change these for the installer process only, without using some external DLL library.
With Inno Setup itself only, you can change a system cursors. But this will affect all other applications, while the installer is running.
[Files]
Source: "MyCursor.cur"; Flags: dontcopy
[Code]
const
OCR_NORMAL = 32512;
function SetSystemCursor(hcur: LongWord; id: DWORD): BOOL;
external 'SetSystemCursor@user32.dll stdcall';
function LoadCursorFromFile(lpFileName: string): LongWord;
external 'LoadCursorFromFileW@user32.dll stdcall';
function CopyIcon(hIcon: LongWord): LongWord;
external 'CopyIcon@user32.dll stdcall';
function LoadCursor(hInstance: LongWord; lpCursorName: LongWord): LongWord;
external 'LoadCursorA@user32.dll stdcall';
var
OriginalCursor: LongWord;
procedure InitializeWizard();
var
PathToCursorFile: string;
Cursor: LongWord;
begin
// Remember the original custom
OriginalCursor := CopyIcon(LoadCursor(0, OCR_NORMAL));
// Load our cursor
ExtractTemporaryFile('MyCursor.cur')
PathToCursorFile := ExpandConstant('{tmp}\MyCursor.cur');
Cursor := LoadCursorFromFile(PathToCursorFile);
SetSystemCursor(Cursor, OCR_NORMAL);
end;
procedure DeinitializeSetup();
begin
// Restore original cursor on exit
SetSystemCursor(OriginalCursor, OCR_NORMAL);
end;
Changing default (normal) cursor of some (or all) installer window controls
[Files]
Source: "MyCursor.cur"; Flags: dontcopy
[Code]
const
GCL_HCURSOR = (-12);
function LoadCursorFromFile(lpFileName: string): LongWord;
external 'LoadCursorFromFileW@user32.dll stdcall';
function SetClassLong(hWnd: HWND; Index, NewLong: Longint): Longint;
external 'SetClassLongA@user32 stdcall';
procedure InitializeWizard();
var
PathToCursorFile: string;
Cursor: LongWord;
begin
ExtractTemporaryFile('MyCursor.cur')
PathToCursorFile := ExpandConstant('{tmp}\MyCursor.cur');
Cursor := LoadCursorFromFile(PathToCursorFile);
SetClassLong(WizardForm.NextButton.Handle, GCL_HCURSOR, Cursor);
end;
The above code changes cursor for the Next button. If you want to use the same custom cursor for all control, you can iterate the control tree.
procedure SetControlsCursor(Control: TWinControl; Cursor: LongWord);
var
I: Integer;
begin
SetClassLong(Control.Handle, GCL_HCURSOR, Cursor);
for I := 0 to Control.ControlCount - 1 do
begin
if Control.Controls[I] is TWinControl then
begin
SetControlsCursor(TWinControl(Control.Controls[I]), Cursor);
end;
end;
end;
procedure InitializeWizard();
...
begin
...
SetControlsCursor(WizardForm, Cursor);
end;