Click here to Skip to main content
15,915,508 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: File IO using Assembly and C Pin
Luc Pattyn27-Jan-08 11:51
sitebuilderLuc Pattyn27-Jan-08 11:51 
GeneralRe: File IO using Assembly and C Pin
Umer Sheikh27-Jan-08 12:02
Umer Sheikh27-Jan-08 12:02 
GeneralRe: File IO using Assembly and C Pin
Mark Salsbery27-Jan-08 12:12
Mark Salsbery27-Jan-08 12:12 
GeneralRe: File IO using Assembly and C Pin
Umer Sheikh27-Jan-08 12:20
Umer Sheikh27-Jan-08 12:20 
GeneralRe: File IO using Assembly and C Pin
Umer Sheikh27-Jan-08 12:42
Umer Sheikh27-Jan-08 12:42 
GeneralRe: File IO using Assembly and C Pin
Luc Pattyn27-Jan-08 12:47
sitebuilderLuc Pattyn27-Jan-08 12:47 
GeneralMFC: printing a document through drawing on a CScrollView Pin
Sternocera27-Jan-08 4:41
Sternocera27-Jan-08 4:41 
GeneralRe: MFC: printing a document through drawing on a CScrollView Pin
bob1697227-Jan-08 6:42
bob1697227-Jan-08 6:42 
Here's a quick sample to plop into a new CScrollView doc/view app to see if the results are consistent using print preview. It's more of a WYSIWYG approach and simplifies printing because it uses the same drawing code to print that is used for the screen. Try this out in a new project then adapt what you need to your application.

NOTE: This was previous post of mine describing the print paging mechanism to someone but it demonstrates general printing. I hope it helps.

//CDocument members...

// Header file .h
protected:
CSize m_DocSize;

// Implementation file .cpp
CSize CYourDoc::GetDocSize() const
{
return m_DocSize;
}

CYourDoc::CYourDoc()
{
// TODO: add one-time construction code here
m_DocSize=CSize(2000,2800);
}

//CScrollView members...

// Header file .h
private:
int m_nPage;

// Implementation file .cpp
CYourView::CYourView()
{
// TODO: add construction code here
SetScrollSizes(MM_TEXT,CSize(0,0)); // Set arbitrary values

m_nPage=1;
}

/***************************************
NOTE: The pInfo parameter is uncommented
****************************************/
void CYourView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* pInfo)
{
// TODO: add extra initialization before printing
pInfo->SetMaxPage(3);
}

void CYourView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
// TODO: Add your specialized code here and/or call the base class
m_nPage=pInfo->m_nCurPage;

CScrollView::OnPrint(pDC, pInfo);
}

void CYourView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
CScrollView::OnPrepareDC(pDC);

// TODO: Add your specialized code here and/or call the base class

// Set up the DC for the current scale factor
int nExtentX;
int nExtentY;
CSize sizeDoc;
CRect rectClient;

pDC->SetMapMode(MM_ISOTROPIC);

// Get pertinent rectangle data
GetClientRect(&rectClient);
sizeDoc=GetDocument()->GetDocSize();

sizeDoc.cy=(-sizeDoc.cy); // Y goes down as it increments
pDC->SetWindowExt(sizeDoc); // Window extent is size of document

// Calculate viewport extent
nExtentX=rectClient.Width();
nExtentY=(int)((nExtentX*sizeDoc.cy)/(sizeDoc.cx));

// What kind of device context do we have?
if (pDC->IsPrinting()==TRUE) {
pDC->SetViewportExt(pDC->GetDeviceCaps(HORZRES),-pDC->GetDeviceCaps(VERTRES));
} else {
// Context is for screen
pDC->SetViewportExt(nExtentX,nExtentY);
}
}

