请帮助我使用CDC :: SetMapMode(int nMapMode) [英] Help me please using CDC::SetMapMode(int nMapMode)

查看:78
本文介绍了请帮助我使用CDC :: SetMapMode(int nMapMode)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已更改了映射模式,如下所示:要使用(1个逻辑单位= 1毫米)

I have changed the maping mode as the code below is shown: to work with (1 logical unit = 1 millimeter)

void CGLVImpressionView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
    CView::OnPrepareDC(pDC, pInfo);
    // TODO: Add your specialized code here and/or call the base class
    pDC->SetMapMode(MM_ISOTROPIC);
    // Working with (1 logical unit = 1 mm) for both width & height of the device context.
    pDC->SetWindowExt(1, 1);
    pDC->SetViewportExt(pDC->GetDeviceCaps(HORZRES) / pDC->GetDeviceCaps(HORZSIZE),
                        pDC->GetDeviceCaps(VERTRES) / pDC->GetDeviceCaps(VERTSIZE));
    pDC->SetBkMode(TRANSPARENT);
    //CView::OnPrepareDC(pDC, pInfo);
}



当我创建这样的字体时:



and when I create a font like this:

void CGLVImpressionView::OnBeginPrinting(CDC* pDC, CPrintInfo* /*pInfo*/) 
{
	// TODO: Add your specialized code here and/or call the base class
	m_fnTimes12.CreatePointFont(120, _T("Times New Roman"), pDC);
	m_fnTimes14.CreatePointFont(140, _T("Times New Roman"), pDC);

        //CView::OnBeginPrinting(pDC, pInfo);
}



它将以巨大的尺寸绘制:(
我做错了什么?
请帮帮我.

该图像可能有用:
http://img546.imageshack.us/img546/7144/dpiw.jpg



It will be drawn with a huge size :(
What am I doing wrong ?
Help me please.

This image may be useful:
http://img546.imageshack.us/img546/7144/dpiw.jpg

推荐答案

您的初始化错误.函数的顺序称为:
1.)OnPreparePrinting
2.)OnBeginPrinting
3.)OnPrepareDC
4.)OnDraw
您应该在OnPrepareDC函数中创建字体.
问候.

[edit]您的字体适用于MM_TEXT,但使用MM_ISOTROPIC绘制.
Your initialisation is wrong. The order of functions called:
1.) OnPreparePrinting
2.) OnBeginPrinting
3.) OnPrepareDC
4.) OnDraw
yous should create the fonts in OnPrepareDC function.
Regards.

[edit] your fonts are ceated for MM_TEXT but drawn with MM_ISOTROPIC.


映射模式可能会影响字体大小.尝试在绘制文本之前将映射模式重置为普通模式,然后将其设置回所需的任何位置.

或者,您可以减小字体大小作为一种快速的解决方法...
The mapping mode will probably affect the font size. Try to reset the mapping mode to normal just before drawing the text, then set it back to whatever you want.

Or you may just reduce your font size as a quick workaround...


我认为您的计算可能不正确.查看我的打印机,我得到以下值
霍兹雷斯:2892
HORZSIZE:204

垂直:4125
垂直尺寸:291

提供14 x 14的ViewPort范围,以便在渲染时将您的角色在每个方向上放大14倍.您可能会发现,将映射保留在MM_TEXT会更容易,该映射将在打印文本时从Window正确缩放到ViewPort.
I think your calculation may be incorrect. Looking at my printer I get the following values
HORZRES : 2892
HORZSIZE : 204

VERTRES : 4125
VERTSIZE : 291

Giving a ViewPort Extent of 14 x 14 so your characters will be scaled up by 14 times in each direction when rendered. You may find it easier just to leave the mapping at MM_TEXT which will correctly scale from Window to ViewPort when printing text.


这篇关于请帮助我使用CDC :: SetMapMode(int nMapMode)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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