GetDeviceCaps Technology

General Tech Technology & Software 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Technology & Software related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago


I have a control and I want to paint it different way in Form and when printting. Here the way I did it:

private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    {
        Rectangle rect = myControl.ClientRectangle;
        myControl.Render(e.Graphics, rect);
        e.HasMorePages = false;
    }

and in Render function

public void Render(Graphics g, Rectangle rect) {
      DeviceCapTechnology dct = (DeviceCapTechnology)GetDeviceCaps(hDC, (int)DeviceCap.TECHNOLOGY);
      if((dct & DeviceCapTechnoloy.DT_RASPRINTER) == DeviceCapTechnoloy.DT_RASPRINTER) {
           //logic for print to printer
      } else {
           //normal logic
      }
}
public enum DeviceCapTechnology
    {
        DT_PLOTTER = 0, //Vector plotter
        DT_RASDISPLAY = 2, //Raster display
        DT_RASPRINTER = 4, //Raster printer
        DT_RASCAMERA = 6, //Raster camera
        DT_CHARSTREAM = 8, //Character stream
        DT_METAFILE = 10, //Metafile
        DT_DISPFILE = 12 //Display file
    }

But when the PrintDocumentDialog show, the result of the test always is DT_RASDISPLAY not what I expected to be DT_RASPRINTER.

So what is the right way to do it?

Thank you

profilepic.png
manpreet 2 years ago

Your DeviceCapTechnology enumeration is wrong

/* Device Technologies */
#define DT_PLOTTER          0   /* Vector plotter                   */
#define DT_RASDISPLAY       1   /* Raster display                   */
#define DT_RASPRINTER       2   /* Raster printer                   */
#define DT_RASCAMERA        3   /* Raster camera                    */
#define DT_CHARSTREAM       4   /* Character-stream, PLP            */
#define DT_METAFILE         5   /* Metafile, VDM                    */
#define DT_DISPFILE         6   /* Display-file                     */

0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.