Exemplo n.º 1
0
Fl_Gdi * fl_gdi_printer_chooser(Fl_Gdi_Settings * settings)
{

    PRINTDLG pd;
    pd.Flags       = PD_RETURNDC;
    PrintDlg(&pd);
    ZeroMemory(&pd, sizeof(pd));

    pd.lStructSize = sizeof(pd);

    pd.Flags       = PD_RETURNDC  | PD_ALLPAGES | PD_NOSELECTION | PD_NOPAGENUMS;
    pd.nCopies     = 1;
    pd.nMinPage =1;
    pd.nMaxPage =1;
    pd.nFromPage =1;
    pd.nToPage = 1;
    if(settings) {
        pd.hDevMode    = settings->mode;
        pd.hDevNames    = settings->names;
        pd.nCopies     = settings->copies();
        pd.nFromPage = settings->first_page();
        if(settings->max_page()) {
            pd.Flags &= ~PD_NOPAGENUMS ;
            pd.nMaxPage = settings->max_page();
            pd.nFromPage = settings->first_page();
            if(!settings->last_page())
                pd.nToPage = settings->max_page();
            else
                pd.nToPage = settings->last_page();
        }
    }



    if (PrintDlg(&pd)!=TRUE || !pd.hDC || !pd.hDevMode) {
        //int rrr =CommDlgExtendedError();
        return 0;
    };

    Fl_Gdi * gdi = new Fl_Gdi(pd.hDC, (DEVMODE *)pd.hDevMode);

    if(settings) {
        if(pd.Flags & PD_PAGENUMS) {
            settings->first_page(pd.nFromPage);
            settings->last_page(pd.nToPage);
            settings->mode = (DEVMODE *)pd.hDevMode;
            settings->names = (DEVNAMES *)pd.hDevNames;
        }
    } else
        gdi->delete_mode(1);
    return gdi;
}
Exemplo n.º 2
0
static void test_PrintDlgExW(void)
{
    LPPRINTDLGEXW pDlg;
    HRESULT res;

    /* Set CommDlgExtendedError != 0 */
    PrintDlg(NULL);
    SetLastError(0xdeadbeef);
    res = pPrintDlgExW(NULL);
    ok( (res == E_INVALIDARG),
        "got 0x%x with %u and %u (expected 'E_INVALIDARG')\n",
        res, GetLastError(), CommDlgExtendedError());


    pDlg = HeapAlloc(GetProcessHeap(), 0, (sizeof(PRINTDLGEXW)) + 8);
    if (!pDlg) return;

    /* lStructSize must be exact */
    ZeroMemory(pDlg, sizeof(PRINTDLGEXW));
    pDlg->lStructSize = sizeof(PRINTDLGEXW) - 1;
    PrintDlg(NULL);
    SetLastError(0xdeadbeef);
    res = pPrintDlgExW(pDlg);
    ok( (res == E_INVALIDARG),
        "got 0x%x with %u and %u (expected 'E_INVALIDARG')\n",
        res, GetLastError(), CommDlgExtendedError());


    ZeroMemory(pDlg, sizeof(PRINTDLGEXW));
    pDlg->lStructSize = sizeof(PRINTDLGEXW) + 1;
    PrintDlg(NULL);
    SetLastError(0xdeadbeef);
    res = pPrintDlgExW(pDlg);
    ok( (res == E_INVALIDARG),
        "got 0x%x with %u and %u (expected 'E_INVALIDARG')\n",
        res, GetLastError(), CommDlgExtendedError());


    ZeroMemory(pDlg, sizeof(PRINTDLGEXW));
    pDlg->lStructSize = sizeof(PRINTDLGEXW);
    SetLastError(0xdeadbeef);
    res = pPrintDlgExW(pDlg);
    ok( (res == E_HANDLE),
        "got 0x%x with %u and %u (expected 'E_HANDLE')\n",
        res, GetLastError(), CommDlgExtendedError());


    HeapFree(GetProcessHeap(), 0, pDlg);
    return;

}
Exemplo n.º 3
0
/*****************************************************************************
 * Startup the printing interface
 * Done at start of program
*****************************************************************************/
void StartTextPrnt(void)
{
   memset( &pd, 0, sizeof(PRINTDLG) );
   pd.lStructSize = sizeof(PRINTDLG);

   memset( &lf, 0, sizeof(LOGFONT) );

   strcpy( lf.lfFaceName, "LinePrinter BM" );
   offsetx = 450;
   offsety = 200;
   savelpi = 8;
   savecpi = 16;
   SetCPI( MAKELONG(savecpi,savelpi) );
   lf.lfWidth = lf.lfHeight = 1;
   lf.lfWeight = 400;
   lf.lfPitchAndFamily = FF_MODERN|FIXED_PITCH;
   // Get a DC handle to the system`s default printer. using
   // the PD_RETURNDEFAULT flag ensures that no dialog is opened.
   pd.Flags = PD_RETURNDC | PD_RETURNDEFAULT | PD_NOSELECTION;
   PrintDlg(&pd);
   if ( pd.hDevMode == NULL )
   {
      display_error(78,"Unable to initialise default printer",FALSE);
      return;
   }
   SetOrient( DMORIENT_PORTRAIT );
}
Exemplo n.º 4
0
/* Obtain printer device context */
static HDC get_printer_dc(short *width, short *height)
{
    PRINTDLG pdlg;
    PDEVMODE returnedDevmode;

    /*
     * XXX - can this be done without a Windows print dialog?
     *
     * "CreateDC()" creates a device context, and you can
     * apparently specify WINSPL16 as the driver name on
     * Windows OT, or the name of a "print provider", such as
     * "WINSPOOL" on Windows NT, to get a context for a printer.
     *
     * The device name would be the printer name as shown by the
     * Print Manager; is there a way to enumerate those?
     */

    /* Initialize the PRINTDLG structure. */
    memset(&pdlg, 0, sizeof(PRINTDLG));
    pdlg.lStructSize = sizeof(PRINTDLG);
    /* Set the flag to return printer DC. */
    pdlg.Flags =
        PD_RETURNDC |           /* return the device context we need */
        PD_NOPAGENUMS |         /* disable the "Pages" radio button */
        PD_NOSELECTION |        /* disable the "Selection" radio button */
        PD_USEDEVMODECOPIESANDCOLLATE;  /* let device print multiple pages */

    /* Invoke the printer dialog box. */
    if (PrintDlg(&pdlg)) {
        /* http://msdn.microsoft.com/en-us/library/windows/desktop/dd162931%28v=vs.85%29.aspx */
        returnedDevmode = (PDEVMODE)GlobalLock(pdlg.hDevMode);

        if (returnedDevmode == NULL) {
            if (pdlg.hDevMode)
                GlobalFree(pdlg.hDevMode);
            if (pdlg.hDevNames)
                GlobalFree(pdlg.hDevNames);
            return NULL;
        }

        if (returnedDevmode->dmOrientation == DMORIENT_LANDSCAPE) {
            *width = returnedDevmode->dmPaperLength;
            *height = returnedDevmode->dmPaperWidth;
        }
        else {  /* assume DMORIENT_PORTRAIT */
            *width = returnedDevmode->dmPaperWidth;
            *height = returnedDevmode->dmPaperLength;
        }

        GlobalUnlock(pdlg.hDevMode);

        if (pdlg.hDevMode)
            GlobalFree(pdlg.hDevMode);
        if (pdlg.hDevNames)
            GlobalFree(pdlg.hDevNames);
    }

    /* hDC member of the PRINTDLG structure contains the printer DC. */
    return pdlg.hDC;
}
Exemplo n.º 5
0
int wxWindowsPrintDialog::ShowModal()
{
    ConvertToNative( m_printDialogData );

    PRINTDLG *pd = (PRINTDLG*) m_printDlg;

    if (m_dialogParent)
        pd->hwndOwner = (HWND) m_dialogParent->GetHWND();
    else if (wxTheApp->GetTopWindow())
        pd->hwndOwner = (HWND) wxTheApp->GetTopWindow()->GetHWND();
    else
        pd->hwndOwner = 0;

    bool ret = (PrintDlg( pd ) != 0);

    pd->hwndOwner = 0;

    if ( ret != false && (pd->hDC) )
    {
        wxPrinterDC *pdc = new wxPrinterDC( (WXHDC) pd->hDC );
        m_printerDC = pdc;
        ConvertFromNative( m_printDialogData );
        return wxID_OK;
    }
    else
    {
        return wxID_CANCEL;
    }
}
Exemplo n.º 6
0
HDC MacPrinterCanvas::GetPrinterDC(){
#if 1
	PRINTDLG pd;

	// Initialize PRINTDLG
	ZeroMemory(&pd, sizeof(PRINTDLG));
	pd.lStructSize = sizeof(PRINTDLG);
	pd.hwndOwner   = NULL;
	pd.hDevMode    = NULL;     // Don't forget to free or store hDevMode
	pd.hDevNames   = NULL;     // Don't forget to free or store hDevNames
	pd.Flags       = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC; 
	pd.nCopies     = 1;
	pd.nFromPage   = 0xFFFF; 
	pd.nToPage     = 0xFFFF; 
	pd.nMinPage    = 1; 
	pd.nMaxPage    = 0xFFFF; 

	if (PrintDlg(&pd)==TRUE) {
		return pd.hDC;
	} 
#else
	static char szPrinter[80];
	char* szDevice, *szDriver, *szOutput;
	szDevice=szPrinter;
	GetProfileString("windows", "device", ",,,", szPrinter, 80);
	if (NULL != (szDevice = strtok(szPrinter, ",")) &&
		NULL != (szDriver = strtok(NULL, ", "))
		 //&& NULL != (szOutput = strtok(NULL, ", "))
		) {
			return CreateDC(szDriver, szDevice, NULL, NULL);
	}
#endif
	return 0;
}
Exemplo n.º 7
0
int Print::start_print(HWND ohwnd,HINSTANCE hThis) {

    hdc = GetDC(ohwnd);
    memDC = CreateCompatibleDC(hdc);

    print_init(&printdlg, ohwnd, hThis);
    if(!PrintDlg(&printdlg)) return 0;

    docinfo.cbSize = sizeof(DOCINFO);
    docinfo.lpszDocName = "Printing bitmaps";
    docinfo.lpszOutput = NULL;
    docinfo.lpszDatatype = NULL;
    docinfo.fwType = 0;

    if(!(GetDeviceCaps(printdlg.hDC, RASTERCAPS)
	 & (RC_BITBLT | RC_STRETCHBLT|RC_BITMAP64 |
	    RC_DI_BITMAP| RC_DIBTODEV |RC_PALETTE |RC_SCALING |RC_STRETCHBLT|RC_STRETCHDIB))) {
	/*
	  MessageBox(ohwnd, "Cannot Print Raster Images",
	  "Error", MB_OK);
	*/
	return NULL;
    }

    StartDoc(printdlg.hDC, &docinfo);
    //##	begin	zhoubin	000406
    printer_mem_dc = CreateCompatibleDC(printdlg.hDC);
    //##	end		zhoubin	000406

    return 1;
}
Exemplo n.º 8
0
void Printer::GetDefault()
{
	DeleteGlobals();
	pd.Flags = PD_RETURNDEFAULT;
	PrintDlg(&pd);
	// pd now has hDevMode and hDevNames set
}
Exemplo n.º 9
0
BOOL Printer::PrintDialog(Window *Obj,UINT Flags)
{
	pd.hwndOwner = Obj->hWnd;
	pd.Flags = Flags;

	while (PrintDlg(&pd)==0)
	{
		switch (CommDlgExtendedError())
		{
			case PDERR_DEFAULTDIFFERENT:
			{
				DEVNAMES *dn=(DEVNAMES*) GlobalLock(pd.hDevNames);
				dn->wDefault&=~DN_DEFAULTPRN;
				GlobalUnlock(pd.hDevNames);
				break;
			}
			case PDERR_PRINTERNOTFOUND:
				MessageBox(Obj->hWnd,"Printer not Found\r\nReverting to default printer","Error",MB_OK);
				GetDefault();
				pd.Flags = Flags; // reset flags as GetDefault changes them
				break;
			default:
				return FALSE;
		}
	}
	return TRUE;
}
Exemplo n.º 10
0
void Print(HWND hWnd)
{
	PRINTDLG PrintDialog;
	memset(&PrintDialog, 0, sizeof(PRINTDLG));
	PrintDialog.lStructSize = sizeof(PRINTDLG);
	PrintDialog.hwndOwner = hWnd;
	PrintDialog.hDevMode = NULL;
	PrintDialog.hDevNames = NULL;
	PrintDialog.nCopies = 1;
	PrintDialog.Flags = PD_RETURNDC;
	PrintDialog.nMinPage = 1;
	PrintDialog.nMaxPage = 0xFFFF;
	PrintDlg(&PrintDialog);
	DOCINFO docInfo;
	docInfo.cbSize = sizeof(docInfo);
	docInfo.lpszDocName = L"Printing";
	docInfo.lpszOutput = 0;
	docInfo.lpszDatatype = 0;
	docInfo.fwType = 0;
	StartDoc(PrintDialog.hDC, &docInfo); 
	RECT printRect;
	GetClientRect(hWnd, &printRect);
	StretchBlt(PrintDialog.hDC, 0, 0, scrhor*4, scrvert*4, hdc1, scrhor/3, scrvert/3, scrhor/3*2,scrvert/3*2, SRCCOPY);
	EndDoc(PrintDialog.hDC);
}
Exemplo n.º 11
0
// This form is deprecated
wxPrinterDC::wxPrinterDC(const wxString& driver_name,
                         const wxString& device_name,
                         const wxString& file,
                         bool interactive,
                         wxPrintOrientation orientation)
{
    m_isInteractive = interactive;

    if ( !file.empty() )
        m_printData.SetFilename(file);

#if wxUSE_COMMON_DIALOGS
    if ( interactive )
    {
        PRINTDLG pd;

        pd.lStructSize = sizeof( PRINTDLG );
        pd.hwndOwner = (HWND) NULL;
        pd.hDevMode = (HANDLE)NULL;
        pd.hDevNames = (HANDLE)NULL;
        pd.Flags = PD_RETURNDC | PD_NOSELECTION | PD_NOPAGENUMS;
        pd.nFromPage = 0;
        pd.nToPage = 0;
        pd.nMinPage = 0;
        pd.nMaxPage = 0;
        pd.nCopies = 1;
        pd.hInstance = (HINSTANCE)NULL;

        m_ok = PrintDlg( &pd ) != 0;
        if ( m_ok )
        {
            m_hDC = (WXHDC) pd.hDC;
        }
    }
    else
#endif // wxUSE_COMMON_DIALOGS
    {
        if ( !driver_name.empty() && !device_name.empty() && !file.empty() )
        {
            m_hDC = (WXHDC) CreateDC(driver_name.t_str(),
                                     device_name.t_str(),
                                     file.fn_str(),
                                     NULL);
        }
        else // we don't have all parameters, ask the user
        {
            wxPrintData printData;
            printData.SetOrientation(orientation);
            m_hDC = wxGetPrinterDC(printData);
        }

        m_ok = m_hDC ? true: false;

        // as we created it, we must delete it as well
        m_bOwnsDC = true;
    }

    Init();
}
Exemplo n.º 12
0
main ()
{
	PRINTDLG	pd;
	DOCINFO		di;
	char*		szMessage;

	memset (&pd, 0, sizeof(PRINTDLG));
	memset (&di, 0, sizeof(DOCINFO));

	di.cbSize = sizeof(DOCINFO);
	di.lpszDocName = "Test";

	pd.lStructSize = sizeof(PRINTDLG);
	pd.Flags = PD_PAGENUMS | PD_RETURNDC;
	pd.nFromPage = 1;
	pd.nToPage = 1;
	pd.nMinPage = 1;
	pd.nMaxPage = 1;

	szMessage = 0;

	if (PrintDlg (&pd))
	{
		if (pd.hDC)
		{
			if (StartDoc (pd.hDC, &di) != SP_ERROR)
			{
				StartPage (pd.hDC);

				TextOut (pd.hDC, 0, 0, "Hello, printer!", 15);

				EndPage (pd.hDC);

				EndDoc (pd.hDC);

				szMessage = "Printed.";
			}
			else
			{
				szMessage = "Could not start document.";
			}
		}
		else
		{
			szMessage = "Could not create device context.";
		}
	}
	else
	{
		szMessage = "Canceled or printer could not be setup.";
	}

	if (szMessage)
	{
		MessageBox (NULL, szMessage, "Print Test", MB_OK);
	}

	return 0;
}
Exemplo n.º 13
0
void SelPrinter(HWND hDlg){
  PRINTDLG pd;
  ZeroMemory(&pd,sizeof(PRINTDLG));
  pd.lStructSize = sizeof(PRINTDLG);
  pd.hwndOwner = hDlg;

  HGLOBAL hNewDevMode = NULL;
  HGLOBAL hNewDevNames = NULL;
  if(hDevMode != NULL && hDevNames != NULL){
    int size = GetSizeOfDevMode(hDevMode);
    hNewDevMode = GlobalAlloc(GHND,size);
    GlobalCpy(hNewDevMode,hDevMode,size);
    size = GetSizeOfDevNames(hDevNames);
    hNewDevNames = GlobalAlloc(GHND,size);
    GlobalCpy(hNewDevNames,hDevNames,size);
  }
  pd.hDevMode = hNewDevMode;
  pd.hDevNames = hNewDevNames;
  pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC | 
             PD_NOPAGENUMS | PD_NOSELECTION | PD_HIDEPRINTTOFILE;
  pd.nCopies = GetCurrentPrinterCopies();
  pd.nFromPage = 1;
  pd.nToPage = 1;
  pd.nMinPage = 1;
  pd.nMaxPage = 1;

  if(PrintDlg(&pd)){
    if(hPrintDC != NULL){
      DeleteDC(hPrintDC);
    }
    hPrintDC = pd.hDC;

    int size = GetSizeOfDevMode(pd.hDevMode);
    if(hDevMode != NULL){
      GlobalReAlloc(hDevMode,size,0);
    }else{
      hDevMode = GlobalAlloc(GHND,size);
    }
    GlobalCpy(hDevMode,pd.hDevMode,size);
    
    size = GetSizeOfDevNames(pd.hDevNames);
    if(hDevNames != NULL){
      GlobalReAlloc(hDevNames,size,0);
    }else{
      hDevNames = GlobalAlloc(GHND,size);
    }
    GlobalCpy(hDevNames,pd.hDevNames,size);

  }
  SetCurrentDirectoryToExePath();

  if(pd.hDevMode != NULL){
    GlobalFree(pd.hDevMode);
  }

  if(pd.hDevMode != NULL){
    GlobalFree(pd.hDevMode);
  }
}
Exemplo n.º 14
0
int PrintBox ( void )
{
	// Gain HWND if can
	hwnd = NULL;
	if ( g_pGlob )
		hwnd = g_pGlob->hWnd;

	// Initialize PRINTDLG
	ZeroMemory(&pd, sizeof(PRINTDLG));
	pd.lStructSize = sizeof(PRINTDLG);
	pd.hwndOwner   = hwnd;
	pd.hDevMode    = NULL;      // Don't forget to free or store hDevMode.
	pd.hDevNames   = NULL;      // Don't forget to free or store hDevNames.
	pd.Flags       = PD_ALLPAGES | PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC | PD_HIDEPRINTTOFILE | PD_NOPAGENUMS; 
	pd.nCopies     = 1;
	pd.nFromPage   = 0; 
	pd.nToPage     = 0; 
	pd.nMinPage    = 1; 
	pd.nMaxPage    = 1; 

	// Print Setup
	if (PrintDlg(&pd)==TRUE)
	{
		// Free unused data
		if (pd.hDevMode) GlobalFree (pd.hDevMode);
		if (pd.hDevNames) GlobalFree (pd.hDevNames); 

		// Prepare Document
		di.cbSize = sizeof(DOCINFO); 
		di.lpszDocName = "Printing Document"; 
		di.lpszDatatype = (LPTSTR) NULL; 
		di.lpszOutput = (LPTSTR) NULL; 
		di.fwType = 0; 

		// Begin a print job by calling the StartDoc function. 
		int nError = StartDoc(pd.hDC, &di); 
		if (nError == SP_ERROR) 
		{
			DeleteDC(pd.hDC); 
			pd.hDC = NULL;
			return 0;
		}
		
		// Inform the driver that the application is about to begin 
		nError = StartPage(pd.hDC); 
		if (nError <= 0) 
		{
			DeleteDC(pd.hDC); 
			pd.hDC = NULL;
			return 0;
		}
	}
	else
		return 0;

	// success - begin sending text
	return 1;
}
Exemplo n.º 15
0
	HDC Printer_getDC (void) {
		if (! theWinPrint. hDevMode) {
			memset (& theWinPrint, 0, sizeof (PRINTDLG));
			theWinPrint. lStructSize = sizeof (PRINTDLG);
			theWinPrint. Flags = PD_RETURNDEFAULT | PD_RETURNDC;
			PrintDlg (& theWinPrint);
		}
		return theWinPrint. hDC;
	}
