Click here to Skip to main content
15,900,589 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Peer-to-Peer with Windows-Sockets Pin
18-May-01 6:50
suss18-May-01 6:50 
Generalcapture a rectangle in a static image and resize it in another window Pin
Frederico Levesque18-May-01 4:44
Frederico Levesque18-May-01 4:44 
GeneralRe: capture a rectangle in a static image and resize it in another window Pin
18-May-01 5:08
suss18-May-01 5:08 
GeneralClasses, new, delete, destructors Pin
José Luis Sogorb18-May-01 4:41
José Luis Sogorb18-May-01 4:41 
GeneralRe: Classes, new, delete, destructors Pin
James R. Twine18-May-01 4:50
James R. Twine18-May-01 4:50 
GeneralRe: Classes, new, delete, destructors Pin
José Luis Sogorb18-May-01 5:16
José Luis Sogorb18-May-01 5:16 
GeneralRe: Classes, new, delete, destructors Pin
James R. Twine18-May-01 8:32
James R. Twine18-May-01 8:32 
GeneralRe: Classes, new, delete, destructors Pin
José Luis Sogorb18-May-01 9:40
José Luis Sogorb18-May-01 9:40 
Well, I took the idea from a Microsoft Visual C++ example (In the offical book):

void CMyDrawView::SetPenBrush(CDC *pDC, bool bTransparent, UINT nColor)
{
ASSERT(pDC != NULL);
if(bTransparent)
{
m_pBrushOld = (CBrush*)pDC->SelectStockObject(NULL_BRUSH);
}
else
{
m_pBrushOld = (CBrush*)pDC->SelectStockObject(WHITE_BRUSH);
}
ASSERT(m_pBrushOld != NULL);

ASSERT(nColor - ID_COLOR_BLACK >= 0 &&
nColor - ID_COLOR_BLACK <=
(sizeof(arColors) / sizeof(arColors[0])));
m_pPenNew = new CPen(); //------->> here

m_pPenNew->CreatePen(PS_INSIDEFRAME, 0,
arColors[nColor - ID_COLOR_BLACK]);
m_pPenOld = (CPen*)pDC->SelectObject(m_pPenNew);
}

void CMyDrawView::ResetPenBrush(CDC *pDC)
{
ASSERT(pDC != NULL);
pDC->SelectObject(m_pBrushOld);
pDC->SelectObject(m_pPenOld);

delete m_pPenNew; //--------->>>>> here
m_pPenNew = NULL;
m_pPenOld = NULL;
m_pBrushOld = NULL;
}

Which is the solution then?
GeneralRe: Classes, new, delete, destructors Pin
James R. Twine18-May-01 10:14
James R. Twine18-May-01 10:14 
GeneralRe: Classes, new, delete, destructors Pin
José Luis Sogorb18-May-01 23:22
José Luis Sogorb18-May-01 23:22 
GeneralRe: Classes, new, delete, destructors Pin
James R. Twine19-May-01 2:16
James R. Twine19-May-01 2:16 
GeneralMailslot Problem Pin
18-May-01 4:27
suss18-May-01 4:27 
GeneralGeneral Question Pin
mr200318-May-01 4:11
mr200318-May-01 4:11 
GeneralRe: General Question Pin
Stan Shannon18-May-01 9:45
Stan Shannon18-May-01 9:45 
GeneralMemory Mapped Files and Security under IIS 5.0 / Win2K... Pin
James R. Twine18-May-01 3:15
James R. Twine18-May-01 3:15 
GeneralDrag and Drop Pin
Eran18-May-01 2:55
Eran18-May-01 2:55 
GeneralRe: Drag and Drop Pin
Tomasz Sowinski18-May-01 3:06
Tomasz Sowinski18-May-01 3:06 
GeneralTCP/IP Socket programming Pin
Gerry18-May-01 2:03
Gerry18-May-01 2:03 
GeneralRe: TCP/IP Socket programming Pin
18-May-01 2:29
suss18-May-01 2:29 
GeneralRe: TCP/IP Socket programming Pin
Gerry18-May-01 2:45
Gerry18-May-01 2:45 
GeneralRe: TCP/IP Socket programming Pin
markkuk20-May-01 21:06
markkuk20-May-01 21:06 
QuestionCPrintDialog::GetDefaults() doesn't work? Pin
Joep18-May-01 1:31
Joep18-May-01 1:31 
AnswerRe: CPrintDialog::GetDefaults() doesn't work? Pin
Gerry18-May-01 3:21
Gerry18-May-01 3:21 
GeneralUnsing STL in cunjunction with MFC Pin
18-May-01 1:19
suss18-May-01 1:19 
GeneralRe: Unsing STL in cunjunction with MFC Pin
James R. Twine18-May-01 2:57
James R. Twine18-May-01 2:57 

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.