Solved

How do I create CDC object from from scratch?

Posted on 2002-06-28
4
470 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
4 Comments
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 200 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

867 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now