Click here to Skip to main content
15,900,399 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: about Coordinate Map Mode and compatible DC ??? Pin
AntonlioX25-Jun-05 6:21
AntonlioX25-Jun-05 6:21 
GeneralRe: about Coordinate Map Mode and compatible DC ??? Pin
charlieg25-Jun-05 7:26
charlieg25-Jun-05 7:26 
GeneralRe: about Coordinate Map Mode and compatible DC ??? Pin
AntonlioX25-Jun-05 9:12
AntonlioX25-Jun-05 9:12 
GeneralRe: about Coordinate Map Mode and compatible DC ??? Pin
charlieg25-Jun-05 14:08
charlieg25-Jun-05 14:08 
GeneralRe: about Coordinate Map Mode and compatible DC ??? Pin
Jose Lamas Rios25-Jun-05 18:16
Jose Lamas Rios25-Jun-05 18:16 
GeneralRe: about Coordinate Map Mode and compatible DC ??? Pin
AntonlioX25-Jun-05 19:25
AntonlioX25-Jun-05 19:25 
GeneralRe: about Coordinate Map Mode and compatible DC ??? Pin
Jose Lamas Rios26-Jun-05 11:28
Jose Lamas Rios26-Jun-05 11:28 
GeneralRe: about Coordinate Map Mode and compatible DC ??? Pin
Pazzuzu5-Jul-05 1:20
Pazzuzu5-Jul-05 1:20 
Hi,

Iam using Keith Rule's CMemDc class & I have changed it according to my requirement.Iam posting that class also here.
Now Iam zooming my View using "SetWorldTransform" call.
My problem now is when I change the zoom factor to below or above 100,the Fonts are not smooth.

The following are my codes:

//Creating Font like this in "MyView" constructor.Don't want to use FixedFonts.

m_oFont.CreatePointFont(120, _T("Courier New"));
LOGFONT oLogfont;
m_oFont.GetLogFont(&oLogfont);


//OnPrepareDc looks like this.
void MyView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
pDC->SetMapMode(MM_TEXT);
SetGraphicsMode(pDC->GetSafeHdc(), GM_ADVANCED);
pDC->SelectObject(&m_oFont);
pDC->GetTextMetrics(&m_TextMetrics);

XFORM xForm;
xForm.eM11 = 0.01 * m_iZoomFactor;
xForm.eM21 = 0;
xForm.eDx = 0;
xForm.eM12 = 0;
xForm.eM22 = 0.01 * m_iZoomFactor;
xForm.eDy = 0;

pDC->GetTextMetrics(&m_textMetrics);
SetWorldTransform(pDC->GetSafeHdc(), &xForm);
CScrollView::OnPrepareDC(pDC, pInfo);
}

//My "OnDraw" looks like this.

void MyView::OnDraw(CDC* pDC)
{
CpagesDoc* pDoc = GetDocument();
CSize sizeTotal;
//default scrollsizes to 80 chars X 80 lines.
sizeTotal.cx = 80;
sizeTotal.cy = 80;

//Client Rectangle Size.
CRect rect;
GetClientRect(&rect);

//Creating a temporary Dc.
C_TempDc tempDC(pDC,m_oFont,&rect);

int pageWidth = 800;
int pageHeight = 800;
//int pageGap = 5;
int pageNumber =3;
SIZE size;
size.cx = 1000;
size.cy = (pageHeight*3)+100;

//First Page
tempDC->Rectangle(CRect(0,0,pageWidth,pageHeight));
tempDC->TextOut(5,10,"This is the first line on the FirstPage");

sizeTotal.cx *= MulDiv(m_textMetrics.tmAveCharWidth, m_iZoomFactor, 100);
sizeTotal.cy *= MulDiv(m_textMetrics.tmHeight, m_iZoomFactor, 100);
SetScrollSizes(MM_TEXT, sizeTotal);

}

//Keith Rule's Memory Buffer

#ifndef C_TEMPDC_H
#define C_TEMPDC_H

class C_TempDc : public CDC

