Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. sending data to printer

sending data to printer

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++question
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vgkotha
    wrote on last edited by
    #1

    hi i am writng my own printsetup dailog box in mfc. i selected all properties and when i give print the printer is not signaling . i am providing my code below please correct where the mistake. if my code is wrong please give guidence how can i send data to printer. my intention is not displaying windows printdialog box. what are the functionality we did on printdialog we can carry on our dialogbox. It's urgent. please help thank you void CMyPrintSetup::OnButPrint() { // TODO: Add your control notification handler code here unsigned char temp[32]; DEVMODE *devout,*devin; DWORD dwNeeded,dwRet; DEVMODE* pDevMode; /**********************getting printer handle**********************/ if(!OpenPrinter(printername,&hprinter,NULL)) //for getting handle for printer MessageBox("Printer can't be opened","emazines",MB_OK); /*******get the size of the buffer for specified printer****************/ dwNeeded=DocumentProperties(NULL,hprinter,printername,NULL,NULL,0); pDevMode=(DEVMODE*)malloc(dwNeeded); /**get the default DEVMODE for the printer and modify if your needs*********/ dwRet=DocumentProperties (NULL,hprinter,printername,pDevMode,NULL,DM_OUT_BUFFER); if (dwRet != IDOK) { /* If failure, cleanup and return failure. */ free(pDevMode); ClosePrinter(hprinter); } pDevMode->dmOrientation=m_orientation; pDevMode->dmCopies=m_copies; /***********set the new values to printer****************/ dwRet=DocumentProperties (NULL,hprinter,printername,pDevMode,pDevMode,DM_IN_BUFFER|DM_OUT_BUFFER); if(dwRet!=IDOK) { MessageBox("properties initialization error","emazines",MB_OK); } /*********************** code for printing *************************/ CDC dc; //creating a DC object AfxMessageBox(printername); HDC hdc=CreateDC(NULL,printername,NULL,NULL); dc.Attach(hdc); dc.Rectangle(100,100,200,200); dc.TextOut(50,50,"Emazines Software Private Limited"); dc.DeleteDC(); /*********************End of the code for printing*********************/ CDialog::OnOK();//for closing window }

    K R 2 Replies Last reply
    0
    • V vgkotha

      hi i am writng my own printsetup dailog box in mfc. i selected all properties and when i give print the printer is not signaling . i am providing my code below please correct where the mistake. if my code is wrong please give guidence how can i send data to printer. my intention is not displaying windows printdialog box. what are the functionality we did on printdialog we can carry on our dialogbox. It's urgent. please help thank you void CMyPrintSetup::OnButPrint() { // TODO: Add your control notification handler code here unsigned char temp[32]; DEVMODE *devout,*devin; DWORD dwNeeded,dwRet; DEVMODE* pDevMode; /**********************getting printer handle**********************/ if(!OpenPrinter(printername,&hprinter,NULL)) //for getting handle for printer MessageBox("Printer can't be opened","emazines",MB_OK); /*******get the size of the buffer for specified printer****************/ dwNeeded=DocumentProperties(NULL,hprinter,printername,NULL,NULL,0); pDevMode=(DEVMODE*)malloc(dwNeeded); /**get the default DEVMODE for the printer and modify if your needs*********/ dwRet=DocumentProperties (NULL,hprinter,printername,pDevMode,NULL,DM_OUT_BUFFER); if (dwRet != IDOK) { /* If failure, cleanup and return failure. */ free(pDevMode); ClosePrinter(hprinter); } pDevMode->dmOrientation=m_orientation; pDevMode->dmCopies=m_copies; /***********set the new values to printer****************/ dwRet=DocumentProperties (NULL,hprinter,printername,pDevMode,pDevMode,DM_IN_BUFFER|DM_OUT_BUFFER); if(dwRet!=IDOK) { MessageBox("properties initialization error","emazines",MB_OK); } /*********************** code for printing *************************/ CDC dc; //creating a DC object AfxMessageBox(printername); HDC hdc=CreateDC(NULL,printername,NULL,NULL); dc.Attach(hdc); dc.Rectangle(100,100,200,200); dc.TextOut(50,50,"Emazines Software Private Limited"); dc.DeleteDC(); /*********************End of the code for printing*********************/ CDialog::OnOK();//for closing window }

      K Offline
      K Offline
      KarstenK
      wrote on last edited by
      #2

      Use: dc.Startpage(); //print stuff dc.EndPage();

      1 Reply Last reply
      0
      • V vgkotha

        hi i am writng my own printsetup dailog box in mfc. i selected all properties and when i give print the printer is not signaling . i am providing my code below please correct where the mistake. if my code is wrong please give guidence how can i send data to printer. my intention is not displaying windows printdialog box. what are the functionality we did on printdialog we can carry on our dialogbox. It's urgent. please help thank you void CMyPrintSetup::OnButPrint() { // TODO: Add your control notification handler code here unsigned char temp[32]; DEVMODE *devout,*devin; DWORD dwNeeded,dwRet; DEVMODE* pDevMode; /**********************getting printer handle**********************/ if(!OpenPrinter(printername,&hprinter,NULL)) //for getting handle for printer MessageBox("Printer can't be opened","emazines",MB_OK); /*******get the size of the buffer for specified printer****************/ dwNeeded=DocumentProperties(NULL,hprinter,printername,NULL,NULL,0); pDevMode=(DEVMODE*)malloc(dwNeeded); /**get the default DEVMODE for the printer and modify if your needs*********/ dwRet=DocumentProperties (NULL,hprinter,printername,pDevMode,NULL,DM_OUT_BUFFER); if (dwRet != IDOK) { /* If failure, cleanup and return failure. */ free(pDevMode); ClosePrinter(hprinter); } pDevMode->dmOrientation=m_orientation; pDevMode->dmCopies=m_copies; /***********set the new values to printer****************/ dwRet=DocumentProperties (NULL,hprinter,printername,pDevMode,pDevMode,DM_IN_BUFFER|DM_OUT_BUFFER); if(dwRet!=IDOK) { MessageBox("properties initialization error","emazines",MB_OK); } /*********************** code for printing *************************/ CDC dc; //creating a DC object AfxMessageBox(printername); HDC hdc=CreateDC(NULL,printername,NULL,NULL); dc.Attach(hdc); dc.Rectangle(100,100,200,200); dc.TextOut(50,50,"Emazines Software Private Limited"); dc.DeleteDC(); /*********************End of the code for printing*********************/ CDialog::OnOK();//for closing window }

        R Offline
        R Offline
        Roger Allen
        wrote on last edited by
        #3

        CDC dc; //creating a DC object AfxMessageBox(printername); HDC hdc=CreateDC(NULL,printername,NULL,NULL); dc.Attach(hdc); dc.StartDoc(); dc.StartPage(); dc.Rectangle(100,100,200,200); dc.TextOut(50,50,"Emazines Software Private Limited"); dc.EndPage(); dc.EndDoc(); dc.DeleteDC(); Roger Allen Sonork 100.10016 I have a terminal disease. Its called life!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups