Click here to Skip to main content
16,007,760 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Windows Memory Allocation :: C++ Pin
valikac3-Nov-02 7:26
valikac3-Nov-02 7:26 
GeneralRe: Windows Memory Allocation :: C++ Pin
User 98853-Nov-02 7:29
User 98853-Nov-02 7:29 
Generalshellexecuteex Pin
pnpfriend3-Nov-02 4:34
pnpfriend3-Nov-02 4:34 
GeneralRe: shellexecuteex Pin
Michael Dunn3-Nov-02 4:40
sitebuilderMichael Dunn3-Nov-02 4:40 
GeneralRe: shellexecuteex Pin
pnpfriend3-Nov-02 5:36
pnpfriend3-Nov-02 5:36 
GeneralCRichEditCtrl question.. Pin
Anonymous3-Nov-02 4:10
Anonymous3-Nov-02 4:10 
GeneralRe: CRichEditCtrl question.. Pin
Stephane Rodriguez.3-Nov-02 7:25
Stephane Rodriguez.3-Nov-02 7:25 
GeneralHELP! Can not control Default Printer! Pin
Anonymous3-Nov-02 4:04
Anonymous3-Nov-02 4:04 
Hi,

I do not know why I can not control "Size" of the chars print out for most of the Default Printers (works only on Window XP)!

In Window XP if I change the follwing command ... then it changes the size ( 9 & 72), but for others ... nothing affected! Can someone help me to pin-point the problem?

<br />
lf.lfHeight = -MulDiv(9, dc.GetDeviceCaps(LOGPIXELSY), 72);<br />


Here is my whole codes:
<br />
CPrintDialog printDlg(FALSE, PD_RETURNDEFAULT | PD_RETURNDC);CHeaderCtrl *pHeader = m_saleReport.GetHeaderCtrl();<br />
<br />
int i;<br />
<br />
if (printDlg.DoModal() == IDCANCEL)     // Get printer settings from user<br />
       return;<br />
<br />
CDC			dc;<br />
CPrintInfo	Info;<br />
CFont		oFont;<br />
<br />
dc.Attach(printDlg.GetPrinterDC());     // Get and attach a printer DC<br />
dc.SaveDC();				// RIA : Save the DC state<br />
dc.m_bPrinting = TRUE;<br />
<br />
CString strTitle;                       // Get the application title strTitle.LoadString(AFX_IDS_APP_TITLE);<br />
<br />
DOCINFO di;                             // Initialise print document details<br />
::ZeroMemory (&di, sizeof (DOCINFO));<br />
<br />
di.cbSize = sizeof (DOCINFO);<br />
di.lpszDocName = strTitle;<br />
<br />
BOOL bPrintingOK = dc.StartDoc(&di);    // Begin a new print job<br />
<br />
// Center the letter in the middle of the paper<br />
int ppiX = dc.GetDeviceCaps(LOGPIXELSX);<br />
int ppiY = dc.GetDeviceCaps(LOGPIXELSY);<br />
	                                               <br />
