Click here to Skip to main content
15,895,485 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Detect network connection? Pin
lynchspawn20-Dec-05 8:28
lynchspawn20-Dec-05 8:28 
QuestionRe: Detect network connection? Pin
David Crow20-Dec-05 10:28
David Crow20-Dec-05 10:28 
AnswerRe: Detect network connection? Pin
ThatsAlok20-Dec-05 18:06
ThatsAlok20-Dec-05 18:06 
QuestioneVC++ 4.0 to SQL Server 2000 Pin
rbrad1234520-Dec-05 4:05
rbrad1234520-Dec-05 4:05 
QuestionSizing Toolbar buttons (Win32) Pin
Ward20-Dec-05 4:04
Ward20-Dec-05 4:04 
AnswerRe: Sizing Toolbar buttons (Win32) Pin
Ward21-Dec-05 0:45
Ward21-Dec-05 0:45 
QuestionHow to print contents of a control (say edit control), which is in a Dialog Pin
Vairamuthu. G.20-Dec-05 3:36
Vairamuthu. G.20-Dec-05 3:36 
AnswerRe: How to print contents of a control (say edit control), which is in a Dialog Pin
Ward20-Dec-05 4:23
Ward20-Dec-05 4:23 
Hi,

Use following code:

DOCINFO  di = { sizeof (DOCINFO) } ;<br />
   PRINTDLG pd ;<br />
   int             yChar, iCharsPerLine, iLinesPerPage, iTotalLines, iTotalPages, iPage, iLine, iLineNum ;<br />
   PTSTR           pstrBuffer ;<br />
<br />
   TCHAR           szJobName [64 + MAX_PATH] ;<br />
   TEXTMETRIC      tm ;<br />
   WORD            iColCopy, iNoiColCopy ;<br />
     <br />
   pd.lStructSize         = sizeof (PRINTDLG) ;<br />
   pd.hwndOwner           = hwnd ;<br />
   pd.hDevMode            = NULL ;<br />
   pd.hDevNames           = NULL ;<br />
   pd.hDC                 = NULL ;<br />
   pd.Flags               = PD_ALLPAGES | PD_COLLATE | PD_RETURNDC | PD_NOSELECTION ;<br />
   pd.nFromPage           = 0 ;<br />
   pd.nToPage             = 0 ;<br />
   pd.nMinPage            = 0 ;<br />
   pd.nMaxPage            = 0 ;<br />
   pd.nCopies             = 1 ;<br />
   pd.hInstance           = NULL ;<br />
   pd.lCustData           = 0L ;<br />
   pd.lpfnPrintHook       = NULL ;<br />
   pd.lpfnSetupHook       = NULL ;<br />
   pd.lpPrintTemplateName = NULL ;<br />
   pd.lpSetupTemplateName = NULL ;<br />
   pd.hPrintTemplate      = NULL ;<br />
   pd.hSetupTemplate      = NULL ;<br />
     <br />
   if (!PrintDlg (&pd))//select a printer<br />
          return TRUE ;<br />
     <br />
   if (0 == (iTotalLines = SendDlgItemMessage (hwnd,IDC_TEKSTVELD, EM_GETLINECOUNT, 0, 0)))<br />
          return TRUE ;<br />
     <br />
   GetTextMetrics (pd.hDC, &tm) ;<br />
   yChar = tm.tmHeight + tm.tmExternalLeading ;<br />
     <br />
   iCharsPerLine = GetDeviceCaps (pd.hDC, HORZRES) / tm.tmAveCharWidth ;<br />
   iLinesPerPage = GetDeviceCaps (pd.hDC, VERTRES) / yChar ;<br />
   iTotalPages   = (iTotalLines + iLinesPerPage - 1) / iLinesPerPage ;<br />
<br />
   pstrBuffer = (PTSTR)malloc (sizeof (TCHAR) * (iCharsPerLine + 1)) ;<br />
	 <br />
	   <br />
   di.lpszDocName = //Fill in some name for your document;<br />
