当前位置: 首页>>代码示例>>C++>>正文


C++ PrintDlg函数代码示例

本文整理汇总了C++中PrintDlg函数的典型用法代码示例。如果您正苦于以下问题:C++ PrintDlg函数的具体用法?C++ PrintDlg怎么用?C++ PrintDlg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PrintDlg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fl_gdi_printer_chooser

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;
}
开发者ID:GustavoMOG,项目名称:efltk,代码行数:52,代码来源:Fl_Gdi.cpp

示例2: test_PrintDlgExW

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;

}
开发者ID:devyn,项目名称:wine,代码行数:51,代码来源:printdlg.c

示例3: StartTextPrnt

/*****************************************************************************
 * 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 );
}
开发者ID:ErisBlastar,项目名称:osfree,代码行数:31,代码来源:print.c

示例4: get_printer_dc

/* 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;
}
开发者ID:jelmer,项目名称:wireshark,代码行数:61,代码来源:print_win32.c

示例5: ConvertToNative

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;
    }
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:29,代码来源:printdlg.cpp

示例6: ZeroMemory

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;
}
开发者ID:neurodebian,项目名称:iv-hines,代码行数:34,代码来源:mprinter.cpp

示例7: GetDC

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;
}
开发者ID:ndilday,项目名称:virtualu,代码行数:31,代码来源:Oprint2.cpp

示例8: DeleteGlobals

void Printer::GetDefault()
{
	DeleteGlobals();
	pd.Flags = PD_RETURNDEFAULT;
	PrintDlg(&pd);
	// pd now has hDevMode and hDevNames set
}
开发者ID:DavidKinder,项目名称:Level9,代码行数:7,代码来源:printer.cpp

示例9: while

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;
}
开发者ID:DavidKinder,项目名称:Level9,代码行数:27,代码来源:printer.cpp

示例10: Print

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);
}
开发者ID:LisP94,项目名称:OSiSP,代码行数:25,代码来源:OSiSP1.cpp

示例11: sizeof

// 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();
}
开发者ID:AaronDP,项目名称:wxWidgets,代码行数:60,代码来源:dcprint.cpp

示例12: main

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;
}
开发者ID:anshus012,项目名称:binutils,代码行数:59,代码来源:prntest.c

示例13: SelPrinter

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);
  }
}
开发者ID:pjmtdw,项目名称:kazesomiso,代码行数:59,代码来源:myprint_proc.cpp

示例14: PrintBox

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;
}
开发者ID:Fliper12,项目名称:darkbasicpro,代码行数:58,代码来源:GUIDialogs.cpp

示例15: Printer_getDC

	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;
	}
开发者ID:alekstorm,项目名称:tala,代码行数:9,代码来源:Printer.cpp


注:本文中的PrintDlg函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。