Solved

How do I create CDC object from from scratch?

Posted on 2002-06-28
4
494 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Title # Comments Views Activity
Generic progress indicator 6 119
either24  challenge 19 105
Change to event 1 129
Bartender label printing - switch on and off graphics 3 75
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.

726 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