本文介绍了如何设置我的位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在CStatic控件上设置位图图像.

I want to set bitmap image on CStatic control.

capEditCopy(hMyWindow);
		OpenClipboard();
		 m_hBmp = (HBITMAP)::GetClipboardData(CF_BITMAP);
		CloseClipboard();
		m_bmp.Detach();
		m_bmp.Attach(m_hBmp);
((CStatic*)m_cTab1.GetDlgItem(6))->SetBitmap(m_bmp);


它使调试断言失败!


It gives debug assertion failed!

推荐答案

capEditCopy(hMyWindow);
		OpenClipboard();
		 m_hBmp = (HBITMAP)::GetClipboardData(CF_BITMAP);

		m_bmp.Detach();
		m_bmp.Attach(m_hBmp);
((CStatic*)m_cTab1.GetDlgItem(6))->SetBitmap(m_bmp);
CloseClipboard();


请像这样检查.


Please check like this.


void abcDlg::CapturePhoto()
{
    //dlgWin2.m_cTab1=m_cTab;
    CWin2Dlg dlgWin2;

    if(IDOK==dlgWin2.DoModal())// && (!dlgWin2.Image().Empty()))
            {
                ((CStatic*)m_cTab.GetDlgItem(6))->SetBitmap(dlgWin2.m_hBmp);
            }
}
void CWin2Dlg::OnBnClickedButton1()
{
	if(CaptureFlag && m_hBmp)
	{
		bool iop=capEditCopy(hMyWindow);
		OpenClipboard();
		 m_hBmp = (HBITMAP)::GetClipboardData(CF_BITMAP);
		 CloseClipboard();	
	}
}


这篇关于如何设置我的位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 17:02