When I use SendMessage(..) in an OnTextObjectPaint event then the drawing on the canvas is all screwed up and/or not visible. I am using WPTools VCL Demo 5.18.1 for Delphi 5.
procedure TFormMain.ButtonInsertImageClick(Sender: TObject);
var
WPOImage : TWPOImage;
begin
// insert image
WPOImage := TWPOImage.Create( WPRichText.Memo.RTFData);
WPOImage.LoadFromFile( 'test.bmp');
WPRichText.TextObjects.Insert( WPOImage);
end;
procedure TFormMain.WPRichTextTextObjectPaint(Sender: TObject;
pobj: TWPTextObj; toCanvas: TCanvas; XRes, YRes, X, Y, W, H,
BASE: Integer; PageRef: TWPVirtPage; Modes: TWPTextObjectPaintModes;
const CanvasExtraAttr: TWPPaintExtraParams;
var ContinueMode: TWPTextObjectPaintResult);
begin
// enable/disable bug
if (CheckBoxBug.Checked) then begin
SendMessage( Self.Handle, WM_USER + 50, 0, 0);
end;
// paint object
if Assigned( pobj) and Assigned( pobj.ObjRef) then begin
pobj.ObjRef.Paint( toCanvas, Rect( X, Y, X + W, Y + H), pobj, []);
end;
// draw red cross over object
toCanvas.Pen.Color := clRed;
toCanvas.Pen.Width := MulDiv( 3, XRes, WPScreenPixelsPerInch);
toCanvas.MoveTo( X, Y);
toCanvas.LineTo( X + W, Y + H);
toCanvas.MoveTo( X + W, Y);
toCanvas.LineTo( X, Y + H);
// tell WPTools not to paint contents and selection
ContinueMode := ContinueMode - [wpObjPaintContents] - [wpobjPaintSelection];
end;