Click here to Skip to main content
15,886,724 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: dynamic two dimentional array Pin
David Crow12-Sep-07 8:41
David Crow12-Sep-07 8:41 
GeneralRe: dynamic two dimentional array Pin
Mark Salsbery12-Sep-07 8:42
Mark Salsbery12-Sep-07 8:42 
QuestionHow to change size of a win32 toolbar after TB_DELETEBUTTON Pin
ioctl5112-Sep-07 0:13
ioctl5112-Sep-07 0:13 
QuestionPrinting Problem Pin
pri_skit11-Sep-07 23:59
pri_skit11-Sep-07 23:59 
AnswerRe: Printing Problem Pin
Nelek12-Sep-07 0:29
protectorNelek12-Sep-07 0:29 
GeneralRe: Printing Problem Pin
pri_skit12-Sep-07 1:31
pri_skit12-Sep-07 1:31 
GeneralRe: Printing Problem Pin
Nelek12-Sep-07 1:42
protectorNelek12-Sep-07 1:42 
AnswerRe: Printing Problem [modified] Pin
bob1697212-Sep-07 1:54
bob1697212-Sep-07 1:54 
Have you tried a more WYSIWYG approach? Try using the MM_ANISOTROPIC mapping mode as it makes it easier to match your view and print output using the same OnDraw code.

Here's a quick sample to plop into a new CScrollView doc/view app to see if the results are consistent on your printers. Keep in mind that it's more important to preserve aspect ratio, keeping everything proportional, and ensuring no drawing code falls outside the printable area. You will find small variances in the metric accuracy on all printers so focus more on the relative placement and you'll suffer less print anxiety.

//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)
{
CTestPrintDoc* 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);
}

Generalproblem in url Pin
yadahav11-Sep-07 23:30
yadahav11-Sep-07 23:30 
GeneralRe: problem in url Pin
nitin311-Sep-07 23:38
nitin311-Sep-07 23:38 
GeneralRe: problem in url Pin
David Crow12-Sep-07 3:13
David Crow12-Sep-07 3:13 
QuestionRe: problem in url Pin
Hamid_RT12-Sep-07 6:58
Hamid_RT12-Sep-07 6:58 
QuestionProblem when adding JPEG images in ListBox Pin
Atul2311-Sep-07 23:29
Atul2311-Sep-07 23:29 
QuestionRe: Problem when adding JPEG images in ListBox Pin
David Crow12-Sep-07 3:15
David Crow12-Sep-07 3:15 
QuestionHow to make Unistall.exe Pin
GauranG Shah11-Sep-07 23:21
GauranG Shah11-Sep-07 23:21 
AnswerRe: How to make Unistall.exe Pin
Russell'12-Sep-07 0:06
Russell'12-Sep-07 0:06 
GeneralRe: How to make Unistall.exe [modified] Pin
GauranG Shah12-Sep-07 0:12
GauranG Shah12-Sep-07 0:12 
GeneralRe: How to make Unistall.exe Pin
Russell'12-Sep-07 2:06
Russell'12-Sep-07 2:06 
GeneralRe: How to make Unistall.exe Pin
GauranG Shah12-Sep-07 3:00
GauranG Shah12-Sep-07 3:00 
QuestionIs the OS Vista? Pin
Russell'12-Sep-07 3:25
Russell'12-Sep-07 3:25 
AnswerRe: Is the OS Vista? Pin
GauranG Shah12-Sep-07 4:14
GauranG Shah12-Sep-07 4:14 
Questionhow to find the list of activex controls Pin
chandu00411-Sep-07 23:13
chandu00411-Sep-07 23:13 
AnswerRe: how to find the list of activex controls Pin
nbugalia11-Sep-07 23:42
nbugalia11-Sep-07 23:42 
GeneralRe: how to find the list of activex controls Pin
chandu00411-Sep-07 23:58
chandu00411-Sep-07 23:58 
GeneralRe: how to find the list of activex controls Pin
nbugalia12-Sep-07 0:11
nbugalia12-Sep-07 0:11 

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.