Reputation: 2593
I have a class
THexMap = Class(TScrollingWinControl)
private
FCanvas :timage; // the canvas to draw on.
Dureing the constructor I create TImage Like so.
Constructor THexMap.Create(AOwner: Tcomponent);
begin
inherited Create(AOwner);
FCanvas := timage.Create(self);
FCanvas.Visible := true;
{ Set intial property values for component }
MakeSolidMap;
end;
If i try to set the parent here like so
FCanvas.parent := THexMap;
I get Incompatible types: TWinControl and Class of ThexMap
How do i make it so this image shows up inside the THexMap?
SOME MORE INFO THAT MIGHT HELP...
If i set the create like so
FCanvas := TImage.Create(AOwner);
The TImage
is on the forum, but no image shows up. If i click on the component in the Object Inspector and then click on the property Picture, the correct image will show in the picture Editor.
THE REDRAW..
procedure THexMap.WndProc(var Message: TMessage);
const
DISCARD_CURRENT_ORIGIN = nil;
var
R : TRect;
PS : PAINTSTRUCT;
begin
if Message.Msg = WM_PAINT then
begin
if GetUpdateRect( Handle, nil, false ) then
begin
BeginPaint( Handle, PS );
try
R := PS.rcPaint;
bitblt(fCanvas.Canvas.Handle, R.Left, R.Top, R.Width, R.Height, TempMap.Canvas.Handle, R.Left+FOffset.X, R.Top+FOffset.Y, SRCCOPY);
finally
EndPaint( Handle, PS );
end;
end
else
inherited;
end
else
inherited;
end;
Upvotes: 0
Views: 957
Reputation: 80187
Parent is an instance of TWinConrol, not class type
(e.g. this boy's parent is John Doe, not mankind)
So you have to write:
FCanvas := timage.Create(self);
FCanvas.Parent := Self;
Visible = true is not needed here
Upvotes: 2