0

I get an error: Debug Assertion Failed at my myDC.DrawText? If I remove that line, the graphics work fine.

CPaintDC dc(this);

CBitmap myBmp;
CDC myDc;

HANDLE h = ::LoadImage(NULL,"C:\\lady.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
myBmp.Attach(h);

myDc.DrawText("Hello",CRect(10,10,100,30),DT_CENTER);  // Debug Assertion Failed


myDc.CreateCompatibleDC(&dc);
myDc.SelectObject(&myBmp);
dc.BitBlt(20,10,436,363,&myDc,0,0,SRCCOPY);
4

1 回答 1

3

您在实际创建 DC 之前绘制文本。将 DrawText 行移到 CreateCompatibleDB 行下方。

于 2012-04-11T12:29:26.250 回答