Solved

Printing Problem

Posted on 2003-10-22
3
190 Views
Last Modified: 2013-11-20
How Do I set the default Printer setting to B&W for a color printer without using the default property dialog box?
0
Comment
Question by:rpatna
3 Comments
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
See sample code in MSDN topic CWinApp::GetPrinterDeviceDefaults .

void CMyApp::SetMonochrome()
{
   PRINTDLG pd;
   pd.lStructSize=(DWORD)sizeof(PRINTDLG);
   BOOL bRet=GetPrinterDeviceDefaults(&pd);
   if(bRet)
   {
      // protect memory handle with ::GlobalLock and ::GlobalUnlock
      DEVMODE FAR *pDevMode=(DEVMODE FAR *)::GlobalLock(m_hDevMode);
      // set monochrome mode
      pDevMode->dmColor=DMCOLOR_MONOCHROME;
      ::GlobalUnlock(m_hDevMode);
   }
}

0
 

Author Comment

by:rpatna
Comment Utility
The problem was to get a B&W printout of a color image(bitmap). The solution given may not be apropriate for this particular problem as it didnot worked in my case.
0
 

Accepted Solution

by:
ashokRaut earned 50 total points
Comment Utility
Try this:

HBITMAP hMonocrome = CreateBitMap( ( WORD )lpbi->biWidth, ( WORD )lpbi->biHeight, 1, 1, NULL) ;  

SetDIBits( hDC, hMonocrome, 0, lpbi->Height, (LPSTR)lpbi + lpbi->biSize + nColors *size0f(RGBQUAD) , (LPBITMAPINFO)lpbi, IB_RGB_COLORS ) ;


REFER TO: MNDN Topic Bit2Mono.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now