本文整理自网络,侵删。
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(user32DLLHandle, 'PrintWindow'); if @printWindowAPI <> nil then begin GetWindowRect(windowHandle, r) ; bmp.Width := r.Right - r.Left;//www.delphitop.com 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*)
procedure TForm2.Button1Click(Sender: TObject);
beginImage1.Picture:=nil;WindowSnap(Self.Handle, Image1.Picture.Bitmap) ;Image1.Refresh;
end;
相关阅读 >>
Delphi 关于datetimepicker的一点问题(同时修改日期和时间的实现)
Delphi的tservice 服务路径获取 dll中获取文件路径
更多相关阅读请进入《Delphi》频道 >>