在1024*768的分辨率下,部分界面超出了Windows窗口界面,在对Image控件截图过程中,超过窗口的部分无法截取到,试了很多种方法,一样没有达到想要的效果,请各位大大帮忙,谢谢!
解决方案 »
- 誰有興趣開發這樣的Grid控件?
- FastReport 使用问题,请求高手指点!
- oracle 中如何在储发器中调用存储过程的问题
- 紧急求救:如何获取打印机实际纸张大小?!!!!!!!!!!!!!!!!!!!!!!!
- 循环错在何处,运行完后报错,
- dbgrid选定行变化的事件是什么???
- 连接MySql的问题,请帮帮忙。
- Delphi6.0新控件的新特性
- Quick Report 无法显示数据
- 已知一窗体的句柄,求窗体内一TImage的图片路径,TImage名称已知
- 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