Click to See Complete Forum and Search --> : Problem with drawing large text with Win98


Stoil
November 3rd, 2004, 04:24 AM
Hi, everybody!
My app works perfect with Windows XP, but with Win98 the view is awful:-(
I understand that some GDI functions use 16bit coordinates.
From this article: http://support.microsoft.com/kb/287168/EN-US/
I see I can't use DPtoLP() because limitation to 32767...
How can I overcome this limitation?
Could anybody tell me how to decide the problems with 32K limit in Windows 98!?

Stoil
March 7th, 2005, 05:04 AM
I decided drawing and scrolling problems in Win98.
Now, my view class is derived from CView and I added functions:

void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
void OnSize(UINT nType, int cx, int cy);
BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);

To avoid limitation of CDC::LPtoDP I added the next function, which replace CDC::LPtoDP and CDC::DPtoLP:
// nWindow - logical pos; nWinOrg - begin logic coordinates ; nWinExt, nViewExt - scale, nViewOrg - begin device coordinates
int GetDP(int nWindow, int nWinOrg, int nWinExt, int nViewExt, int nViewOrg)
{
int nViewPort = ( nWindow - nWinOrg ) * nViewExt/nWinExt + nViewOrg;
double dViewPort = (double)( nWindow - nWinOrg ) * nViewExt/nWinExt + (double) nViewOrg;
if ( dViewPort > 0 )
nViewPort = dViewPort + 0.5;
else
nViewPort = dViewPort - 0.5;
return nViewPort;
}

// nViewPort - device pos; nViewOrg - begin device coordinates; nViewExt, nWinExt - scale; nWinOrg - begin logic coordinates
int GetLP(int nViewPort, int nViewOrg, int nViewExt, int nWinExt, int nWinOrg)
{
int nWindow = ( nViewPort - nViewOrg ) * nWinExt/nViewExt + nWinOrg;
double dWindow = (double)( nViewPort - nViewOrg ) * nWinExt/nViewExt + (double)nWinOrg;
if ( dWindow > 0 )
nWindow = dWindow + 0.5;
else
nWindow = dWindow - 0.5;
return nWindow;
}

CPoint CCFormeditorView::DPtoLP(CPoint pt)
{
CDC *pDC = GetDC();
if ( pDC == NULL )
return pt;
OnPrepareDC(pDC, NULL);
int nWinExt = pDC->GetWindowExt().cx;
int nViewExt = pDC->GetViewportExt().cx;
pt.x = GetLP(pt.x + m_ptScrollPos.x, 0, nViewExt, nWinExt, 0);
pt.y = GetLP(pt.y+ m_ptScrollPos.y, 0, nViewExt, nWinExt, 0);
// pDC->DPtoLP(&pt);

ReleaseDC(pDC);
return pt ;//+ point;
}

CPoint CCFormeditorView::LPtoDP(CPoint pt)
{
CDC *pDC = GetDC();
if ( pDC == NULL )
return pt;
OnPrepareDC(pDC, NULL);
int nWinExt = pDC->GetWindowExt().cx;
int nViewExt = pDC->GetViewportExt().cx;
pt.x = GetDP(pt.x, 0, nWinExt,nViewExt, -m_ptScrollPos.x);
pt.y = GetDP(pt.y, 0, nWinExt, nViewExt, -m_ptScrollPos.y);
// pDC->LPtoDP(&pt);
ReleaseDC(pDC);
return pt;
}


where m_ptScrollPos saved scroll position into device units - pixels

Before drawing every element, I decrease its coordinate with m_ptScrollPos
If anybody have questions may ask me by mail: torpedo_st@yahoo.com
Good luck!