DrawText无法在winxp中工作,就像在win7中一样 [英] DrawText wont work in winxp where as it does in win7
本文介绍了DrawText无法在winxp中工作,就像在win7中一样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用CRgn Class创建区域的代码,以下是在dc上创建黑色区域的代码段:
Hi,
I am working on a code in which I am creating a region using CRgn Class,the following is the snippet to create black region on dc:
CRect fpsoverlay;
GetClientRect(&fpsoverlay);
fpsOverlay.right = fpsOverlay.right - 30;
CRgn rgn2;
CBrush bBr2(RGB(0,0,0));
dc.SelectObject(bBr2);
int nOldROP2 = dc.GetROP2();
dc.SetROP2(R2_COPYPEN);
rgn2.CreateRectRgn(fpsoverlay.left,fpsoverlay.bottom-15,fpsoverlay.right,fpsoverlay.bottom);
dc.FillRgn(&rgn2,&bBr2);
SetBkMode(dc,TRANSPARENT);
SetTextColor(dc,RGB(0,255,0));
DrawText(dc,"Caption1",-1,fpsoverlay,DT_CENTER);
我将在第一个区域旁边创建另一个区域,并使用不同的文本,如下所示:
I am creating another region next to the first region with different text like the following:
CRect fpsoverlay1;
GetClientRect(&fpsoverlay1);
fpsOverlay1.left = fpsOverlay1.right - 30;
fpsoverlay1.top = fpsoverlay1.bottom-15;
CRgn rgn1;
CBrush bBr3(RGB(0,0,0));
dc.SelectObject(bBr3);
int nOldROP3 = dc.GetROP2();
dc.SetROP2(R2_COPYPEN);
rgn1.CreateRectRgn(fpsoverlay1.left,fpsoverlay1.top,fpsoverlay1.right,fpsoverlay1.bottom);
dc.FillRgn(&rgn1,&bBr3);
SetBkMode(dc,TRANSPARENT);
SetTextColor(dc,RGB(0,255,0));
DrawText(dc,"Caption2",-1,fpsoverlay1,DT_RIGHT);
该代码在Windows7(在此OS上开发)中运行良好,但是当我在Windows XP上使用此ActiveX控件时,第二个区域的标题(即"Caption2")不可见.
请提出解决方案.
在此先感谢
This code works well in Windows7(it is developed on this OS),but when I use this ActiveX control on windows XP the caption of the second region i.e "Caption2" is not visible.
Please suggest the solution.
Thanks in advance
推荐答案
假设并存的fpsOverlay
/fpsoverlay
只是一个错字,两个字幕的处理方式不同之处在于坐标已处理.
对于Caption2,.top
设置为.bottom-15
,而不是Caption1
.这在调用DrawText
时会有所不同(将相同的值传递到CreateRectRgn
).
使两个标题的代码相同应该可以缩小问题的范围. (在两个Windows版本下,可能会有不同的剪切策略.)
Assuming that the coexistingfpsOverlay
/fpsoverlay
is just a typo, the difference between the handling of the two captions lies in the way the coordinates are processed.
For Caption2,.top
is set to.bottom-15
, not forCaption1
. This makes a difference whenDrawText
is called (identical values are passed toCreateRectRgn
).
Making to the code identical for both captions should allow you to narrow down the problem. (Probably a different clipping policy under the two Windows versions).
这篇关于DrawText无法在winxp中工作,就像在win7中一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文