Creating a CWnd Class for Printing, Not Viewing

Creating a CWnd Class for Printing, Not Viewing

Question:
After significant development time, a wonderful class derived from CWnd was created by our team to pull together text, graphics, etc. in a Paintbrush type of application. Now, we’d like to be able to print the created bitmap. This was fairly simple to implement. However, the wrinkle now is that we must be able to print these images without displaying them. The information regarding what to place, and where, is stored in a database. We don’t want to have to display the CWnd, but crank through several CRecordsets, and build the images, and print them.

What is the best way to accomplish this? Can you create a CWnd without displaying it? Can the DC be changed from painting to printing?

Answer:
It’s easy to create a CWnd without displaying it. Just keep it hidden. However, CWnd is probably not the class I would choose to derive from if I was not showing anything on screen.

Still, I might if I had to send messages to it or if I was trying to convert existing code as you are.

I can’t offer much help here except to say that you can change the DC from a window DC to a printer DC and most of the code that accesses the DC will continue to work. There are some differences with printing, however, such as keeping track of multiple pages and so on. For these differences, you will most likely need to make some changes to your code.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes