Error FindBitMap

In the OnAfterDrawItem Event of the TMSFNCPlanner i wrote this code:

procedure TfrmPlannerMainForm.TMSFNCPlannerAfterDrawItem(Sender: TObject;
  AGraphics: TTMSFNCGraphics; ARect: TRectF; AItem: TTMSFNCPlannerItem);
var
  bmp: TBitmap;
begin
    bmp := TMSFNCBitmapContainer1.FindBitmap('test');
end;

but if a compile this, delphi shows the error message " E2010 Incompatible type: TBitmap and TPicture". But 'test' is a bitmap.............

What is wrong with this code fragment?

Bert Bunnig

The result of TMSFNCBitmapContainer.FindBitmap() is TTMSFNCBitmap


So, write

var
  bmp: TTMSFNCBitmap;
begin
  bmp := TMSFNCBitmapContainer1.FindBitmap('test');
end;

Thanks for the solution.

But now there is another problem: I want to add an Icon to an planner Item, and i have tried the example in the TMS tutorial:

procedure TForm1.TMSFNCPlanner1AfterDrawItem(Sender: TObject; ACanvas: TCanvas;
ARect: TRectF; AItem: TTMSFNCPlannerItem);
var
bmp: TBitmap;
rbmp: TRectF;
begin
if AItem.ConflictsForPosition(0) > 1 then
begin
bmp := TMSFNCBitmapContainer1.FindBitmap('warning');
if Assigned(bmp) then
begin
rbmp := RectF(ARect.Right - 26, ARect.Bottom - 26, ARect.Right - 2, ARect.Bottom - 2);
ACanvas.DrawBitmap(bmp, RectF(0, 0, bmp.Width, bmp.Height), rbmp, 1);
end;
end;
end;

In my OnAfterDrawItem event there  is no aCanvas so i used this code:

procedure TfrmPlannerMainForm.AgendaAfterDrawItem(Sender: TObject;
  AGraphics: TTMSFNCGraphics;
  ARect: TRectF; AItem: TTMSFNCPlannerItem);
var
  bmp: TTMSFNCBitmap;
  rbmp: TRectF;
begin
 
    bmp := TMSFNCBitmapContainer1.FindBitmap('warning');
    if Assigned(bmp) then
    begin
      rbmp := RectF(ARect.Right-26,ARect.Bottom-26,ARect.Right-2,ARect.Bottom-2);
      AGraphics.DrawBitmap(0,0,RectF(0,0,10,10),0,rbmp);
    end;
  end;
 But this does not work. Who knows what to do.

Bert Bunnig


Try to change the code to:


 AGraphics.DrawBitmap(ARect.Left, ARect.Top, bmp);

Problem solved...........Bruno thank you very much.