16,472
社区成员
发帖
与我相关
我的任务
分享
CMyStatic::CMyStatic(char *bmpPath)
{
//加载图片
strcpy(m_bmpPath,bmpPath);
m_hbmp = (HBITMAP)LoadImage(NULL,"c:/BIN/res/Close.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
m_curBmp.Attach(m_hbmp);
if (NULL == m_curBmp.m_hObject)
{
MessageBox("加载图片失败!","加载失败!",MB_OK);
}
m_stcID = -1;
}
void CMyStatic::MyCreate(CRect &rect, CWnd *pWnd, int ID)
{
//这里创建一个CStatic窗体
CStatic::Create(NULL,WS_CHILD|WS_VISIBLE|SS_BITMAP|SS_NOTIFY,rect,pWnd,ID);
if (m_hWnd == NULL)
{
MessageBox("静态文本窗体创建不成功!","创建失败",MB_OK);
return;
}
}
void CMyStatic::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect curRect;
GetClientRect(curRect);
CDC memDC;
memDC.CreateCompatibleDC(NULL);
memDC.SelectObject(&m_curBmp);
dc.BitBlt(0,0,curRect.Width(),curRect.Height(),&memDC,0,0,SRCCOPY);
// TODO: Add your message handler code here
// Do not call CStatic::OnPaint() for painting messages
}