?
Solved

How do I create CDC object from from scratch?

Posted on 2002-06-28
4
Medium Priority
?
517 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
2 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

850 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