以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 可以把打开的窗口 设置 分辨率 所有内容一起 导出图片吗 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=147480) |
-- 作者:a937775799 -- 发布时间:2020/3/17 23:03:00 -- 可以把打开的窗口 设置 分辨率 所有内容一起 导出图片吗 可以把打开的窗口 设置 分辨率 所有内容一起 导出图片吗,程序一个窗口显示的不全,会有下拉栏,我想导出选择设置分辨率,导出一个完整的大图片,这样可以单独打印a1,a2,a3都可以 [此贴子已经被作者于2020/3/17 23:11:46编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/3/17 23:12:00 -- 没有办法设置。 可以利用窗口打印功能,但是只能打印一层的控件,不支持嵌套的控件打印,而且部分控件也无法打印。 可以利用截图功能,不过也只能截图屏幕看得到的地方
|
-- 作者:a937775799 -- 发布时间:2020/3/17 23:13:00 -- 这下悲剧了,完蛋了 |
-- 作者:a937775799 -- 发布时间:2020/3/18 0:36:00 -- 我在全局代码里这么写但是都调试不过,对象.hdc 好像是什么 什么东西 来着,不知道怎么弄了 ,我对。net 不熟啊 麻烦帮我改改 \'添加如下声明 Private structure re Dim Left As Long Dim Top As Long Dim Right As Long Dim Bottom As Long End structure Private Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As re) As Long Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long \'添加这个函数 Public Function GetWndPic(Wnd As Long, f As WinForm.Form , pic As WinForm.PictureBox ) Dim R As re, DC As Long GetWindowRect( Wnd, R) \'获取指定窗口的左上角?右下角位置(以便获取其大小) DC = GetWindowDC(Wnd) \'得到dc BringWindowToTop( Wnd )\'目标窗口提到前面(非置顶) BitBlt( pic.hdc , 0, 0, f.Width, f.Height, DC, 0, 0, vbSrcCopy ) \'复制绘图 ReleaseDC( Wnd, DC) \'释放 End Function \'调用示例(把句柄131454的程序窗口截图放到Picture1中) \'GetWndPic 131454, Picture1
[此贴子已经被作者于2020/3/18 2:32:33编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/3/18 8:48:00 -- 全局代码: Public Declare Function CreateDC Lib "gdi32.dll" (ByVal lpszDriver As String, ByVal lpszDevice As String, ByVal lpszOutput As String, ByVal lpInitData As IntPtr) As IntPtr Public Declare Function BitBlt Lib "gdi32.dll" (ByVal hdcDest As IntPtr, ByVal nXDest As Integer, ByVal nYDest As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As Integer, ByVal dwRop As UInt32) As Integer Public Declare Function CreateCompatibleDC Lib "gdi32.dll" (ByVal hdc As IntPtr) As IntPtr Public Declare Function CreateCompatibleBitmap Lib "gdi32.dll" (ByVal hdc As IntPtr, ByVal nWidth As Integer, ByVal nHeight As Integer) As IntPtr Public Declare Function SelectObject Lib "gdi32.dll" (ByVal hdc As IntPtr, ByVal hgdiobj As IntPtr) As IntPtr Public Declare Function DeleteDC Lib "gdi32.dll" (ByVal hdc As IntPtr) As Integer Public Declare Function PrintWindow Lib "user32.dll" (ByVal hwnd As IntPtr, ByVal hdcBlt As IntPtr, ByVal nFlags As UInt32) As Boolean Public Declare Function GetWindowDC Lib "user32.dll" (ByVal hwnd As IntPtr) As IntPtr Public Function GetWindow(ByVal hWnd As IntPtr) As Bitmap Dim hscrdc As IntPtr = GetWindowDC(hWnd) Dim control As system.windows.forms.Control = system.windows.forms.Control.FromHandle(hWnd) Dim hbitmap As IntPtr = CreateCompatibleBitmap(hscrdc, control.Width, control.Height) Dim hmemdc As IntPtr = CreateCompatibleDC(hscrdc) SelectObject(hmemdc, hbitmap) PrintWindow(hWnd, hmemdc, 0) Dim bmp As Bitmap = Bitmap.FromHbitmap(hbitmap) DeleteDC(hscrdc) DeleteDC(hmemdc) Return bmp End Function 打开需要截图的窗口,必须是独立,或者模式窗口 Dim f = Forms("窗口3") f.open Dim bit As Bitmap = GetWindow(f.baseform.handle) bit.save("D:\\123.jpg") |
-- 作者:a937775799 -- 发布时间:2020/3/18 10:01:00 -- 我试下了 可以用 但是有个问题, 截图的是刚刚的窗口大小呢, 我电脑 屏幕小,窗口下面还有滚动的没有截 出来呢,而且 有点不清晰 |
-- 作者:有点蓝 -- 发布时间:2020/3/18 10:21:00 -- 没有办法一次性截图。只能截图窗口看得到的地方。网上搜了一下,一般都是截图,然后移动滚动条,然后截图,然后移动....最后把所有的截图合并到一起。 这里有个例子自己下载看看:https://download.csdn.net/download/lz37025/10397123?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task,我没有积分下载不了
|
-- 作者:a937775799 -- 发布时间:2020/3/18 10:36:00 -- 好的 我去 看看 , 顺便问问 如果不截图 直接打印 ,那么这种滚动窗体 能直接打印出来吗 |
-- 作者:有点蓝 -- 发布时间:2020/3/18 10:40:00 -- foxtable的窗口打印是可以的。 |
-- 作者:a937775799 -- 发布时间:2020/3/18 10:47:00 -- 那我 换个思路 把整个窗口打印 导出到pdf,比如我这个窗口,这样的思路可以吗 [此贴子已经被作者于2020/3/18 10:47:05编辑过]
|