The code that triggers "
read-only property. Compile aborted" error is:
function Dir_Icon(): Integer;
var
TypRect: TRect;
Icon: THandle;
TypImg: TBitmapImage;
begin
TypRect.Left := 0;
TypRect.Top := 0;
TypRect.Right := GetSystemMetrics(SM_CXICON);
TypRect.Bottom := GetSystemMetrics(SM_CYICON);
Icon := ExtractIcon(0,'imageres.dll',3)
with TypImg do
begin
Left := ScaleX(MWU_LEFTBORDER);
Top := ScaleY(MWU_TOPBORDER);
Center := False;
Stretch := False;
AutoSize := True;
Bitmap.Width := GetSystemMetrics(SM_CXICON);
Bitmap.Height := GetSystemMetrics(SM_CYICON);
Bitmap.Canvas.Brush.Color := TPanel(Parent).Color;
Bitmap.Canvas.FillRect(TypRect);
DrawIcon(Bitmap.Canvas.Handle,0,0,Icon);
end;
//DestroyIcon(Icon); //not needed with LR_SHARED or with LoadIcon
end;
procedure InitializeWizard();
begin
WizardForm.SelectDirBitmapImage = Dir_Icon();
end;
---
The code that triggers "Cannot cast an object" error is:
procedure Dir_Icon(TypImg: TBitmapImage);
var TypRect: TRect;
Icon: THandle;
begin
TypRect.Left := 0;
TypRect.Top := 0;
TypRect.Right := GetSystemMetrics(SM_CXICON);
TypRect.Bottom := GetSystemMetrics(SM_CYICON);
Icon := ExtractIcon(0,'imageres.dll',3)
with TypImg do
begin
Left := ScaleX(MWU_LEFTBORDER);
Top := ScaleY(MWU_TOPBORDER);
Center := False;
Stretch := False;
AutoSize := True;
Bitmap.Width := GetSystemMetrics(SM_CXICON);
Bitmap.Height := GetSystemMetrics(SM_CYICON);
Bitmap.Canvas.Brush.Color := TPanel(Parent).Color;
Bitmap.Canvas.FillRect(TypRect);
DrawIcon(Bitmap.Canvas.Handle,0,0,Icon);
end;
//DestroyIcon(Icon); //not needed with LR_SHARED or with LoadIcon
end;
procedure InitializeWizard();
begin
Dir_Icon(WizardForm.SelectDirBitmapImage);
end;
---