Solved

How do I create CDC object from from scratch?

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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…
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 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

17 Experts available now in Live!

Get 1:1 Help Now