EDN Admin
Well-known member
Hi all,
I have created an application which displays the 1 , 4 ,8 ,24 bpp by using the setpixel method . Now i have decided to add the copy , paste feature to the application for which i have wriitten the following code.
void CBmpInfoView::OnLButtonDown(UINT nFlags, CPoint point)<br/>
{<br/>
CBmpInfoDoc* pDoc = GetDocument();
if (m_Tracker.HitTest(point) < 0){
m_Tracker.TrackRubberBand(this , point , TRUE);
}else if (m_Tracker.Track(this, point, TRUE)){<br/>
<br/>
}
pDoc->SetModifiedFlag();<br/>
pDoc->UpdateAllViews(NULL);
CScrollView::OnLButtonDown(nFlags , point);<br/>
}
void CBmpInfoView::OnEditCopy()<br/>
{<br/>
CClientDC dc(this);<br/>
CDC memDC;<br/>
CBitmap bitmap;
m_Tracker.GetTrueRect(m_rectSave);
memDC.CreateCompatibleDC(&dc);<br/>
bitmap.CreateCompatibleBitmap(&dc, m_rectSave.Width(), m_rectSave.Height());<br/>
CBitmap* pOldBitmap = memDC.SelectObject(&bitmap);
OnPrepareDC(&memDC);<br/>
OnDraw(&memDC);
OpenClipboard();<br/>
EmptyClipboard();<br/>
SetClipboardData(CF_BITMAP, bitmap.GetSafeHandle());<br/>
CloseClipboard();
// Clean up<br/>
memDC.SelectObject(pOldBitmap);<br/>
bitmap.Detach();<br/>
}
Above given code displays the image from the 0 , 0 position and displays it in black color . Could you please help me out from this.
ThankYou
View the full article
I have created an application which displays the 1 , 4 ,8 ,24 bpp by using the setpixel method . Now i have decided to add the copy , paste feature to the application for which i have wriitten the following code.
void CBmpInfoView::OnLButtonDown(UINT nFlags, CPoint point)<br/>
{<br/>
CBmpInfoDoc* pDoc = GetDocument();
if (m_Tracker.HitTest(point) < 0){
m_Tracker.TrackRubberBand(this , point , TRUE);
}else if (m_Tracker.Track(this, point, TRUE)){<br/>
<br/>
}
pDoc->SetModifiedFlag();<br/>
pDoc->UpdateAllViews(NULL);
CScrollView::OnLButtonDown(nFlags , point);<br/>
}
void CBmpInfoView::OnEditCopy()<br/>
{<br/>
CClientDC dc(this);<br/>
CDC memDC;<br/>
CBitmap bitmap;
m_Tracker.GetTrueRect(m_rectSave);
memDC.CreateCompatibleDC(&dc);<br/>
bitmap.CreateCompatibleBitmap(&dc, m_rectSave.Width(), m_rectSave.Height());<br/>
CBitmap* pOldBitmap = memDC.SelectObject(&bitmap);
OnPrepareDC(&memDC);<br/>
OnDraw(&memDC);
OpenClipboard();<br/>
EmptyClipboard();<br/>
SetClipboardData(CF_BITMAP, bitmap.GetSafeHandle());<br/>
CloseClipboard();
// Clean up<br/>
memDC.SelectObject(pOldBitmap);<br/>
bitmap.Detach();<br/>
}
Above given code displays the image from the 0 , 0 position and displays it in black color . Could you please help me out from this.
ThankYou
View the full article