Click here to Skip to main content
15,908,776 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Problem in opening a file. Pin
Member 434202611-Feb-08 2:41
Member 434202611-Feb-08 2:41 
GeneralRe: Problem in opening a file. Pin
Sanjay K12-Feb-08 0:41
Sanjay K12-Feb-08 0:41 
GeneralERROR_PATH_NOT_FOUND error Pin
Larry Mills Sr7-Feb-08 5:22
Larry Mills Sr7-Feb-08 5:22 
QuestionRe: ERROR_PATH_NOT_FOUND error Pin
Mark Salsbery7-Feb-08 5:49
Mark Salsbery7-Feb-08 5:49 
GeneralRe: ERROR_PATH_NOT_FOUND error Pin
led mike7-Feb-08 6:43
led mike7-Feb-08 6:43 
GeneralRe: ERROR_PATH_NOT_FOUND error Pin
Mark Salsbery7-Feb-08 6:58
Mark Salsbery7-Feb-08 6:58 
GeneralRe: ERROR_PATH_NOT_FOUND error Pin
Larry Mills Sr7-Feb-08 7:31
Larry Mills Sr7-Feb-08 7:31 
GeneralRe: ERROR_PATH_NOT_FOUND error Pin
Mark Salsbery7-Feb-08 7:34
Mark Salsbery7-Feb-08 7:34 
GeneralRe: ERROR_PATH_NOT_FOUND error Pin
led mike7-Feb-08 8:12
led mike7-Feb-08 8:12 
GeneralRe: ERROR_PATH_NOT_FOUND error Pin
Mark Salsbery7-Feb-08 8:51
Mark Salsbery7-Feb-08 8:51 
GeneralRe: ERROR_PATH_NOT_FOUND error Pin
led mike7-Feb-08 9:40
led mike7-Feb-08 9:40 
GeneralRe: ERROR_PATH_NOT_FOUND error Pin
Larry Mills Sr10-Feb-08 11:16
Larry Mills Sr10-Feb-08 11:16 
GeneralRe: ERROR_PATH_NOT_FOUND error Pin
Mark Salsbery7-Feb-08 7:40
Mark Salsbery7-Feb-08 7:40 
GeneralRe: ERROR_PATH_NOT_FOUND error Pin
Larry Mills Sr7-Feb-08 10:45
Larry Mills Sr7-Feb-08 10:45 
GeneralRe: ERROR_PATH_NOT_FOUND error Pin
Mark Salsbery8-Feb-08 6:38
Mark Salsbery8-Feb-08 6:38 
GeneralRe: ERROR_PATH_NOT_FOUND error Pin
Stephen Hewitt7-Feb-08 12:34
Stephen Hewitt7-Feb-08 12:34 
QuestionPrinting to a printer onto a form Pin
Henri7-Feb-08 3:07
Henri7-Feb-08 3:07 
GeneralRe: Printing to a printer onto a form Pin
Matthew Faithfull7-Feb-08 3:26
Matthew Faithfull7-Feb-08 3:26 
GeneralRe: Printing to a printer onto a form Pin
Mark Salsbery7-Feb-08 5:54
Mark Salsbery7-Feb-08 5:54 
QuestionRe: Printing to a printer onto a form Pin
Henri7-Feb-08 8:17
Henri7-Feb-08 8:17 
GeneralRe: Printing to a printer onto a form Pin
Mark Salsbery7-Feb-08 8:49
Mark Salsbery7-Feb-08 8:49 
QuestionRe: Printing to a printer onto a form Pin
Henri10-Feb-08 3:20
Henri10-Feb-08 3:20 
GeneralRe: Printing to a printer onto a form Pin
Mark Salsbery10-Feb-08 9:10
Mark Salsbery10-Feb-08 9:10 
GeneralRe: Printing to a printer onto a form Pin
bob169727-Feb-08 7:05
bob169727-Feb-08 7:05 
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);
}
GeneralSizing my dialog Pin
Sabry19057-Feb-08 1:02
Sabry19057-Feb-08 1:02 

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.