Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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);


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
Posted

1 solution

Assuming that the coexisting fpsOverlay/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 for Caption1. This makes a difference when DrawText is called (identical values are passed to CreateRectRgn).

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).
 
Share this answer
 
v2
Comments
hakz.code 19-Jul-11 9:58am    
For caption1 also the .top is set to .bottom-15,but both the overlays are different,when drawn they exist side by side as their x coordinates are different.
YvesDaoust 19-Jul-11 11:22am    
Sorry to disagree, there is no fpsoverlay.top = ... statement in the first snippet. This can make a difference.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900