if (!strpointmap.empty()) if (strpointmap[n].Find(L"png") != -1 || strpointmap[n].Find(L"PNG") != -1) { image.Load(strpointmap[n]); CDC* pDialogDC = GetDC(); CRect mrect; CPen pen(PS_SOLID, 3, RGB(200, 200, 200)); CBrush pbrush; pbrush.CreateSolidBrush(RGB(200, 200, 200)); pDialogDC->SelectObject(&pen); pDialogDC->SelectObject(&pbrush); pDialogDC->Rectangle(rectPicture); int mleft = move_x[changenum]; int mright = change_x[changenum] + image.GetWidth(); int mtop = move_y[changenum]; int mbottom = change_y[changenum] + image.GetHeight(); int width = (int)(image.GetWidth() * nScalePercent / 100.0f); int height = (int)(image.GetHeight() * nScalePercent / 100.0f); CBitmap bitmap; bitmap.CreateBitmap(width, height, image.GetBPP(), 1, NULL); CDC* pDC = m_pictureCtrl.GetDC(); CDC memDC; memDC.CreateCompatibleDC(pDC); CBitmap* pOldBitmap = memDC.SelectObject(&bitmap); memDC.SetStretchBltMode(COLORONCOLOR); image.StretchBlt(memDC.GetSafeHdc(), 0, 0, width, height, SRCCOPY); memDC.SelectObject(pOldBitmap); m_pictureCtrl.SetBitmap(bitmap.Detach()); m_nScalePercent = nScalePercent;代码中有错误HGDIOBJ" 类型的实参与 "HBITMAP" 类型的形参不兼容,而且在CBitmap* pOldBitmap = memDC.SelectObject(bitmap);中memDC"HGDIOBJ" 类型的值不能用于初始化 "CBitmap *" 类型的实体
时间: 2024-02-28 21:54:56 浏览: 62
minigui移植到6410
5星 · 资源好评率100%
这段代码中的错误是将一个 HGDIOBJ 类型的对象作为参数传递给了一个需要 HBITMAP 类型对象的函数。具体来说,是在以下代码中出现的问题:
```C++
CBitmap* pOldBitmap = memDC.SelectObject(&bitmap);
```
应该将其改为:
```C++
CBitmap* pOldBitmap = memDC.SelectObject(bitmap);
```
另外,在以下代码中,应该将 memDC 的类型从 CDC 改为 CMemDC,以避免内存泄漏:
```C++
CDC memDC;
```
改为:
```C++
CMemDC memDC(pDC, &bitmap);
```
阅读全文