Click here to Skip to main content
15,920,632 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: MDI Parent Size Problem Pin
David Crow6-Jul-05 5:56
David Crow6-Jul-05 5:56 
GeneralSimultaneous access to a serial device from two threads Pin
Juergen Kordes5-Jul-05 21:30
Juergen Kordes5-Jul-05 21:30 
GeneralRe: Simultaneous access to a serial device from two threads Pin
ThatsAlok5-Jul-05 21:42
ThatsAlok5-Jul-05 21:42 
Generalwindow media player Pin
Anonymous5-Jul-05 21:17
Anonymous5-Jul-05 21:17 
GeneralRe: window media player Pin
Jose Lamas Rios6-Jul-05 3:39
Jose Lamas Rios6-Jul-05 3:39 
Generalip adress Pin
_tasleem5-Jul-05 20:57
_tasleem5-Jul-05 20:57 
GeneralRe: ip adress Pin
ThatsAlok5-Jul-05 21:35
ThatsAlok5-Jul-05 21:35 
GeneralFont Problem Pin
Pazzuzu5-Jul-05 20:46
Pazzuzu5-Jul-05 20:46 
Hi all,

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 someone can Help....

QuestionTo delete functions via IDE of VC++ 2003 ? Pin
Maxwell Chen5-Jul-05 20:45
Maxwell Chen5-Jul-05 20:45 
Generalopening MDI in maximized form at startup Pin
sayup5-Jul-05 20:15
sayup5-Jul-05 20:15 
GeneralRe: opening MDI in maximized form at startup Pin
Antony T5-Jul-05 22:48
sussAntony T5-Jul-05 22:48 
Generalenum in a switch statement Pin
Ista5-Jul-05 20:13
Ista5-Jul-05 20:13 
GeneralRe: enum in a switch statement Pin
ThatsAlok5-Jul-05 20:26
ThatsAlok5-Jul-05 20:26 
GeneralRe: enum in a switch statement Pin
Bob Stanneveld5-Jul-05 22:18
Bob Stanneveld5-Jul-05 22:18 
GeneralRe: enum in a switch statement Pin
ThatsAlok6-Jul-05 1:44
ThatsAlok6-Jul-05 1:44 
GeneralRe: enum in a switch statement Pin
Bob Stanneveld6-Jul-05 1:47
Bob Stanneveld6-Jul-05 1:47 
GeneralRe: enum in a switch statement Pin
Ista6-Jul-05 8:56
Ista6-Jul-05 8:56 
GeneralRe: enum in a switch statement Pin
Rick York6-Jul-05 11:46
mveRick York6-Jul-05 11:46 
GeneralRe: enum in a switch statement Pin
Ista6-Jul-05 11:51
Ista6-Jul-05 11:51 
GeneralRe: enum in a switch statement Pin
Bob Stanneveld6-Jul-05 20:40
Bob Stanneveld6-Jul-05 20:40 
GeneralUsername n Password Pin
kireken5-Jul-05 19:10
kireken5-Jul-05 19:10 
GeneralRe: Username n Password Pin
Christian Graus5-Jul-05 19:33
protectorChristian Graus5-Jul-05 19:33 
GeneralRe: Username n Password Pin
kireken5-Jul-05 19:48
kireken5-Jul-05 19:48 
GeneralRe: Username n Password Pin
Christian Graus6-Jul-05 11:12
protectorChristian Graus6-Jul-05 11:12 
GeneralRe: Username n Password Pin
Anonymous6-Jul-05 19:46
Anonymous6-Jul-05 19:46 

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.