<br />
   if (StartDoc (pd.hDC, &di) > 0)<br />
   {<br />
          for (iColCopy = 0 ;<br />
               iColCopy < ((WORD) pd.Flags & PD_COLLATE ? pd.nCopies : 1) ;<br />
               iColCopy++)<br />
          {<br />
               for (iPage = 0 ; iPage < iTotalPages ; iPage++)<br />
               {<br />
                    for (iNoiColCopy = 0 ;<br />
                         iNoiColCopy < (pd.Flags & PD_COLLATE ? 1 : pd.nCopies);<br />
                         iNoiColCopy++)<br />
                    {<br />
                         if (StartPage (pd.hDC) < 0)<br />
                         {<br />
                              bSuccess = FALSE ;<br />
                              break ;<br />
                         }<br />
                         for (iLine = 0 ; iLine < iLinesPerPage ; iLine++)<br />
                         {<br />
                              iLineNum = iLinesPerPage * iPage + iLine ;<br />
                              <br />
                              if (iLineNum > iTotalLines)<br />
                                   break ;<br />
                              <br />
                              *(int *) pstrBuffer = iCharsPerLine ;<br />
                              <br />
               //IDC_TEKSTVELD is the control containing the text you want to send to the printer<br />
							  int iAantalChars = (int) SendDlgItemMessage (hwnd,IDC_TEKSTVELD, EM_GETLINE,<br />
			                                      (WPARAM) iLineNum, (LPARAM) pstrBuffer);<br />
							  <br />
							  <br />
								TextOut (pd.hDC, 0, yChar * iLine, pstrBuffer, iAantalChars);<br />
							           <br />
                if (EndPage (pd.hDC) < 0)<br />
                {<br />
                  break ;<br />
                }<br />
                    <br />
                <br />
               }//END FOR<br />
               <br />
     }<br />
          <br />
     free (pstrBuffer) ;<br />
     DeleteDC (pd.hDC) ;


This will surely help you.;)

kind regards,

Ward
QuestionError in strcpy Pin
vikas amin20-Dec-05 3:02
vikas amin20-Dec-05 3:02 
AnswerRe: Error in strcpy Pin
khan++20-Dec-05 3:12
khan++20-Dec-05 3:12 
AnswerRe: Error in strcpy Pin
Ted Ferenc20-Dec-05 3:15
Ted Ferenc20-Dec-05 3:15 
AnswerRe: Error in strcpy Pin
RChin20-Dec-05 3:17
RChin20-Dec-05 3:17 
AnswerRe: Error in strcpy Pin
toxcct20-Dec-05 3:22
toxcct20-Dec-05 3:22 
GeneralRe: Error in strcpy Pin
vikas amin20-Dec-05 3:29
vikas amin20-Dec-05 3:29 
GeneralRe: Error in strcpy Pin
Smith#20-Dec-05 3:40
Smith#20-Dec-05 3:40 
AnswerRe: Error in strcpy Pin
Bob Stanneveld20-Dec-05 3:38
Bob Stanneveld20-Dec-05 3:38 
AnswerRe: Error in strcpy Pin
Blake Miller20-Dec-05 4:22
Blake Miller20-Dec-05 4:22 
GeneralRe: Error in strcpy Pin
toxcct20-Dec-05 4:35
toxcct20-Dec-05 4:35 
GeneralRe: Error in strcpy Pin
Blake Miller20-Dec-05 4:39
Blake Miller20-Dec-05 4:39 
AnswerRe: Error in strcpy Pin
John M. Drescher20-Dec-05 6:50
John M. Drescher20-Dec-05 6:50 
QuestionRe: Error in strcpy Pin
David Crow20-Dec-05 10:29
David Crow20-Dec-05 10:29 
AnswerRe: Error in strcpy Pin
ThatsAlok20-Dec-05 18:19
ThatsAlok20-Dec-05 18:19 
QuestionInitializing Structure in a class Pin
vikas amin20-Dec-05 2:45
vikas amin20-Dec-05 2:45 
AnswerRe: Initializing Structure in a class Pin
Russell'20-Dec-05 2:55
Russell'20-Dec-05 2:55 
GeneralRe: Initializing Structure in a class Pin
toxcct20-Dec-05 3:02
toxcct20-Dec-05 3: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.