捕获焦点对齐的表单 [英] Capture an in-focus form

查看:109
本文介绍了捕获焦点对齐的表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计,



我们需要一个通用的例程,最好用C#编写,它将在我们的应用程序中生成表单的表单(Windows Form as以及WPF形式)。此镜头将由用户操作(例如菜单选项)触发,并将生成当前焦点的表单镜头。镜头应在其图像中包含原样,包括数据和其他图形文物。镜头将包括整个表格,即使其中一些不在显示屏上。镜头最好是.pdf格式。



有没有人知道实现这一目标的好方法。



非常感谢,
Avi



Maciej Los,你是对的我没有提供选择的语言。

我很感谢你和谢尔盖的回答。

Folks,

We need a generic routine, preferably written in C#, that will generate a "form shot" of the forms in our application (Windows Form as well as WPF forms). This shot will be triggered by a user action (say a menu option) and will generate a shot of the form that is currently in focus. The shot should include in its image the form as is, including the data and other graphics artefacts. The shot will include the entire form, even if some of it is off the display. The shots will preferably be in a .pdf format.

Does anyone know of a good way to achieve this goal.

Many thanks,
Avi

Maciej Los, you are correct I did not supply the language of choice.
I appreciate yours and Sergey''s responses.

推荐答案

请看我的问题。我假设你需要一个屏幕截图。



首先,你需要把表格放在最上面,看看这一切。如果需要,您可以使用原始Windows API轻松记住当前的Z顺序并在以后恢复它(我甚至需要解释如何?只需查看窗口函数;不幸的是,您必须使用P / Invoke)。我不知道你是否可以在没有显示整个表格的情况下做到并且怀疑它是不可能的。该方法需要在屏幕上显示整个表单。



您只需在屏幕坐标中找到表单大小和位置,并使用System.Drawing.Graphics.CopyFromScreen对于 System.Drawing.Graphics 的实例,取自新创建的 System.Drawing.Bitmap 实例。你可以在这里找到一些代码示例:

http://pcsxcetrasupport3.wordpress.com/2012/03/09/windows-form-screenshot-and-print-preview-in-vb-net/ [ ^ ]。



使用PDF来做这些事情并不是一个好主意(即使你是为文档创建它,你可以在以后再做),但你总是如果您使用,例如,iText,更准确地说,它的.NET端口,iTextSharp:

http://en.wikipedia.org/wiki/IText [ ^ ],

http://itextpdf.com/ [ ^ ],

http://sourceforge.net/projects/itextsharp/ [ ^ ]。



包括对Java iText网站的引用,因为大多数文档都在那里。如果您了解C#,那么理解基于Java的API文档并不困难。



-SA
Please see my question. I will assume you need a screen shot.

First of all, you need to put the form on top, to see it all. If you want, you can easily remember the current Z-order and restore it later, using raw Windows API (do I even need to explain how? just look at the window functions; unfortunately, you have to use P/Invoke). I don''t know if you can do it without showing the whole form and suspect it''s impossible. The method requires the whole form to be shown on screen.

You just find out the form size and location in screen coordinates, and use System.Drawing.Graphics.CopyFromScreen for an instance of System.Drawing.Graphics taken from a newly created instance of System.Drawing.Bitmap. You can find some code sample here:
http://pcsxcetrasupport3.wordpress.com/2012/03/09/windows-form-screenshot-and-print-preview-in-vb-net/[^].

Using PDF for such things is not a good idea (even if you create it for documentation, you can do it later), but you always can make PDF from image if you use, for example, iText, more exactly, its .NET port, iTextSharp:
http://en.wikipedia.org/wiki/IText[^],
http://itextpdf.com/[^],
http://sourceforge.net/projects/itextsharp/[^].

In included the reference to Java iText site as well, because most documentation is there. If you understand C#, it would not be difficult to understand Java-bases API documentation.

—SA

首先,阅读Sergey Alexandrovich Kryukov的解决方案1 ​​......你会发现许多有用的信息...



其次,你没有提供足够的信息来准确回答(特别是编程语言),所以我只能猜出你在寻找什么。



请参阅PrintForm类 [ ^ ],可以在运行时打印Windows窗体的图像。



更多:

打印表单组件 [ ^ ]

所有关于PrintForm组件1.0 [ ^ ]

在Visual Basic中使用PrintForm组件(Matt Gertz) [ ^ ]
First of all, read solution1 by Sergey Alexandrovich Kryukov... There you''ll find many useful information...

Secondly, you did not provide enough information to put exact answer (especially programming language), so i can only guess what you are looking for.

Please, see PrintForm Class[^], which enables printing an image of a Windows Form at run time.

More:
Print Form Component[^]
All about PrintForm component 1.0[^]
Using the PrintForm component in Visual Basic (Matt Gertz)[^]


这篇关于捕获焦点对齐的表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