wzsun wrote:Hi Kambiz,
procedure TMainForm.PenButtonClick(Sender: TObject);
begin
Dragging := False;
PicShow.BgPicture.Bitmap.LoadFromFile(LoadedImage);
Canvas := TCanvas.Create;
Canvas.Handle := PicShow.BgPicture.Bitmap.Handle;
Canvas.Pen.Color := clRed;
Canvas.Brush.Color := clBlue;
Canvas.Brush.Style := bsSolid;
Canvas.Pen.Width := 10;
end;
I didn't read your entire code because in the above code I saw some serious mistakes:
1. The bitmap handle is not a canvas handle. Instead of assigning PicShow.BgPicture.Bitmap.Handle to the Canvas.Handle, you should assign PicShow.BgPicture.Bitmap.Canvas.Handle to it.
2. You might not create a new canvas, otherwise changes on the canvas will not be reported to the PicShow. Instead of creating a new canvas, you have use PicShow.BgPicture.Bitmap.Canvas. In this case, you do not need to assign any handle to the canvas.handle.
3. I hope you have set the PicShow.BgMode proprty to a right value.
4. The bgPicture is the background image. So, if the image loaded in the Picture property is visible, it will covers the background image.
Kambiz