Thursday, November 12, 2009

How to Use Bitmap in SDI? ( VC++)

void CBitmapView::OnDraw(CDC* pDC)
{
CBitmapDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);



CBitmap bm;
CRect rc;
CBrush br;
bm.LoadBitmap(IDB_BITMAP1);
br.CreatePatternBrush(&bm);
GetClientRect(&rc);
//rc.bottom=100;
//rc.top=50;
//rc.left=50;
//rc.right=100;
pDC->FillRect(rc,&br);


// TODO: add draw code for native data here


}


void CBitmapView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CClientDC * Bms=new CClientDC(this);
if(point.x >= i && point.x <=j && point.y >=i && point.y <= j) { RedrawWindow(); CBrush br1; br1.CreateSolidBrush(RGB(100,100,50)); CRect rc1(i,i,j,j); Bms->FillRect(rc1,&br1);

}
CView::OnLButtonDown(nFlags, point);
}

No comments:

Post a Comment