1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Menus;
type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure FormDeactivate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure FormPaint(Sender: TObject); procedure FormResize(Sender: TObject); procedure FormClick(Sender: TObject); private public end;
var Form1: TForm1; bmp:TBitmap; cn:TCanvas; hnd:HWND;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject); begin Application.OnDeactivate:=OnDeactivate; bmp:=TBitmap.create; cn:=TCanvas.create; hnd:=GetWindowDC(handle); cn.handle:=hnd; end;
procedure TForm1.FormDeactivate(Sender: TObject); begin cn.draw(0,0,bmp); end;
procedure TForm1.FormDestroy(Sender: TObject); begin bmp.free; cn.Free; releasedc(handle,hnd); end;
procedure TForm1.FormPaint(Sender: TObject); begin cn.draw(0,0,bmp); end;
procedure TForm1.FormResize(Sender: TObject); begin bmp.width:=width; bmp.height:=GetSystemMetrics(SM_CYFRAME)*2+GetSystemMetrics(SM_CYCAPTION); bmp.Canvas.copyrect(bmp.canvas.cliprect,cn,bmp.canvas.cliprect); end;
procedure TForm1.FormClick(Sender: TObject); begin form2.show; cn.draw(0,0,bmp); end;
end. |