?
Solved

How do I create CDC object from from scratch?

Posted on 2002-06-28
4
Medium Priority
?
510 Views
Last Modified: 2013-11-20
Friends,

Please help me for creating a CDC object as follows.

I have a DrawGraphic(CDC* pDC) method in DLL, In which iam loading this one in a background process( executes sometimes before user logges in).
Can I build CDC object with my own values and passed to this function. This is works when I pass a compatible dc or printer dc or if create a dc like this
     CDC dispDC;
     dispDC.CreateDC("DISPLAY", NULL, NULL, NULL);

but for some reason this doesnt work when iam in back ground mode. Friends please help me how to build a CDC object with all necessary values....

Thanks in advance
Hari
0
Comment
Question by:pphari
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 800 total points
ID: 7117964
CDC dispDC;
CDC *pDC = GetDC();     // get screen dc
dispDC.CreateCompatibleDC(pDC); // make this dc compatible with screen dc
// selecting object of current screen dc to our dc
HBITMAP hBMP = CreateCompatibleBitmap(pDC->m_hDC, nWidth, nHeight);
::SelectObject(dispDC.m_hDC, hBMP);


GOOD LUCK
0
 
LVL 8

Expert Comment

by:fl0yd
ID: 7118658
I'm not quite sure what your problem is. You are talking about users not being logged in. But what does the user have to do with your DrawGraphic()-function? I'd recommend passing a NULL-pointer to your DrawGraphic()-function if no user is logged in and you need to rely on that. I really can't imagine what you are trying to achieve, so please, give us some more information.
Btw. you should look into what a device context is. It allows homogenous access to display devices but needs to be properly initialized so that the actual painting (which is hidden from the developer) can be performed in an appropriate manner.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

762 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