Click here to Skip to main content
15,888,351 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Adding new font Pin
Monty210-Jul-06 22:27
Monty210-Jul-06 22:27 
GeneralRe: Adding new font Pin
Semion_N11-Jul-06 3:34
Semion_N11-Jul-06 3:34 
QuestionPrinting Document Pin
Ganesh_T10-Jul-06 21:52
Ganesh_T10-Jul-06 21:52 
AnswerRe: Printing Document Pin
Hamid_RT10-Jul-06 22:03
Hamid_RT10-Jul-06 22:03 
GeneralRe: Printing Document Pin
Ganesh_T10-Jul-06 22:39
Ganesh_T10-Jul-06 22:39 
GeneralRe: Printing Document Pin
Hamid_RT11-Jul-06 0:28
Hamid_RT11-Jul-06 0:28 
GeneralRe: Printing Document Pin
Ganesh_T11-Jul-06 1:04
Ganesh_T11-Jul-06 1:04 
AnswerRe: Printing Document Pin
Monty210-Jul-06 22:33
Monty210-Jul-06 22:33 
Ganesh_T wrote:
I tried with it but was giving whole scrren aftyer printing with reduced size.


Thats cause the printers resolution is more than Screens resolution


heres some sample code

CDC prtDC;
CPrintInfo printInfo;
CSize size;
DOCINFO di;

CSize paper_size;  //printer paper size in mm
int xLogPPI = 0;
int yLogPPI = 0;

	
if( AfxGetApp()->GetPrinterDeviceDefaults(&printInfo.m_pPD->m_pd) )
{
	HDC hDC = printInfo.m_pPD->m_pd.hDC;
	if (hDC == NULL)
		hDC = printInfo.m_pPD->CreatePrinterDC();
	if(hDC !=NULL)
		{
			prtDC.Attach(hDC);
			paper_size.cx = prtDC.GetDeviceCaps(HORZSIZE);
			paper_size.cy = prtDC.GetDeviceCaps(VERTSIZE);
			xLogPPI = prtDC.GetDeviceCaps(LOGPIXELSX);
			yLogPPI = prtDC.GetDeviceCaps(LOGPIXELSY);
		}
		else 
		{
			AfxMessageBox("Can not find printer. Please check installed/default printers.");
			return ;
		}
	}
	int scr_xLogPPI = pDC->GetDeviceCaps(LOGPIXELSX);
	int scr_yLogPPI = pDC->GetDeviceCaps(LOGPIXELSY);
	int paper_width = (int) ((double) paper_size.cx * (double) xLogPPI / 25.4);   //width of a printed page in pixels
	int paper_height = (int) ((double) paper_size.cy * (double) yLogPPI / 25.4);
	double ratio_x = (double) xLogPPI / (double) scr_xLogPPI;
	double ratio_y = (double) yLogPPI / (double) scr_yLogPPI;

	//Create GDI stuff
	CFont *pPrnFont = new CFont();
	LOGFONT lf = {0};
	lf.lfHeight = -14 * ratio_x;
	lf.lfWeight = FW_NORMAL;
	_tcscpy(lf.lfFaceName,"Times new roman");
	pPrnFont->CreateFontIndirect(&lf);
..
..
..


you need to multiply everything with ratio_x and ratio_y so that everythings printed like it is diplayed on the screen

Hope it Helps



You know you're obsessed with computer graphics when you're outside and you look up at the trees and think, "Wow! That's spectacular resolution!"

Only kings, presidents, editors, and people with tapeworms have the right to use the editorial "we."

GeneralRe: Printing Document [modified] Pin
Ganesh_T10-Jul-06 22:40
Ganesh_T10-Jul-06 22:40 
GeneralRe: Printing Document Pin
Monty210-Jul-06 22:55
Monty210-Jul-06 22:55 
Questiondetecting frame change in video Pin
Ram Murali10-Jul-06 21:46
Ram Murali10-Jul-06 21:46 
QuestionCTreeCtrl question Pin
zeus_master10-Jul-06 21:45
zeus_master10-Jul-06 21:45 
AnswerRe: CTreeCtrl question Pin
Hamid_RT10-Jul-06 21:47
Hamid_RT10-Jul-06 21:47 
AnswerRe: CTreeCtrl question Pin
Abhi Lahare10-Jul-06 21:52
Abhi Lahare10-Jul-06 21:52 
GeneralRe: CTreeCtrl question Pin
zeus_master10-Jul-06 22:07
zeus_master10-Jul-06 22:07 
QuestionProblem related to onPaint() Pin
LakshmiPathiRao10-Jul-06 21:33
LakshmiPathiRao10-Jul-06 21:33 
AnswerRe: Problem related to onPaint() Pin
Parthi_Appu10-Jul-06 21:41
Parthi_Appu10-Jul-06 21:41 
QuestionMFC Commandline.... Pin
Phil.Benson10-Jul-06 21:29
professionalPhil.Benson10-Jul-06 21:29 
AnswerRe: MFC Commandline.... Pin
Abhi Lahare10-Jul-06 21:47
Abhi Lahare10-Jul-06 21:47 
AnswerRe: MFC Commandline.... Pin
Monty210-Jul-06 22:20
Monty210-Jul-06 22:20 
GeneralRe: MFC Commandline.... Pin
Phil.Benson10-Jul-06 22:28
professionalPhil.Benson10-Jul-06 22:28 
QuestionIP ADRESS Pin
ashish dogra10-Jul-06 21:06
ashish dogra10-Jul-06 21:06 
AnswerRe: IP ADRESS Pin
Abhi Lahare10-Jul-06 21:12
Abhi Lahare10-Jul-06 21:12 
GeneralRe: IP ADRESS Pin
ashish dogra10-Jul-06 21:17
ashish dogra10-Jul-06 21:17 
AnswerRe: IP ADRESS Pin
A_Fa10-Jul-06 21:13
A_Fa10-Jul-06 21:13 

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.