Click here to Skip to main content
15,122,728 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: problem with sprintf_s() on win 7 Pin
Member 935377613-Nov-12 23:48
MemberMember 935377613-Nov-12 23:48 
Questionhow to get motherboard SN Pin
buffay1-Nov-12 20:42
Memberbuffay1-Nov-12 20:42 
AnswerRe: how to get motherboard SN Pin
Richard MacCutchan2-Nov-12 1:37
mveRichard MacCutchan2-Nov-12 1:37 
QuestionChart Control Pin
Tom Paronis1-Nov-12 7:04
MemberTom Paronis1-Nov-12 7:04 
AnswerRe: Chart Control Pin
Richard MacCutchan1-Nov-12 7:48
mveRichard MacCutchan1-Nov-12 7:48 
GeneralRe: Chart Control Pin
Tom Paronis1-Nov-12 8:34
MemberTom Paronis1-Nov-12 8:34 
QuestionCopy CDC Pin
_Flaviu31-Oct-12 23:29
Member_Flaviu31-Oct-12 23:29 
AnswerRe: Copy CDC Pin
Santhosh G_1-Nov-12 2:38
MemberSanthosh G_1-Nov-12 2:38 
C++
    CSize sizeDoc = pDoc->GetBitmapSize();
CDC MemDC, TempDC;
MemDC.CreateCompatibleDC(pDC);
TempDC.CreateCompatibleDC(pDC);
CBitmap* pOldBitmap = MemDC.SelectObject(&pDoc->GetBitmap());
pDC->SetStretchBltMode(HALFTONE);
TempDC.StretchBlt(0, 0, sizeLog.cx, sizeLog.cy, &MemDC, 0, 0, sizeDoc.cx, sizeDoc.cy, SRCCOPY);
pDC->StretchBlt(0, 0, sizeLog.cx, sizeLog.cy, &TempDC, 0, 0, sizeDoc.cx, sizeDoc.cy, SRCCOPY);
pDC->SelectObject(pOldBitmap);


When a memory device context is created, GDI automatically selects a 1-by-1 monochrome stock bitmap for it. GDI output functions can be used with a memory device context only if a bitmap has been created and selected into that context.

Here TempDC is not attached to any Bitmap, and therefore GDI function StretchBlt will not draw to TempDC.
You have to create a Bitmap compatible to your DC, and attach the same to temperory memory DC.
C++
    CSize sizeDoc = pDoc->GetBitmapSize();
CDC MemDC, TempDC;
MemDC.CreateCompatibleDC(pDC);
TempDC.CreateCompatibleDC(pDC);
CBitmap* pOldBitmap = MemDC.SelectObject(&pDoc->GetBitmap());
pDC->SetStretchBltMode(HALFTONE);

    // Creating Bitmap for Memory DC.
    HDC hdc = ::GetDC(NULL);
    HBITMAP hScreenBmp = CreateCompatibleBitmap( hdc , nWidth, m_nImageHeight );

    // Attach temporary bitmap with DC.
    TempDC.SelectObject( hScreenBmp );

    // Draw bitmap to Temporary MemDC.
TempDC.StretchBlt(0, 0, sizeLog.cx, sizeLog.cy, &MemDC, 0, 0, sizeDoc.cx, sizeDoc.cy, SRCCOPY);
pDC->StretchBlt(0, 0, sizeLog.cx, sizeLog.cy, &TempDC, 0, 0, sizeDoc.cx, sizeDoc.cy, SRCCOPY);
pDC->SelectObject(pOldBitmap);

GeneralRe: Copy CDC Pin
_Flaviu1-Nov-12 3:20
Member_Flaviu1-Nov-12 3:20 
QuestionStrange memory leak Pin
miniman0631-Oct-12 22:58
Memberminiman0631-Oct-12 22:58 
AnswerRe: Strange memory leak Pin
Sivaraman Dhamodharan31-Oct-12 23:45
MemberSivaraman Dhamodharan31-Oct-12 23:45 
GeneralRe: Strange memory leak Pin
miniman061-Nov-12 0:10
Memberminiman061-Nov-12 0:10 
AnswerRe: Strange memory leak Pin
Rolf Kristensen31-Oct-12 23:47
MemberRolf Kristensen31-Oct-12 23:47 
GeneralRe: Strange memory leak Pin
miniman061-Nov-12 0:11
Memberminiman061-Nov-12 0:11 
AnswerRe: Strange memory leak Pin
Santhosh G_1-Nov-12 0:22
MemberSanthosh G_1-Nov-12 0:22 
GeneralRe: Strange memory leak Pin
miniman061-Nov-12 0:31
Memberminiman061-Nov-12 0:31 
AnswerRe: Strange memory leak Pin
Jochen Arndt1-Nov-12 0:35
professionalJochen Arndt1-Nov-12 0:35 
GeneralRe: Strange memory leak Pin
miniman061-Nov-12 1:09
Memberminiman061-Nov-12 1:09 
GeneralRe: Strange memory leak Pin
Jochen Arndt1-Nov-12 1:29
professionalJochen Arndt1-Nov-12 1:29 
AnswerRe: Strange memory leak Pin
BCN-1631-Nov-12 17:01
MemberBCN-1631-Nov-12 17:01 
Questionabout accessing PDF file, compile error. Pin
BCN-16331-Oct-12 16:18
MemberBCN-16331-Oct-12 16:18 
AnswerRe: about accessing PDF file, compile error. Pin
Richard MacCutchan1-Nov-12 0:41
mveRichard MacCutchan1-Nov-12 0:41 
GeneralRe: about accessing PDF file, compile error. Pin
BCN-1631-Nov-12 16:56
MemberBCN-1631-Nov-12 16:56 
GeneralRe: about accessing PDF file, compile error. Pin
Richard MacCutchan1-Nov-12 23:35
mveRichard MacCutchan1-Nov-12 23:35 
GeneralRe: about accessing PDF file, compile error. Pin
BCN-1634-Nov-12 14:39
MemberBCN-1634-Nov-12 14:39 

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.