{

public:

C_TempDc(CDC* pDC,CFont & font,const CRect* pRect = NULL): CDC()
{

ASSERT(pDC != NULL);
//Initialising.
m_pDC = pDC;
m_oldBitmap = NULL;
m_oldFont= NULL;

//Getting ClipBox Rectangle.
pDC->GetClipBox(&m_clipRect);

//Client Rectangle.
m_clientRect = *pRect;
pDC->DPtoLP(&m_clientRect);

// Create a Memory DC
CreateCompatibleDC(pDC);

//pDC->LPtoDP(&m_rect);
m_bitmap.CreateCompatibleBitmap(pDC,m_clientRect.Width(),m_clientRect.Height());


pDC->LPtoDP(&m_clientRect);
m_oldBitmap = SelectObject(&m_bitmap);

///Selecting the Font.
m_oldFont = SelectObject(&font);

SetMapMode(pDC->GetMapMode());

pDC->DPtoLP(&m_clientRect);
SetWindowOrg(m_clientRect.left,m_clientRect.top);

// Fill background
FillSolidRect(m_clientRect, pDC->GetBkColor());
}


~C_TempDc()
{
// Copy the offscreen bitmap onto the screen.
m_pDC->BitBlt(m_clipRect.left,m_clipRect.top,m_clipRect.Width(), m_clipRect.Height(),
this, m_clipRect.left,m_clipRect.top, SRCCOPY);
//Swap back the original bitmap & font.
SelectObject(m_oldBitmap);
SelectObject(m_oldFont);
}


C_TempDc* operator->()
{
return this;
}

operator C_TempDc*()
{
return this;
}


private:

CBitmap m_bitmap;
CBitmap* m_oldBitmap;
CFont* m_oldFont;
CDC* m_pDC;
CRect m_clientRect;
CRect m_clipRect;

};

#endif//C_TEMPDC_H


Hope u can Help....
GeneralCList For Non CObject derived class (vs CTypedPtrList) Pin
yccheok24-Jun-05 23:11
yccheok24-Jun-05 23:11 
GeneralRe: CList For Non CObject derived class (vs CTypedPtrList) Pin
ThatsAlok25-Jun-05 1:06
ThatsAlok25-Jun-05 1:06 
GeneralStrange dynamic_cast problem Pin
yccheok24-Jun-05 22:11
yccheok24-Jun-05 22:11 
GeneralRe: Strange dynamic_cast problem Pin
squidev25-Jun-05 8:18
squidev25-Jun-05 8:18 
GeneralRe: Strange dynamic_cast problem Pin
yccheok25-Jun-05 19:41
yccheok25-Jun-05 19:41 
GeneralRe: Strange dynamic_cast problem Pin
squidev26-Jun-05 3:50
squidev26-Jun-05 3:50 
GeneralRe: Strange dynamic_cast problem Pin
yccheok26-Jun-05 5:25
yccheok26-Jun-05 5:25 
GeneralIPersistStream[Init] Pin
CodingBadger24-Jun-05 16:47
CodingBadger24-Jun-05 16:47 
GeneralDisabling console Pin
Anonymous24-Jun-05 15:48
Anonymous24-Jun-05 15:48 
GeneralRe: Disabling console Pin
Nathan Addy25-Jun-05 8:07
Nathan Addy25-Jun-05 8:07 
Questionhow to download a web page with pictures Pin
Mohsen Saad24-Jun-05 14:43
Mohsen Saad24-Jun-05 14:43 
AnswerRe: how to download a web page with pictures Pin
Ravi Bhavnani24-Jun-05 16:53
professionalRavi Bhavnani24-Jun-05 16:53 
GeneralRemoving references to expired user accounts Pin
aravinthv24-Jun-05 11:35
aravinthv24-Jun-05 11:35 
GeneralRe: Help wanted with TC_ITEM Pin
Jose Lamas Rios24-Jun-05 17:07
Jose Lamas Rios24-Jun-05 17:07 
GeneralRe: Help wanted with TC_ITEM Pin
cgb14328-Jun-05 5:35
cgb14328-Jun-05 5:35 
GeneralNeed help solving Printing Bug Pin
Jorgen E.24-Jun-05 10:22
Jorgen E.24-Jun-05 10:22 
GeneralRe: Need help solving Printing Bug Pin
Jose Lamas Rios26-Jun-05 18:24
Jose Lamas Rios26-Jun-05 18:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.