void CYourView::ResetScrollBars()
{
CSize sizeDoc;
CClientDC dc(this);

this->OnPrepareDC(&dc); // Update the device context

sizeDoc=GetDocument()->GetDocSize();
dc.LPtoDP(&sizeDoc); // Logical to device

this->SetScrollSizes(MM_TEXT,sizeDoc); // Update scrollbars
}

void CYourView::OnSize(UINT nType, int cx, int cy)
{
CScrollView::OnSize(nType, cx, cy);

// TODO: Add your message handler code here
ResetScrollBars();
}

void CYourView::OnDraw(CDC* pDC)
{
CYourDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here

CSize sizeDoc=pDoc->GetDocSize();
CRect rectOutline(0,0,sizeDoc.cx,sizeDoc.cy);
rectOutline.DeflateRect(10,10); // Ensure we can see it

LOGFONT logFont={0};
memcpy(logFont.lfFaceName,"Arial",6);
logFont.lfHeight=300;

CFont font;
font.CreateFontIndirect(&logFont);

CFont* pOldFont=pDC->SelectObject(&font);
CBrush* pOldBrush=(CBrush*)pDC->SelectStockObject(NULL_BRUSH);
CString sMessage;
sMessage.Format("You can add code to center the printout later\nPage %d",m_nPage);
pDC->DrawText(sMessage,&rectOutline,DT_CENTER|DT_WORDBREAK);

pDC->Rectangle(&rectOutline);

pDC->SelectObject(pOldFont);
pDC->SelectObject(pOldBrush);
}
QuestionHow to Implent Browser/Server Architecture under Linux Pin
cy163@hotmail.com27-Jan-08 4:11
cy163@hotmail.com27-Jan-08 4:11 
Generalignore: cross-post Pin
Luc Pattyn27-Jan-08 4:42
sitebuilderLuc Pattyn27-Jan-08 4:42 
GeneralRe: How to Implent Browser/Server Architecture under Linux Pin
Paul Conrad27-Jan-08 10:24
professionalPaul Conrad27-Jan-08 10:24 
GeneralChanging the exe icon Pin
Stan the man27-Jan-08 3:25
Stan the man27-Jan-08 3:25 
GeneralRe: Changing the exe icon Pin
Mark Salsbery27-Jan-08 7:21
Mark Salsbery27-Jan-08 7:21 
GeneralRe: Changing the exe icon Pin
Hamid_RT27-Jan-08 20:42
Hamid_RT27-Jan-08 20:42 
Generalplus arrays Pin
gentleguy27-Jan-08 2:25
gentleguy27-Jan-08 2:25 
GeneralRe: plus arrays Pin
Joan M27-Jan-08 2:43
professionalJoan M27-Jan-08 2:43 
GeneralRe: plus arrays Pin
fd012900227-Jan-08 17:06
fd012900227-Jan-08 17:06 
GeneralFlick problem caused by Invalidate in OnMouseMove Pin
followait27-Jan-08 1:39
followait27-Jan-08 1:39 
QuestionRe: Flick problem caused by Invalidate in OnMouseMove Pin
Mark Salsbery27-Jan-08 7:30
Mark Salsbery27-Jan-08 7:30 
GeneralRe: Flick problem caused by Invalidate in OnMouseMove Pin
followait27-Jan-08 16:51
followait27-Jan-08 16:51 
GeneralRe: Flick problem caused by Invalidate in OnMouseMove Pin
Mark Salsbery27-Jan-08 19:15
Mark Salsbery27-Jan-08 19:15 
Generalabout exception specification Pin
George_George26-Jan-08 22:33
George_George26-Jan-08 22:33 
GeneralRe: about exception specification Pin
Maxwell Chen27-Jan-08 18:33
Maxwell Chen27-Jan-08 18:33 
GeneralRe: about exception specification Pin
George_George27-Jan-08 18:41
George_George27-Jan-08 18:41 
GeneralRe: about exception specification Pin
Maxwell Chen27-Jan-08 18:53
Maxwell Chen27-Jan-08 18:53 

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.