sending data to printer
-
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 }
-
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 }
-
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 }
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!