Click here to Skip to main content
16,008,010 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: declare/access variables programmatically Pin
Jon Hulatt13-Mar-02 6:54
Jon Hulatt13-Mar-02 6:54 
GeneralFree space available in a drive . Pin
Neha13-Mar-02 2:39
Neha13-Mar-02 2:39 
GeneralRe: Free space available in a drive . Pin
Jon Hulatt13-Mar-02 2:48
Jon Hulatt13-Mar-02 2:48 
GeneralRe: Free space available in a drive . Pin
RalfPeter13-Mar-02 3:19
RalfPeter13-Mar-02 3:19 
GeneralRe: Free space available in a drive . Pin
lucy13-Mar-02 8:49
lucy13-Mar-02 8:49 
GeneralI can't change the font color by CDC Pin
Feng Qin13-Mar-02 2:31
Feng Qin13-Mar-02 2:31 
GeneralRe: I can't change the font color by CDC Pin
Tomasz Sowinski13-Mar-02 2:32
Tomasz Sowinski13-Mar-02 2:32 
GeneralRe: I can't change the font color by CDC Pin
Roger Allen13-Mar-02 5:42
Roger Allen13-Mar-02 5:42 
Aprt from what Tomas said, you should also be calling SaveDC() and RestoreDC(-1) on your cacheDC object. Although you select back in the original font/bitmap, you shold also restore the original text colour.

DC's should always be returned to the system in the exact state you got them. Thats why SaveDC() / RestoreDC() is so good for you in this situation.

CDC* pDC = GetDC();
CDC cacheDC;
cacheDC.CreateCompatibleDC( pDC );
if( m_pBitmap == NULL )
{
m_pBitmap = new CBitmap;
m_pBitmap->CreateCompatibleBitmap( &cacheDC, m_ClientRect.Width(), m_ClientRect.Height() );
}
caccheDC.SaveDC() ;
cacheDC.SelectObject( m_pBitmap );

cacheDC->SetTextColor( RGB(0, 0, 255 ) ); //color blue
cacheDC->TextOut( "hello world" );

pDC->BitBlt( m_ClientRect.left, 
m_ClientRect.top,
m_ClientRect.Width(),
m_ClientRect.Height(),
&cacheDC, 0, 0, SRCCOPY );

cacheDC.RestoreDC(-1) ;
cacheDC.DeleteDC();



Roger Allen
Sonork 100.10016

If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
GeneralProgramming on multiprocessor computer Pin
Dang Xuan Ky13-Mar-02 0:45
Dang Xuan Ky13-Mar-02 0:45 
GeneralRe: Programming on multiprocessor computer Pin
Tomasz Sowinski13-Mar-02 1:03
Tomasz Sowinski13-Mar-02 1:03 
GeneralRe: Programming on multiprocessor computer Pin
Jon Hulatt13-Mar-02 1:41
Jon Hulatt13-Mar-02 1:41 
GeneralRe: Programming on multiprocessor computer Pin
Tim Smith13-Mar-02 2:01
Tim Smith13-Mar-02 2:01 
GeneralRe: Programming on multiprocessor computer Pin
Tomasz Sowinski13-Mar-02 2:21
Tomasz Sowinski13-Mar-02 2:21 
GeneralRe: Programming on multiprocessor computer Pin
Jon Hulatt13-Mar-02 2:45
Jon Hulatt13-Mar-02 2:45 
GeneralRe: Programming on multiprocessor computer Pin
Tomasz Sowinski13-Mar-02 2:42
Tomasz Sowinski13-Mar-02 2:42 
GeneralRe: Programming on multiprocessor computer Pin
Dang Xuan Ky14-Mar-02 5:35
Dang Xuan Ky14-Mar-02 5:35 
GeneralRe: Programming on multiprocessor computer Pin
Tomasz Sowinski14-Mar-02 5:50
Tomasz Sowinski14-Mar-02 5:50 
QuestionHow to get network card serial number? Pin
Ales Krajnc13-Mar-02 0:15
Ales Krajnc13-Mar-02 0:15 
AnswerRe: How to get network card serial number? Pin
Jon Hulatt13-Mar-02 1:45
Jon Hulatt13-Mar-02 1:45 
AnswerSendARP Pin
13-Mar-02 4:49
suss13-Mar-02 4:49 
GeneralEnumerate handles Pin
Don Miguel13-Mar-02 0:05
Don Miguel13-Mar-02 0:05 
GeneralRe: Enumerate handles Pin
Stephen Kellett13-Mar-02 8:02
Stephen Kellett13-Mar-02 8:02 
GeneralRe: Enumerate handles Pin
Carlos Antollini13-Mar-02 8:26
Carlos Antollini13-Mar-02 8:26 
GeneralRe: Enumerate handles Pin
Don Miguel13-Mar-02 21:00
Don Miguel13-Mar-02 21:00 
GeneralRemoving application icon from alt+tab list Pin
KGS12-Mar-02 22:53
KGS12-Mar-02 22:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.