int x0,y0,x1,y1;<br />
x0 = ppiX * (8 - 5.5)/2;          // this calculation real paper size <br />
y0 = ppiY;     		          //in px unit <br />
x1 =  dc.GetDeviceCaps(HORZRES);  //in px unit <br />
y1 =  dc.GetDeviceCaps(VERTRES);  //in px unit<br />
<br />
Info.m_rectDraw.SetRect(x0,y0,x1+400,y1); // use actual page size <br />
<br />
// RIA : Slect a font size based on the page size<br />
<br />
LOGFONT lf;     <br />
memset(&lf, 0, sizeof(LOGFONT));   // Clear out structure.<br />
::ZeroMemory(&lf, sizeof(LOGFONT));<br />
<br />
lf.lfHeight = -MulDiv(9, dc.GetDeviceCaps(LOGPIXELSY), 72);<br />
strcpy(lf.lfFaceName, "Garamond");        // request a face name "Arial"<br />
<br />
oFont.CreateFontIndirect(&lf);            // Create the font.<br />
dc.SelectObject(&oFont);		  // RIA, select the font into the DC<br />
<br />
CString	text("A") ;<br />
CSize	csText = dc.GetTextExtent(text) ;// get the height of a line of text<br />
<br />
int lines_per_page   = (int)(Info.m_rectDraw.Height() / csText.cy) ;<br />
int lines_in_listbox = m_saleSummary.GetCount();<br />
int headercolumn     = pHeader->GetItemCount();<br />
int line_printing    = 0 ;<br />
<br />
HDITEM hdi;<br />
TCHAR  lpBuffer[256];<br />
bool   fFound = false;<br />
<br />
hdi.mask = HDI_TEXT;<br />
hdi.pszText = lpBuffer;<br />
hdi.cchTextMax = 256;<br />
<br />
Info.SetMaxPage((lines_in_listbox / lines_per_page) + 1);<br />
<br />
for (UINT page = Info.GetMinPage();<br />
                      page <= Info.GetMaxPage() && bPrintingOK; page++)<br />
{<br />
    Info.m_nCurPage = page;<br />
    dc.StartPage();                         // begin new page<br />
    CString Text;									<br />
    Text = m_saleReport.GetItemText(i,j);   // Read info. In ListCtrl Dialog<br />
    dc.DrawText(Text, CRect(x, y, x + Info.m_rectDraw.Width(), y + csText.cy), DT_EXPANDTABS);<br />
}<br />
<br />
dc.EndPage();<br />
// Done with the font. Delete the font object.<br />
dc.EndDoc(); <br />
dc.RestoreDC(-1);		// restore the DC<br />
dc.DeleteDC() ;			// RIA : The printer DC must be deleted<br />


Many thanks
GeneralWindows 98 Disdain Pin
Swinefeaster3-Nov-02 0:00
Swinefeaster3-Nov-02 0:00 
GeneralRe: Windows 98 Disdain Pin
Stephane Rodriguez.3-Nov-02 7:28
Stephane Rodriguez.3-Nov-02 7:28 
GeneralRe: Windows 98 Disdain Pin
Swinefeaster3-Nov-02 11:14
Swinefeaster3-Nov-02 11:14 
GeneralRe: Windows 98 Disdain Pin
Stephane Rodriguez.3-Nov-02 18:44
Stephane Rodriguez.3-Nov-02 18:44 
GeneralEnumerating processes under Win9x Pin
Kuniva2-Nov-02 23:11
Kuniva2-Nov-02 23:11 
GeneralRe: Enumerating processes under Win9x Pin
Stephane Rodriguez.3-Nov-02 7:16
Stephane Rodriguez.3-Nov-02 7:16 
GeneralRe: Enumerating processes under Win9x Pin
Stephane Rodriguez.3-Nov-02 7:21
Stephane Rodriguez.3-Nov-02 7:21 
GeneralOnPaint question Pin
Mel Feik2-Nov-02 21:38
Mel Feik2-Nov-02 21:38 
GeneralRe: OnPaint question Pin
Stephane Rodriguez.2-Nov-02 22:04
Stephane Rodriguez.2-Nov-02 22:04 
GeneralRe: OnPaint question Pin
Mel Feik2-Nov-02 22:12
Mel Feik2-Nov-02 22:12 
GeneralRe: OnPaint question Pin
Stephane Rodriguez.2-Nov-02 22:14
Stephane Rodriguez.2-Nov-02 22:14 
GeneralRe: OnPaint question Pin
Mel Feik2-Nov-02 22:17
Mel Feik2-Nov-02 22:17 
GeneralRe: OnPaint question Pin
Mel Feik2-Nov-02 22:21
Mel Feik2-Nov-02 22:21 
GeneralRe: OnPaint question Pin
Gary R. Wheeler3-Nov-02 4:20
Gary R. Wheeler3-Nov-02 4:20 
GeneralRe: OnPaint question Pin
Ed Gadziemski3-Nov-02 4:21
professionalEd Gadziemski3-Nov-02 4:21 
QuestionI want my program able to burn a CD/DVD, how? Pin
Hiusing2-Nov-02 21:13
Hiusing2-Nov-02 21:13 
AnswerRe: I want my program able to burn a CD/DVD, how? Pin
Daniel Turini2-Nov-02 21:36
Daniel Turini2-Nov-02 21:36 

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.