Thread: Device Context

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    184

    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

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    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.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    184
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Device & Rendering Context
    By hannibar in forum Windows Programming
    Replies: 1
    Last Post: 12-16-2005, 05:28 AM
  2. Clearing the Windows Device Context
    By loopshot in forum Game Programming
    Replies: 8
    Last Post: 11-17-2005, 10:51 AM
  3. Device context woes
    By samGwilliam in forum Windows Programming
    Replies: 13
    Last Post: 04-16-2005, 10:01 PM
  4. Other Routines For Setting a pixel onto a Device context
    By MicroFiend in forum Game Programming
    Replies: 21
    Last Post: 07-16-2004, 08:09 AM
  5. Replies: 4
    Last Post: 06-30-2004, 03:11 PM