在1024*768的分辨率下,部分界面超出了Windows窗口界面,在对Image控件截图过程中,超过窗口的部分无法截取到,试了很多种方法,一样没有达到想要的效果,请各位大大帮忙,谢谢!
解决方案 »
- 问一个有关TIMER控件的问题
- 历史上的三个“空城计”
- 怎么使用TOleContainer来嵌入office文件
- 多线程:为何线程结束不了
- C++调用Delphi动态库的参数传入问题
- 大家来看看帮帮忙 在线等待
- 如何在Delphi中使用WIN200自带的WINFAX组件?
- 窗体最小化
- delphi+mapX
- 如何程序关闭 opendialog1.Execute 调用的对话框
- devexpress auto installer 能用在DevExpress VCL 12.2.6 FS上不?
- 用DELPHI6开发的程序中 有一函数中有这么一个用法 SetLength(Result, 500); 这其中的 Result 是什么 ?
在vista及win7,win8下,就算超过屏幕,系统仍然绘图,所以取得到。
我做的一个小程序是这样解决:判断系统版本,如果是xp及以下,则调用api将窗口(如果是最小化先还原大小)移到屏幕能全部显示的地方。
如果是窗口本身大小就超过屏幕,我也不知道要怎么做。
联函数都告诉你了还搞不定,非要给你写代码.晕啊.
一个Image,一个Panel
你把鼠标在Panel1上按下,然后拖到你要截屏的窗口上松开看看.
function WindowSnap(WndHandle: HWND; Destbmp: 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(WndHandle, r);
Destbmp.Width := r.Right - r.Left;
Destbmp.Height := r.Bottom - r.Top;
Destbmp.Canvas.Lock;
try
Result := PrintWindowAPI(WndHandle, Destbmp.Canvas.Handle, 0);
finally
Destbmp.Canvas.Unlock;
end;
end;
end;
end;procedure TForm8.Panel1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
h : HWND;
bmp: TBitmap;
begin
h := WindowFromPoint(Mouse.CursorPos);
bmp := TBitmap.Create;
WindowSnap(h, bmp);
Image1.Picture.Graphic := bmp;
bmp.Free;
end;
别说是超出屏幕,就算被别的窗口挡住,都可以截图!因为你的程序只要能被人看到,实际就已经被paint绘出来了,都绘出来了,存一下就OK