Exemplo n.º 16
0
Arquivo: POWPRINT.C Projeto: Madzi/POW
void FAR SetupPrinter (HWND hwnd)
{  
    DWORD flags;

    flags=printerData.Flags;
    printerData.Flags|=PD_PRINTSETUP;
    PrintDlg((LPPRINTDLG)&printerData);
    printerData.Flags=flags;
}
Exemplo n.º 17
0
// Returns default device and port names
static bool wxGetDefaultDeviceName(wxString& deviceName, wxString& portName)
{
    deviceName.clear();

    LPDEVNAMES  lpDevNames;
    LPTSTR      lpszDeviceName;
    LPTSTR      lpszPortName;

    PRINTDLG    pd;

    // Cygwin has trouble believing PRINTDLG is 66 bytes - thinks it is 68
#ifdef __GNUWIN32__
    memset(&pd, 0, 66);
    pd.lStructSize    = 66; // sizeof(PRINTDLG);
#else
    memset(&pd, 0, sizeof(PRINTDLG));
    pd.lStructSize    = sizeof(PRINTDLG);
#endif

    pd.hwndOwner      = (HWND)NULL;
    pd.hDevMode       = NULL; // Will be created by PrintDlg
    pd.hDevNames      = NULL; // Ditto
    pd.Flags          = PD_RETURNDEFAULT;
    pd.nCopies        = 1;

    if (!PrintDlg((LPPRINTDLG)&pd))
    {
        if ( pd.hDevMode )
            GlobalFree(pd.hDevMode);
        if (pd.hDevNames)
            GlobalFree(pd.hDevNames);

        return false;
    }

    if (pd.hDevNames)
    {
        lpDevNames = (LPDEVNAMES)GlobalLock(pd.hDevNames);
        lpszDeviceName = (LPTSTR)lpDevNames + lpDevNames->wDeviceOffset;
        lpszPortName   = (LPTSTR)lpDevNames + lpDevNames->wOutputOffset;

        deviceName = lpszDeviceName;
        portName = lpszPortName;

        GlobalUnlock(pd.hDevNames);
        GlobalFree(pd.hDevNames);
        pd.hDevNames=NULL;
    }

    if (pd.hDevMode)
    {
        GlobalFree(pd.hDevMode);
        pd.hDevMode=NULL;
    }
    return ( !deviceName.empty() );
}
Exemplo n.º 18
0
HDC CDrawApp::GetDefaultPrinterIC()
{
PRINTDLG pd;
	memset(&pd,0,sizeof(PRINTDLG));
	pd.lStructSize = sizeof(PRINTDLG);
	pd.Flags = PD_RETURNDEFAULT | PD_RETURNIC; 
	DWORD i;
	if (!PrintDlg(&pd)) 
		i=CommDlgExtendedError();
	return pd.hDC;
}
Exemplo n.º 19
0
void printSetup(int calledFromCleanThread, int devmodeSize,
			   char *devmode, char *device, char *driver, char *output,
			   int *ok, PRINTDLG **pdPtr)
{
  	int			deviceLength, driverLength, outputLength;
	HANDLE		hDevnames,hDevmode;
	static PRINTDLG	pd;

	// Set up DEVNAMES structure

	//rMessageBox(NULL, MB_APPLMODAL, "in printSetup", "");
	deviceLength	= strlen(device)+1;
	driverLength	= strlen(driver)+1;
	outputLength	= strlen(output)+1;

	hDevnames	= setupDevnames(deviceLength,driverLength,outputLength,device,driver,output);

	// Set up DEVMODE structure
	hDevmode	= setupDevmode(devmodeSize,devmode);

	// Set up print dialog record
	pd.lStructSize = sizeof(PRINTDLG);
	pd.hwndOwner = calledFromCleanThread ? NULL : ghMainWindow;	// (NULL = desktop)
//	pd.hwndOwner = NULL;	// (NULL = desktop)
		// the handle must belong to the active thread, otherwise PrintDlg will crash
		// When this function is called from the Clean thread, ghMainWindow will not
		// belong to the active thread.
	pd.hDevMode = hDevmode;
	pd.hDevNames = hDevnames;
	pd.hDC = NULL;
	pd.Flags =	PD_PRINTSETUP | PD_ENABLESETUPHOOK;
	pd.nFromPage = 1;
	pd.nToPage = 1;
	pd.nMinPage = 1;
	pd.nMaxPage = USHRT_MAX;
	pd.nCopies = 1;
	pd.hInstance = NULL;
	pd.lCustData = 0L;
	pd.lpfnPrintHook = NULL;
	pd.lpfnSetupHook =  DialogToFrontHook;
	pd.lpPrintTemplateName = NULL;
	pd.lpSetupTemplateName = NULL;
	pd.hPrintTemplate = NULL;
	pd.hSetupTemplate = NULL;

	// Open print dialog
	*ok	= PrintDlg(&pd);
	*pdPtr = &pd;

	if (hDevnames!=pd.hDevNames) LocalFree(hDevnames);
	if (hDevmode!=pd.hDevMode) LocalFree(hDevmode);

}
Exemplo n.º 20
0
void CMainFrame::OnFilePrint()
{
    // Bring up a dialog to choose the printer
    PRINTDLG pd = {0};
    pd.lStructSize = sizeof(pd);
    pd.Flags = PD_RETURNDC;
    pd.hwndOwner = m_hWnd;
    // Retrieve the printer DC
    PrintDlg(&pd);
    // TODO:
    // Add your own code here. Refer to the tutorial for additional information
}
Exemplo n.º 21
0
VOID DIALOG_FilePrinterSetup(VOID)
{
    PRINTDLG printer;

    ZeroMemory(&printer, sizeof(printer));
    printer.lStructSize         = sizeof(printer);
    printer.hwndOwner           = Globals.hMainWnd;
    printer.hInstance           = Globals.hInstance;
    printer.Flags               = PD_PRINTSETUP;
    printer.nCopies             = 1;

    PrintDlg(&printer);
}
Exemplo n.º 22
0
static HENHMETAFILE copyToMetafile (Picture me) {
	RECT rect;
	HDC dc;
	PRINTDLG defaultPrinter;
	int resolution;
	memset (& defaultPrinter, 0, sizeof (PRINTDLG));
	defaultPrinter. lStructSize = sizeof (PRINTDLG);
	defaultPrinter. Flags = PD_RETURNDEFAULT | PD_RETURNDC;
	PrintDlg (& defaultPrinter);
	SetRect (& rect, my selx1 * 2540, (12 - my sely2) * 2540, my selx2 * 2540, (12 - my sely1) * 2540);
	dc = CreateEnhMetaFile (defaultPrinter. hDC, nullptr, & rect, L"Praat\0");
	if (! dc) Melder_throw (U"Cannot create Windows metafile.");
	resolution = GetDeviceCaps (dc, LOGPIXELSX);   // Virtual PC: 360; Parallels Desktop: 600
	//Melder_fatal (U"resolution ", resolution);
	if (Melder_debug == 6) {
		DEVMODE *devMode = * (DEVMODE **) defaultPrinter. hDevMode;
		MelderInfo_open ();
		MelderInfo_writeLine (U"DEVICE CAPS:");
		MelderInfo_writeLine (U"aspect x ", GetDeviceCaps (dc, ASPECTX),
			U" y ", GetDeviceCaps (dc, ASPECTY));
		MelderInfo_writeLine (U"res(pixels) hor ", GetDeviceCaps (dc, HORZRES),
			U" vert ", GetDeviceCaps (dc, VERTRES));
		MelderInfo_writeLine (U"size(mm) hor ", GetDeviceCaps (dc, HORZSIZE),
			U" vert ", GetDeviceCaps (dc, VERTSIZE));
		MelderInfo_writeLine (U"pixels/inch hor ", GetDeviceCaps (dc, LOGPIXELSX),
			U" vert ", GetDeviceCaps (dc, LOGPIXELSY));
		MelderInfo_writeLine (U"physicalOffset(pixels) hor ", GetDeviceCaps (dc, PHYSICALOFFSETX),
			U" vert ", GetDeviceCaps (dc, PHYSICALOFFSETY));
		MelderInfo_writeLine (U"PRINTER:");
		MelderInfo_writeLine (U"dmFields ", devMode -> dmFields);
		if (devMode -> dmFields & DM_YRESOLUTION)
			MelderInfo_writeLine (U"y resolution ", devMode -> dmYResolution);
		if (devMode -> dmFields & DM_PRINTQUALITY)
			MelderInfo_writeLine (U"print quality ", devMode -> dmPrintQuality);
		if (devMode -> dmFields & DM_PAPERWIDTH)
			MelderInfo_writeLine (U"paper width ", devMode -> dmPaperWidth);
		if (devMode -> dmFields & DM_PAPERLENGTH)
			MelderInfo_writeLine (U"paper length ", devMode -> dmPaperLength);
		if (devMode -> dmFields & DM_PAPERSIZE)
			MelderInfo_writeLine (U"paper size ", devMode -> dmPaperSize);
		if (devMode -> dmFields & DM_ORIENTATION)
			MelderInfo_writeLine (U"orientation ", devMode -> dmOrientation);
		MelderInfo_close ();
	}
	autoGraphics pictGraphics = Graphics_create_screen ((void *) dc, nullptr, resolution);
	Graphics_setWsViewport (pictGraphics.peek(), 0, WIN_WIDTH * resolution, 0, WIN_HEIGHT * resolution);
	Graphics_setWsWindow (pictGraphics.peek(), 0.0, WIN_WIDTH, 12.0 - WIN_HEIGHT, 12.0);
	Graphics_play (my graphics.get(), pictGraphics.peek());
	HENHMETAFILE metafile = CloseEnhMetaFile (dc);
	return metafile;
}
Exemplo n.º 23
0
HDC mswGetPrinterDC( void )
{
	if (!printInit()) {
		return (HDC)0;
	}
	/*memset( &printDlg, 0, sizeof printDlg );*/
	printDlg.lStructSize = sizeof printDlg;
	printDlg.hwndOwner = NULL;
	printDlg.Flags = PD_RETURNDC|PD_NOPAGENUMS|PD_NOSELECTION;
	if (PrintDlg(&printDlg) != 0)
		return printDlg.hDC;
	else
		return (HDC)0;
}
Exemplo n.º 24
0
void Fl_Gdi_Settings::init()
{
    if(mode || names) return; //do not need to initialize
    PRINTDLG pd;
    ZeroMemory(&pd, sizeof(PRINTDLG));
    pd.lStructSize = sizeof(PRINTDLG);
    pd.hwndOwner   = 0;
    pd.hDevMode    = NULL;
    pd.hDevNames    = NULL;
    pd.Flags       = PD_USEDEVMODECOPIESANDCOLLATE | PD_ALLPAGES | PD_RETURNDEFAULT | PD_NOSELECTION;
    PrintDlg(&pd);
    mode = (DEVMODE *)pd.hDevMode;
    names = (DEVNAMES *)pd.hDevNames;
}
Exemplo n.º 25
0
static bool print(ITile *pDraw)
{
	PRINTDLG pd = {0};
	pd.lStructSize = sizeof pd;

	/* 
	 * get rid of PD_RETURNDEFAULT on the line below if you'd like to
	 * see the "Printer Settings" dialog!
	 *
	 */
	pd.Flags = PD_RETURNDEFAULT | PD_RETURNDC;

	// try to retrieve the printer DC
	if( !PrintDlg(&pd) )
	{
		return false;
	}

	DOCINFO di = {0};
	HDC hPrinter = pd.hDC;

	// initialization of the printing!

	// start the first and only page

	Printer canvas(hPrinter);

	RECT rect = {0};
	canvas.GetClipBox(&rect);
	Tiles::rect_t wrect;
	wrect.x = rect.left;
	wrect.y = rect.top;
	wrect.wide = rect.right - rect.left;
	wrect.high = rect.bottom - rect.top;
	pDraw->setRect(wrect);

	pDraw->Draw(&canvas, false);

	// uncomment the following line to print in colour! :)
	// SetTextColor( hPrinter, 0x0000FF );

	// finish the first page
	EndPage( hPrinter );

	// end this document and release the printer's DC
	EndDoc( hPrinter );
	//DeleteDC( hPrinter );
	return true;
}
Exemplo n.º 26
0
bool GPrinter::Browse(GView *Parent)
{
	d->Info.hwndOwner = (Parent) ? Parent->Handle() : 0;
	d->Info.Flags = PD_PRINTSETUP | PD_PAGENUMS;
	if (d->NeedsDC)
		d->Info.Flags |= PD_RETURNDC;
	/*
	if (d->Pages > 1)
	{
		d->Info.nMinPage = 1;
		d->Info.nMaxPage = d->Pages;
	}
	*/

	return PrintDlg(&d->Info);
}
Exemplo n.º 27
0
void wPrintSetup( wPrintSetupCallBack_p callback )
{
	if (!printInit()) {
		return;
	}
	/*memset( &printDlg, 0, sizeof printDlg );*/
	printDlg.lStructSize = sizeof printDlg;
	printDlg.hwndOwner = NULL;
	printDlg.Flags = PD_RETURNDC|PD_PRINTSETUP;
	if (PrintDlg(&printDlg) != 0  && printDlg.hDC) {
		getPageDim( printDlg.hDC );
	}
	if ( callback ) {
		callback( TRUE );
	}
}
Exemplo n.º 28
0
HDC GetDefaultPrinterDC()
{
	PRINTDLG pdlg	= { sizeof(pdlg),  0, 0, 0 };
	pdlg.Flags		= PD_RETURNDC|PD_RETURNDEFAULT;
	
	if(PrintDlg(&pdlg))
	{
		g_hDevMode		= pdlg.hDevMode;
		g_hDevNames		= pdlg.hDevNames;

		return pdlg.hDC;
	}
	else
	{
		return NULL;
	}
}
Exemplo n.º 29
0
void BeginPrinter(){
  PRINTDLG pd;
  ZeroMemory(&pd,sizeof(PRINTDLG));
  pd.lStructSize = sizeof(PRINTDLG);
  pd.hwndOwner = NULL;

  pd.hDevMode = NULL;
  pd.hDevNames = NULL;
  pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC | PD_RETURNDEFAULT;
  pd.nCopies = 1;

  if(PrintDlg(&pd)){
    hDevMode = pd.hDevMode;
    hDevNames = pd.hDevNames;
    hPrintDC = pd.hDC;
  }
}
Exemplo n.º 30
0
void Demo_WritePrinter(void)
{
	PRINTDLG  pd;

	memset(&pd, 0, sizeof(PRINTDLG));
	pd.lStructSize = sizeof(PRINTDLG);

	if ( PrintDlg(&pd)==IDOK )
	{
		HANDLE hPrinter;

		DEVMODE * pDevMode = (DEVMODE *) GlobalLock(pd.hDevMode);

		PRINTER_DEFAULTS prn;
		prn.pDatatype     = "NT EMF 1.008";
		prn.pDevMode      = pDevMode;
		prn.DesiredAccess = PRINTER_ACCESS_USE;

		if ( OpenPrinter((char *) pDevMode->dmDeviceName, & hPrinter, & prn) )
		{
			KFileDialog fd;

			if ( fd.GetOpenFileName(NULL, "spl", "Windows 2000 EMF Spool file") )
			{
				DOC_INFO_1 docinfo;

				docinfo.pDocName    = "Testing WritePrinter";
				docinfo.pOutputFile = NULL;
				docinfo.pDatatype   = "NT EMF 1.008";

				StartDocPrinter(hPrinter, 1, (BYTE *) & docinfo);
				StartPagePrinter(hPrinter);
				
				SendFile(hPrinter, fd.m_TitleName, true);
				
				EndPagePrinter(hPrinter);
				EndDocPrinter(hPrinter);
			}

			ClosePrinter(hPrinter);
		}

		if ( pd.hDevMode )	GlobalFree(pd.hDevMode);
		if ( pd.hDevNames ) GlobalFree(pd.hDevNames);
	}
}