Home » U++ Library support » RichText,QTF,RTF... » Name of a print job is missing  
	
		
		
			| Re: Name of a print job is missing [message #6462 is a reply to message #6461] | 
			Mon, 13 November 2006 11:49    | 
		 
		
			
				
				
				  | 
					
						  
						mirek
						 Messages: 14271 Registered: November 2005 
						
					 | 
					Ultimate Member  | 
					 | 
		 
		 
	 | 
 
	
		OK this seem to work fine for all cases: 
 
bool PrinterJob::Execute0(bool dodlg)
{
	pdlg = new Win32PrintDlg_;
	PRINTDLG& dlg = *pdlg;
	dlg.Flags = PD_DISABLEPRINTTOFILE|PD_NOSELECTION|PD_HIDEPRINTTOFILE|PD_RETURNDEFAULT;
	dlg.nFromPage = current;
	dlg.nToPage = current;
	dlg.nMinPage = from;
	dlg.nMaxPage = to;
	if(from != to)
		dlg.Flags |= PD_ALLPAGES;
	dlg.hwndOwner = GetActiveWindow();
	dlg.Flags |= PD_RETURNDEFAULT;
	if(!PrintDlg(&dlg)) return false;
	if(dlg.hDevMode) {
		DEVMODE *pDevMode = (DEVMODE*)::GlobalLock(dlg.hDevMode);
		pDevMode->dmOrientation = landscape ? DMORIENT_LANDSCAPE : DMORIENT_PORTRAIT;
		::GlobalUnlock(dlg.hDevMode);
	}
	HDC hdc;
	if(dodlg) {
		dlg.Flags = PD_DISABLEPRINTTOFILE|PD_NOSELECTION|PD_HIDEPRINTTOFILE|PD_RETURNDC;
		if(!PrintDlg(&dlg)) return false;
		hdc = dlg.hDC;
	}
	else {
		DEVNAMES *p = (DEVNAMES *)::GlobalLock(dlg.hDevNames);
		String driver = (const char *)p + p->wDriverOffset;
		String device = (const char *)p + p->wDeviceOffset;
		if(dlg.hDevMode) {
			DEVMODE *pDevMode = (DEVMODE*)::GlobalLock(dlg.hDevMode);
			hdc = CreateDC(driver, device, NULL, pDevMode);
			::GlobalUnlock(dlg.hDevMode);
		}
		else
			hdc = CreateDC(driver, device, NULL, NULL);
	}
	if(dlg.hDevMode)
		::GlobalFree(dlg.hDevMode);
	if(dlg.hDevNames)
		::GlobalFree(dlg.hDevNames);
	if(hdc) {
		draw = new PrintDraw(hdc, Nvl(name, Ctrl::GetAppName()));
		page.Clear();
		if(!(dlg.Flags & PD_PAGENUMS)) {
			dlg.nFromPage = dlg.nMinPage;
			dlg.nToPage = dlg.nMaxPage;
		}
		for(int c = 0; c < ((dlg.Flags & PD_COLLATE) ? dlg.nCopies : 1); c++)
			for(int i = dlg.nFromPage - 1; i <= dlg.nToPage - 1; i++)
				for(int c = 0; c < ((dlg.Flags & PD_COLLATE) ? 1 : dlg.nCopies); c++)
					page.Add(i);
		return true;
	}
	return false;
}
 
 
testcase (puttin' that to reference): 
 
#include <CtrlLib/CtrlLib.h>
GUI_APP_MAIN
{
	PrinterJob pj;
	if(PromptYesNo("Landscape?"))
		pj.Landscape();
	if(!PromptYesNo("Use default printer?"))
		pj.Execute();
	Draw& w = pj;
	w.StartPage();
	w.DrawText(0, 0, "Hello world!", Roman(100));
	w.EndPage();
}
 
 
Mirek
		
		
		
 |  
	| 
		
	 | 
 
 
 |  
  
 
	
	  | 
	 | 
	
		Name of a print job is missing
		By:  zsolt on Thu, 21 September 2006 01:48  
	 | 
 
	  | 
	 | 
	
		Re: Name of a print job is missing
		By:  laurice on Mon, 13 November 2006 02:18  
	 | 
 
	  | 
	 | 
	
		Re: Name of a print job is missing
		By:  mirek on Mon, 13 November 2006 08:39  
	 | 
 
	  | 
	 | 
	
		Re: Name of a print job is missing
		By:  laurice on Mon, 13 November 2006 09:14  
	 | 
 
	  | 
	 | 
	
		Re: Name of a print job is missing
		By:  zsolt on Mon, 13 November 2006 10:09  
	 | 
 
	  | 
	 | 
	
		Re: Name of a print job is missing
		By:  mirek on Mon, 13 November 2006 10:20  
	 | 
 
	  | 
	 | 
	
		Re: Name of a print job is missing
		By:  mirek on Mon, 13 November 2006 11:02  
	 | 
 
	  | 
	 | 
	
		Re: Name of a print job is missing
		By:  laurice on Mon, 13 November 2006 11:02  
	 | 
 
	  | 
	 | 
	
		Re: Name of a print job is missing
		By:  laurice on Mon, 13 November 2006 11:05  
	 | 
 
	  | 
	 | 
	
		Re: Name of a print job is missing
		By:  mirek on Mon, 13 November 2006 11:49  
	 | 
 
	  | 
	 | 
	
		Re: Name of a print job is missing
		By:  zsolt on Mon, 13 November 2006 12:10  
	 | 
  
Goto Forum:
 
 Current Time: Tue Nov 04 00:32:22 CET 2025 
 Total time taken to generate the page: 0.06145 seconds 
 |