1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
void MainPanel::OnPaint()
{
//CPaintDC dc(this);
//dc.TextOut(20,20,L"Welcome",7);
//MessageBeep(MB_ICONERROR);
CPaintDC dc(this);
CDC MemDC;
MemDC.CreateCompatibleDC(&dc);
CBitmap *myBmp = MemDC.SelectObject(&m_Bitmap);
dc.BitBlt(0, 0, 1024, 768, &MemDC, 0, 0, SRCCOPY);
dc.SelectObject(myBmp);
}
void MainPanel::OnLButtonDown(UINT nFlags, CPoint point)
{
CFrameWnd::OnLButtonDown(nFlags, point);
m_StartPoint = point;
}
void MainPanel::OnLButtonUp(UINT nFlags, CPoint point)
{
CFrameWnd::OnLButtonDown(nFlags, point);
m_EndPoint = point;
CClientDC dc(this);
dc.MoveTo(m_StartPoint);
dc.LineTo(m_EndPoint);
storeDCinBMP(&dc);
}
void MainPanel::storeDCinBMP(CClientDC* myCDC)
{
m_Bitmap.DeleteObject();
m_Bitmap.CreateCompatibleBitmap(myCDC, 1024, 768);
myCDC->SelectObject(m_Bitmap);
}
|