I decided to stop being lazy and converted the code in my book, I came up with this, that will draw any bitmap on the canvas of a windowed control. (provided the sender is cast correctly)
This is called by the onshow method of a Tabsheet and require a little jigging to make the first page display the background bitmap.
e.g
procedure tForm1.button1click(sender);
begin
//active page is 2
Pagecontrol1.activepage := two;
Pagecontrol1.visible := true;
//switch the active page to the first page forces a call
//to oneshow;
Pagecontrol1.activepage := one;
end;
procedure TForm1.oneshow(sender: tobject);
var canvas: Tcanvas;
R: tRect;
begin
R.left := 0;
R.top := 0;
R.right := (sender as TTabSheet).width;
R.Bottom := (sender as TTabSheet).height;
Canvas := tCanvas.create;
try
// creates a display handle for a widowed control
Canvas.handle := GetDC((sender as TTabsheet).handle);
try
with (sender as TTabsheet) do
begin
Canvas.stretchdraw(R, image.picture.graphic);
end;
finally
releaseDC((sender as TTabsheet).handle, canvas.Handle);
end;
finally
Canvas.free;
end;
end;
rather than using a static image as in the above example the final version loads the bitmap from a resource, and each sucessive tabsheet revealed does the same.
Then only problem is that there is still a thin grey border around the sheets.
Unless anyone can suggest any simplifications/corrected or borderless versions.
Steve