我在SDK中实现屏幕站图,但是位图我是在基于对话框的程序中进行,为什么图像始终不显示?

klcdyx2009 2010-12-27 09:23:43
case WM_LBUTTONDOWN:
{
// MessageBox(NULL,L"abcd",L"hehe",MB_OK);

hBmp=LoadBitmap(MyListhInst,MAKEINTRESOURCE(IDB_BITMAP1));
HDC hdctemp = NULL;
HBITMAP hbmptemp = NULL;
BITMAP bmp;
GetObject(hBmp,sizeof(bmp), &bmp);

hdc = GetDC(hWnd);

TextOut(hdc,0,0,L"美丽",2);
hdcmem = CreateCompatibleDC(hdc);
hdctemp = CreateCompatibleDC(hdc);
hbmptemp = CreateCompatibleBitmap(hdc,rectImage.right - rectImage.left, rectImage.bottom - rectImage.top);

SelectObject(hdctemp,hBmp);
SelectObject(hdcmem,hbmptemp);

bool pp=BitBlt(hdcmem,0,0,ThisOfRect.right- ThisOfRect.left,ThisOfRect.bottom- ThisOfRect.top,hdctemp,rectImage.left,rectImage.top,SRCCOPY);
/*TCHAR MyChar[200];
wsprintf(MyChar,L"textout-%d",pp);
MessageBox(hWnd,MyChar,L"提示",MB_OK);*/

ReleaseDC(hWnd,hdc);
DeleteDC(hdctemp);
DeleteObject(hbmptemp);
DeleteObject(hBmp);

}
我用TextOut字体能显示出来,但是就是图像不显示,为什么?
...全文
107 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
klcdyx2009 2010-12-27
  • 打赏
  • 举报
回复
不行啊,我是把把内存Bitmap复制到hdc了的啊
__lhy 2010-12-27
  • 打赏
  • 举报
回复
[Quote=引用楼主 klcdyx2009 的回复:]
case WM_LBUTTONDOWN:
{
// MessageBox(NULL,L"abcd",L"hehe",MB_OK);

hBmp=LoadBitmap(MyListhInst,MAKEINTRESOURCE(IDB_BITMAP1));
HDC hdctemp = NULL;
HBITMAP hbmptemp = NULL;
BITMAP bmp;
GetObject(hBmp,sizeof(bmp), &bmp);

hdc = GetDC(hWnd);

TextOut(hdc,0,0,L"美丽",2);
hdcmem = CreateCompatibleDC(hdc);
hdctemp = CreateCompatibleDC(hdc);
hbmptemp = CreateCompatibleBitmap(hdc,rectImage.right - rectImage.left, rectImage.bottom - rectImage.top);

SelectObject(hdctemp,hBmp);
SelectObject(hdcmem,hbmptemp);

bool pp=BitBlt(hdcmem,0,0,ThisOfRect.right- ThisOfRect.left,ThisOfRect.bottom- ThisOfRect.top,hdctemp,rectImage.left,rectImage.top,SRCCOPY);
/*TCHAR MyChar[200];
wsprintf(MyChar,L"textout-%d",pp);
MessageBox(hWnd,MyChar,L"提示",MB_OK);*/

ReleaseDC(hWnd,hdc);
DeleteDC(hdctemp);
DeleteObject(hbmptemp);
DeleteObject(hBmp);

}
[/Quote]
把内存Bitmap复制到hdc
Eleven 2010-12-27
  • 打赏
  • 举报
回复
把你的绘图的代码放到WM_PAINT消息中去做
klcdyx2009 2010-12-27
  • 打赏
  • 举报
回复
LoadBitmap不是 NULL;
klcdyx2009 2010-12-27
  • 打赏
  • 举报
回复
LoadBitmap不是啊!!!
向立天 2010-12-27
  • 打赏
  • 举报
回复
其实我没看明白你的问题
小楫轻舟 2010-12-27
  • 打赏
  • 举报
回复
LoadBitmap有成功吗?
hBmp是不是NULL

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