为什么默认的“打印预览"和“打印绘图"太小? [英] Why do default Print Preview and Print draw too small?

查看:93
本文介绍了为什么默认的“打印预览"和“打印绘图"太小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MFC文档/视图体系结构.

我为View绘制的代码看起来不错,但是当我在打印预览"或打印它"中查看它时,除文字绘图外,所有内容都被压缩在左上角的一个较小矩形中.不过,只绘制了一部分文本,只是绘制了较小矩形内的一部分.

我需要在OnPreparePrinting()中做些什么吗?

更新:


在使用pDC()->IsPrinting()进行打印或打印预览的情况下,我将视图绘制功能更改为使用pDC而不是内存DC(内存DC位图是为了避免屏幕绘制闪烁).现在,至少所有文本都可以正确绘制,但所有线条都不能正确绘制.

我正在使用MM_TEXTLOGPIXELSX和Y转换为设备像素.我将在绘制代码中尝试使用MM_ISOTROPIC绘制线条的对象,并查看其是否有效或寻找可疑的东西.

更新2


答案是MM_TEXT应该可以正常工作.我只需要使用打印机DC来调用我的重新分页代码,然后在View :: OnDraw中结束该代码,然后检查该DC是否是打印机DC.

我的用户设置以英寸(对象层)为单位,GUI层使用像素,并且分页可用于任何设备,因为从英寸转换为像素的函数对X和Y均使用pDC-> GetDeviceCaps(LOGPIXELSX). >
我想知道是否有人会验证这种方法或提及更好的东西.可以使用视图DC并使用DIB和StretchBlt()到打印机DC吗?如果能奏效,会不会导致打印质量下降?我的意思是,无论如何我似乎都必须从英寸转换为像素,所以我做的方式似乎尽可能优雅.请证明我错了.

I''m using the MFC document/view architecture.

My draw code for the View appears fine, but when I look at it in Print Preview or Print it, everything is scrunched up in a smaller rectangle in the upper left corner except for the text drawing. Only a portion of the text is drawn though, just the part within the smaller rectangle.

Do I need to do something in OnPreparePrinting()?

Update:


I changed the view draw function to use the pDC instead of the memory DC (memory DC bitmap was to avoid flicker for screen drawing) in case of printing or print preview with pDC()->IsPrinting(). Now at least all of the text is drawing correctly but all of the line drawing is not.

I''m using MM_TEXT and LOGPIXELSX and Y to convert to device pixels. I''m going to try out MM_ISOTROPIC in the draw code for objects that draw lines and see if that works or look for something fishy.

Update 2


The answer was that MM_TEXT should work just fine. I just needed to call my re-pagination code with the printer DC and that ended up in View::OnDraw where I check to see if the dc is a printer dc.

My user settings are in inches (object layer) and the GUI layer uses pixels and the pagination works for any device because the function that converts from inches to pixels uses pDC->GetDeviceCaps( LOGPIXELSX ) for both X and Y.

I wonder if anyone would validate this approach or mention something better. Could one just use the view DC and use a DIB and StretchBlt() to the printer dc? If it does work would one lose printing quality? I mean it seems that I have to convert from inches to pixels anyway so the way I did it seems to be about as elegant as possible. Please prove me wrong.

推荐答案

屏幕和打印机的坐标系不同.过去,我通过设置一组具有偏移量和缩放因子的变量来克服了这个问题,我根据要绘制的位置将它们加载到绘图函数的顶部,并使用了适当的值,然后使用这些值来计算正确的位置.

它不是很优雅,但确实有效.

如果您提出更好的建议,我将非常感兴趣,因为这很繁琐.祝你好运. :)
The co-ordinate system for the screen and the printer are different. I have overcome this problem in the past by setting up a group of variables with offsets & scaling factors, I load them at the top of my draw function with appropriate values depending on where I am drawing to and then I use those values to calculate the correct location.

It is not very elegant but it does work.

If you come up with anything better I would be really interested as it is fairly tedious. Good Luck. :)


这篇关于为什么默认的“打印预览"和“打印绘图"太小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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