1

Topic: The program job of orientation of the press

I print the text through CPrinterDC. Before the press I have a dialogue for press adjustments. In this dialogue of adjustments I set press orientation landscape, because at me wide lines. Whether it is possible to set adjustment of orientation of the press program that the user had not to set each time press orientation in dialogue? Whether it is possible to make it means CPrinterDC? If it is possible, as? If it is impossible to make it by means of CPrinterDC how to make it in another way by means of MFC?

2

Re: The program job of orientation of the press

Hello, RussianFellow, you wrote: you work in a mode "day in a month"? Simply those questions on the press which you set last half a year, on idea dare for a week that who started to understand the press in MFC.

3

Re: The program job of orientation of the press

Hello, RussianFellow, whether you wrote RF> It is possible to set adjustment of orientation of the press program that the user had not to set each time press orientation in dialogue? Whether RF> it is possible to make it means CPrinterDC? If it is possible, as? If it is impossible to make it by means of CPrinterDC how to make it in another way by means of MFC? It is set not in DC, and in DEVMODE. Esteem MSDN about modes of printers in Windows (there an amount of copies, etc.).

4

Re: The program job of orientation of the press

Hello, qaz77, you wrote: Q> It is set not in DC, and in DEVMODE. Q> Esteem MSDN about modes of printers in Windows (there an amount of copies, etc.). And where to use this DEVMODE? You could not result a fragment of the code or give the reference to this usage?

5

Re: The program job of orientation of the press

Hello, RussianFellow, you wrote: RF> And where to use this DEVMODE? You could not result a fragment of the code or give the reference to this usage? To look at an example it is possible in description CWinApp:: GetPrinterDeviceDefaults: https://msdn.microsoft.com/en-us/library/t5799e1d.aspx

6

Re: The program job of orientation of the press

And still a question: whether it is possible to organize program printing of the information so that did not jump out dialogue of a choice/options of the printer? (By means of function TextOut or somehow still). That is that the user pushed button "Press" allocated on a dialog box of application, and there and then there would be a press, without any dialogues of adjustments or a printer choice?

7

Re: The program job of orientation of the press

