사용방법
WindowSnap(Self.Handle, Image1.Picture.Bitmap) ;
Image1.Refresh;
함수선언
function WindowSnap(windowHandle: HWND; bmp: TBitmap): boolean;
var
r: TRect;
user32DLLHandle: THandle;
printWindowAPI: function(sourceHandle: HWND; destinationHandle: HDC; nFlags: UINT): BOOL; stdcall;
begin
result := False;
user32DLLHandle := GetModuleHandle(user32) ;
if user32DLLHandle <> 0 then
begin
@printWindowAPI := GetProcAddress(huser32, 'PrintWindow') ;
if @printWindowAPI <> nil then
begin
GetWindowRect(windowHandle, r) ;
bmp.Width := r.Right - r.Left;
bmp.Height := r.Bottom - r.Top;
bmp.Canvas.Lock;
try
result := printWindowAPI(windowHandle, bmp.Canvas.Handle, 0) ;
finally
bmp.Canvas.Unlock;
end;
end;
end;
end; (*WindowSnap*)
출처 : http://delphi.about.com/od/delphitips2008/qt/print_window.htm
|