whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

62 Visitors Online


 
...tile a non-MDIframe window with a backgrund bitmap?
Autor: P. Below
Homepage: http://www.teamb.com
[ Print tip ]  

Tip Rating (5):  
     




type
  
TForm1 = class(TForm)
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    procedure Button1Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    
FWallpaper: TBitmap;
    procedure WMEraseBkGnd(var Msg: TWMEraseBkGnd); message WM_ERASEBKGND;
  end;

var
  
Form1: TForm1;

implementation

{$R *.DFM}
procedure TForm1.FormDestroy(Sender: TObject);
begin
  
FWallpaper.Free;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  
// Load the bitmap
  // Bild laden
  
if OpenDialog1.Execute then
  begin
    if not 
Assigned(FWallpaper) then
      
FWallpaper := TBitmap.Create;
    FWallpaper.LoadFromFile(OpenDialog1.FileName);
    Invalidate;
  end;
end;

procedure TForm1.WMEraseBkGnd(var Msg: TWMEraseBkGnd);
var
  
row, col: Integer;
begin
  if not 
Assigned(FWallpaper) then
    inherited
  else
  begin
    
// Draw the bitmap
    // Das Bild zeichnen
    
for Row := 0 to ClientHeight div FWallpaper.Height do
      for 
Col := 0 to ClientWidth div FWallpaper.Width do
        
BitBlt(Msg.Dc,
          Col * FWallpaper.Width,
          Row * FWallpaper.Height,
          FWallpaper.Width,
          FWallpaper.Height,
          FWallpaper.Canvas.Handle,
          0,
          0,
          SRCCOPY);
    Msg.Result := 1;
  end{ else }
end;

end.

 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners