翻译一段代码 mfc的 这是有关动态创建控件的
这段代码在窗口创建了按钮但是没能显示我要的图片;CButton*p_MyBut=newCButton();staticm_fc=FALSE;if(m_fc==FALSE)...
这段代码在窗口创建了按钮但是没能显示我要的图片;
CButton *p_MyBut = new CButton();
static m_fc=FALSE;
if(m_fc==FALSE)
{
p_MyBut->Create( "", WS_CHILD | WS_VISIBLE|BS_BITMAP , CRect(175,25,640,470), this, IDC_MYBUTTON );
hwndf = GetDlgItem(IDC_MYBUTTON);
hDesDCf = hwndf->GetDC()->m_hDC;
hSrcDCf = CreateCompatibleDC(hDesDCf);
hwndf->GetClientRect(&rectf);
hBitmapf=(HBITMAP)LoadImage(AfxGetInstanceHandle(),family[iPos],IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
GetObject(hBitmapf, sizeof BITMAP, &bmf);
SelectObject(hSrcDCf, hBitmapf);
SetStretchBltMode(hDesDCf,COLORONCOLOR);
StretchBlt(hDesDCf, rectf.left, rectf.top, rectf.right, rectf.bottom, hSrcDCf, 0, 0, bmf.bmWidth, bmf.bmHeight,+SRCCOPY);
p_MyBut->SetBitmap(hBitmapf);
m_fc=TRUE;
}
else
{
m_fc=FALSE;
}
哪里丫,这代码是重别人的拼凑的,能说详细点吗? 展开
CButton *p_MyBut = new CButton();
static m_fc=FALSE;
if(m_fc==FALSE)
{
p_MyBut->Create( "", WS_CHILD | WS_VISIBLE|BS_BITMAP , CRect(175,25,640,470), this, IDC_MYBUTTON );
hwndf = GetDlgItem(IDC_MYBUTTON);
hDesDCf = hwndf->GetDC()->m_hDC;
hSrcDCf = CreateCompatibleDC(hDesDCf);
hwndf->GetClientRect(&rectf);
hBitmapf=(HBITMAP)LoadImage(AfxGetInstanceHandle(),family[iPos],IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
GetObject(hBitmapf, sizeof BITMAP, &bmf);
SelectObject(hSrcDCf, hBitmapf);
SetStretchBltMode(hDesDCf,COLORONCOLOR);
StretchBlt(hDesDCf, rectf.left, rectf.top, rectf.right, rectf.bottom, hSrcDCf, 0, 0, bmf.bmWidth, bmf.bmHeight,+SRCCOPY);
p_MyBut->SetBitmap(hBitmapf);
m_fc=TRUE;
}
else
{
m_fc=FALSE;
}
哪里丫,这代码是重别人的拼凑的,能说详细点吗? 展开
2个回答
2009-11-20
展开全部
你试试在创建兼容DC的时候参数给个NULL
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询