Groups | Blog | Home
all groups > visual c > december 2006 >

visual c : Device Context Problem in XP


Mullai
12/29/2006 9:59:56 PM
Hi Frendz,

I am working in an application in VC++ 6.0 in Windows 98
platform for drawing images.It works well in win 98 . I am trying to
import the same application for Windows XP. While doing this the DEVICE
CONTEXT creates problem.

///////////////////MY CODE//////////////

int CPicture::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
CPaintDC dc(this);
CRect clientRect;

CPageWindow *page=(CPageWindow *)GetParent();

if(page)
{
clientRect.SetRect(0,0,page->Width,-page->Height);
int oldmapmode=dc.SetMapMode(MM_HIENGLISH);
dc.LPtoDP(&clientRect);
dc.SetMapMode(oldmapmode);
}

m_memDC=new CDC();
m_memBitmap=new CBitmap();
m_memDC->CreateCompatibleDC(&dc);
m_memBitmap->CreateCompatibleBitmap(&dc,clientRect.Width(),clientRect.Height());
m_pOldMemBitmap=m_memDC->SelectObject(m_memBitmap);
return 0;
}
/////////////////////////// end of code/////////////

My problem is after converting from LPtoDP the client rect value is
top=0 bottom=1680 left=0 right= 1054 clientrect(0 1680 0 1054)

in Windows 98 the LPtoDP the client rect value is ient rect value is
top=0 bottom=1984 left=0 right= 1245 clientrect(0 1984 0 1245)


because of this change in the dc the picture position changes..... Can
u pl help how to make the DC compatible for windows xp from wimdows 98


Thanx in advance
Mulls
raylopez99
12/30/2006 1:26:14 AM
[quoted text, click to view]

I think you have identified the problem. So what remains?

BTW, in the future you might want to switch to Forms rather than MFC
library.

RL
Ben Voigt
1/1/2007 10:55:04 AM

[quoted text, click to view]

If you want the exact same sizes in pixels, don't use HIENGLISH. Windows is
doing exactly what you asked it to do, namely adjusting for the screen
pitch, which are commonly specified at 96dpi or 120 dpi, but can be affected
by the manufacturer's monitor driver.

[quoted text, click to view]

Mullai
1/23/2007 4:55:21 AM
Hi,
I have identified the problem. But how to solve the Map mode
problem?
[quoted text, click to view]
Mullai
1/23/2007 4:58:33 AM
HI,

Only in MM_HIENGLISH K am importing the Pictures in the page for
the newspaper. Pl let me know how to overcome this map mode problem.



[quoted text, click to view]
David Wilkinson
1/23/2007 10:23:22 AM
[quoted text, click to view]

Mullai:

Please don't multi-post. You have asked this question in the MFC group also.

AddThis Social Bookmark Button