Hello, RussianFellow, you wrote: RF> That is that the user pushed button "Press" allocated on a dialog box of application, and there and then there would be a press, without any dialogues of adjustments or a printer choice? CPrintInfo in the help. BOOL CMyView:: OnPreparePrinting (CPrintInfo* pInfo) {pInfo-> m_bDirect = TRUE;//TRUE if bypassing Print Dialog... return CView:: OnPreparePrinting (pInfo);} And generally read the documentation more, and we so with your "help" all help on MFC anew quote that here on . .. It is possible a question. What for to you this corpse MFC? I understand still support of old projects, but to do something new on MFC

8

Re: The program job of orientation of the press

All is good but what to do, if at me normal dialogue window application, instead of application of type "document-representation" (document-view)? That is at me is not present any CView or their descendants?

9

Re: The program job of orientation of the press

Hello, RussianFellow, you wrote: RF> All is good but what to do, if at me normal dialogue window application, instead of application of type "document-representation" (document-view)? RF> That is at me is not present any CView or their descendants? I not the telepathist. To guess that at you there for the code which "costs" behind pushing of this button, I cannot. Walk by a debugger deep into. Look as as it is caused. Half of questions disappears by itself. Second half will be more specific. Good luck!

10

Re: The program job of orientation of the press

Hello, RussianFellow, you wrote: RF> All is good but what to do, if at me normal dialogue window application, instead of application of type "document-representation" (document-view)? RF> That is at me is not present any CView or their descendants? http://rsdn.org/forum/mfc/6849112.1 the author: VladFein Date: 24.07 20:14

11

Re: The program job of orientation of the press

Here my pseudocode: void CMyDialog:: OnBnClickedButton1 {CDC printDC; defaultPrinter = ____; printDC.Attach (defaultPrinter); ___; cyPage = printDC.GetDeviceCaps (VERTRES); printDC.GetTextMetrics (&txtm); cyChar = txtm.tmHeight + txtm.tmExternalLeading; yPos = 800; DOCINFO docinfo;:: ZeroMemory (&docinfo,sizeof (DOCINFO)); docinfo.cbSize = sizeof (docinfo); docinfo.lpszDocName = "Simple"; docinfo.lpszOutput = NULL; docinfo.lpszDatatype = "RAW"; docinfo.fwType = 0; CFont *savedFont; savedFont = printDC.GetCurrentFont (); savedFont-> GetLogFont (<); strcpy (lt.ltFaceName, "Courier New"); lf.lfHeight = 110; lf.lfWidth = 52; myFont. CreateFontIndirect (&lf); printDC.SelectObject (&myFont); if (printDC.StartDoc (&docinfo)> 0) {if (printDC.StartPage ()> 0) {sprintf (s, "Test"); len = strlen (s); pzText = (LPCSTR) s; printDC.TextOut (320, yPos, pzText, len); yPos + = cyChar; printDC.EndPage ();} printDC.EndDoc ();} printDC.Detach ();} That is the printer used by default undertakes, landscape orientation of the press is set and on the press the line "Test" is deduced. The question is it is necessary to write all in the code instead of defaultPrinter = ____; and ___;?

12

Re: The program job of orientation of the press

Hello, RussianFellow, you wrote: RF> RF> defaultPrinter = ____; RF> RF> and RF> RF> ___; RF> RF>? Here so try: void CPage:: SetPrinterMode (CDC* pDC, int Mode) {if (Mode! =DMORIENT_LANDSCAPE && Mode! = DMORIENT_PORTRAIT) return; PRINTDLG* pPrintDlg = new PRINTDLG; AfxGetApp ()-> GetPrinterDeviceDefaults (pPrintDlg); DEVMODE* lpDevMode = (DEVMODE *):: GlobalLock (pPrintDlg-> hDevMode); lpDevMode-> dmOrientation = (short) Mode; pDC-> ResetDC (lpDevMode);:: GlobalUnlock (pPrintDlg-> hDevMode); delete pPrintDlg;}

13

Re: The program job of orientation of the press

Hello, Lexsus, you wrote: L> Here so try: L> L> void CPage:: SetPrinterMode (CDC* pDC, int Mode) L> {L> if (Mode! =DMORIENT_LANDSCAPE && Mode! = DMORIENT_PORTRAIT) L> return; L> PRINTDLG* pPrintDlg = new PRINTDLG; L> AfxGetApp ()-> GetPrinterDeviceDefaults (pPrintDlg); L> DEVMODE* lpDevMode = (DEVMODE *):: GlobalLock (pPrintDlg-> hDevMode); L> lpDevMode-> dmOrientation = (short) Mode; pDC->> ResetDC (lpDevMode); L>:: GlobalUnlock (pPrintDlg-> hDevMode); L> delete pPrintDlg; L>} L> At me at line pDC-> ResetDC (lpDevMode); the program fights with the message: Debug Assertion Failed Program: C:\Windows\system32\mfc110d.dll File: f:\dd\vctools\vc7libs\ship\atlmfc\include\afxwin1.inl Line: 737 That it means? How to rectify this error?

14

Re: The program job of orientation of the press

Hello, RussianFellow, you wrote: RF> Hello, Lexsus, you wrote: L>> Here so try: L>> L>> void CPage:: SetPrinterMode (CDC* pDC, int Mode) L>> {L>> if (Mode! =DMORIENT_LANDSCAPE && Mode! = DMORIENT_PORTRAIT) L>> return; L>> PRINTDLG* pPrintDlg = new PRINTDLG; L>> AfxGetApp ()-> GetPrinterDeviceDefaults (pPrintDlg); L>> DEVMODE* lpDevMode = (DEVMODE *):: GlobalLock (pPrintDlg-> hDevMode); L>> lpDevMode-> dmOrientation = (short) Mode; pDC->>> ResetDC (lpDevMode); L>>:: GlobalUnlock (pPrintDlg-> hDevMode); L>> delete pPrintDlg; L>>} L>> RF> At me at line RF> pDC->> ResetDC (lpDevMode); RF> RF> the program fights with the message: RF> RF> Debug Assertion Failed RF> Program: C:\Windows\system32\mfc110d.dll RF> File: f:\dd\vctools\vc7libs\ship\atlmfc\include\afxwin1.inl RF> Line: 737 RF> That it means? How to rectify this error? SetPrinterMode whence you cause?

15

Re: The program job of orientation of the press

Hello, Lexsus, you wrote: RF>> That it means? How to rectify this error? L> SetPrinterMode whence you cause? From function CPage:: OnBnClickedButton1 (): CPage:: OnBnClickedButton1 () {CDC printDC; setPrinterMode (&printDC,DMORIENT_LANDSCAPE);//the further actions;}

16

Re: The program job of orientation of the press

Hello, RussianFellow, you wrote: RF> Hello, Lexsus, you wrote: RF>>> That it means? How to rectify this error? L>> SetPrinterMode whence you cause? RF> from function CPage:: OnBnClickedButton1 (): RF> RF> CPage:: OnBnClickedButton1 () RF> {RF> CDC printDC; RF> setPrinterMode (&printDC,DMORIENT_LANDSCAPE); RF>//the further actions; RF>} RF> You as that should receive a context of press CDC and to transfer in setPrinterMode. In application Document/View it can be made we redefine OnBeginPrinting for example.

17

Re: The program job of orientation of the press

Hello, Lexsus, you wrote: L> You as that should receive a context of press CDC and to transfer in setPrinterMode. In application Document/View it can be made we redefine OnBeginPrinting for example. And what to do in normal dialogue application? Whether it is possible to receive in it a context of press CDC, to the appropriate printer by default, and then already to transfer it in function setPrinterMode?

18

Re: The program job of orientation of the press

Hello, RussianFellow, you wrote: RF> And what to do in normal dialogue application? To "smoke" MSDN: BOOL CWinApp:: GetPrinterDeviceDefaults (struct tagPDA* pPrintDlg); Well and further: typedef struct tagPD {DWORD lStructSize; HWND hwndOwner; HGLOBAL hDevMode; HGLOBAL hDevNames; HDC hDC; DWORD Flags; WORD nFromPage; WORD nToPage; WORD nMinPage; WORD nMaxPage; WORD nCopies; HINSTANCE hInstance; LPARAM lCustData; LPPRINTHOOKPROC lpfnPrintHook; LPSETUPHOOKPROC lpfnSetupHook; LPCTSTR lpPrintTemplateName; LPCTSTR lpSetupTemplateName; HGLOBAL hPrintTemplate; HGLOBAL hSetupTemplate;} PRINTDLG, *LPPRINTDLG;

19

Re: The program job of orientation of the press

RF> And what to do in normal dialogue application? Whether it is possible to receive in it a context of press CDC, to the appropriate printer by default, and then already to transfer it in function setPrinterMode? It is possible. You should read the book http://www.charlespetzold.com/pw5/ "This book has a whole chapter on printing (chapter 13, to be exact): what is a printing device context, what is DEVCAPS, printing dialogs etc." Found in Google. I only cannot understand one, what for to you dead MFC if is live Qt.

20

Re: The program job of orientation of the press

Hello, Arsen. Shnurkov, you wrote: AS> It is possible. You should read book AS> http://www.charlespetzold.com/pw5/ It once found the reference to Russian translation of this book. However, some time later, about it forgot. Because started to ask on it the link. https://rsdn.org/forum/winapi/6720399.1 the Author: Privalov Date: 09.03.17

21

Re: The program job of orientation of the press

Hello, Arsen. Shnurkov, you wrote: AS> Found in Google. I only cannot understand one, what for to you dead MFC if is live Qt. The project becomes on MFC. I - only one of participants of this project.