-
Device Context
Hello everyone,
Quick question. Does anyone know how to use a device context in an if statement? Like the following....
if(pDC == Printer){}
else if(pDC == Monitor){}
I believe that that would be the syntax, but how would I know the value to compare it to for Printer or Monitor. Is there any value that can be compared to a Device Context?
Thanks,
Kendal
-
AFAIK you can compare the handle to a DC's memory addresses like that, but not the 'contents' ie the GDI resorces used (BMP, pen brush) making it less than useful.
Whole screen DC (relative to your app can be got with GetDC(NULL) )
Printer can be found with
hdcPrinter=CreateDC (NULL,sPrinterName,NULL, DevMode) ;
Where the sPrinterName and DevMode are returned from the common 'open print' dialog (and sPrinterName
has been checked for trunction usually with a call to EnumPrinters() depending on the version of MS OS running)
Prahaps if you explained WHAT you want to do we could help more.
-
What it was is that I am using an image viewer program that will display image files (.bmp, .jpg, .gif) and allows the user to increase and decrease the size on the screen for better readability. When I added the print functionality, the printout would be very small, even if the view was at 100%. The view kept getting set small in the OnDraw function, so I used a global bool to indicate when printing and called a function that would adjust the image sizes to the sized of the printer pages. I was able to get that working, but now I have the problem with print preview. That problem is posted on the other thread...here I am sure there are better and more efficient ways to get the program to do what I want it to do, that was just the quickest way I could figure. I will include the code as an attachment on the other thread for that problem if anyone would like to see it.
Thanks again,
Kendal