We help IT Professionals succeed at work.

Why this Image won't show up?

ivylnm
ivylnm asked
on
I put a TImage onto my MDI Form.  I am thinking of getting a bmp file to become the MDI Form background.  But even after I try to select the bmp file into the TImage.picture, it does not show up either.  I try to do it using LoadfromResourceFile, but maybe due to the lack of this knowledge, I fail to load the bmp file as well. Please guide.
Comment
Watch Question

Commented:
The MDI form has a new drawing surface when it becomes an MDI form.  You can get the DC of this by trapping the WM_ERASEBKGND message.

Create a TCanvas object;
Set ThatCanvas.Handle := Message.DC;
Draw to the canvas
set ThatCanvas.Handle := 0;
Free the canvas;

TForm1 = class(TForm)
private
  { Private declarations }
  procedure WMErase(var Message: TWMEraseBkGnd); message WM_EraseBkGnd;
public
  { Public declarations }
end;

procedure TForm1.WMErase(var Message: TWMEraseBkGnd);
var
  C: TCanvas;
begin
  C := TCanvas.Create;
  try
    C.Handle := Message.DC;
    //Draw here
  finally
    C.Handle := 0;
    C.Free;
  end;
end;

Pete
====
http://www.HowToDoThings.com (Delphi articles)
http://www.Stuckindoors.com/delphi (Open source)

Explore More ContentExplore courses, solutions, and other research materials related to this topic.