EVC中CStatic显示BITMAP

来源:互联网 发布:对抗网络 编辑:程序博客网 时间:2024/05/23 11:33
  我的解决方法:
CStatic*   m_picture=(CStatic   *)GetDlgItem(IDC_STATIC_TEST);  
    HBITMAP   bitmap;  
    bitmap=(HBITMAP)::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP_OFF));  
    m_picture->ModifyStyle(0,SS_BITMAP|SS_CENTERIMAGE);  
    m_picture->SetBitmap(bitmap);  




一位好友的解决方法:
// EVC+CStatic+BITMAP

HBITMAP hbitmap = 0 ;
hbitmap = (HBITMAP)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP_TEST),IMAGE_BITMAP,0,0,LR_DEFAULTCOLOR) ;

if (hbitmap)
{
m_ctrlStaticTest.SetBitmap(hbitmap) ; // m_ctrlStaticTest是CStatic的控制变量
}





datoucaicai      2008年07月20日 23点25分26秒 说:
    假设CStatic控件ID为IDC_STATIC_TEST,属性Type为Bitmap,

    m_ctrlStaticTest为CStatic控件关联的控制变量CStatic m_ctrlStaticTest ; //成员变量定义

    DDX_Control(pDX, IDC_STATIC_TEST, m_ctrlStaticTest ); //变量关联

    // 贴图代码
    HBITMAP hbitmap = 0 ;
    hbitmap = (HBITMAP)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP_TEST),IMAGE_BITMAP,0,0,LR_DEFAULTCOLOR) ; //IDB_BITMAP_TEST 为位图ID

    if (hbitmap)
    {
    m_ctrlStaticTest.SetBitmap(hbitmap) ; // m_ctrlStaticTest是CStatic的控制变量
    }

    // LoadImage中的0,0的意思,msdn解释如下:
    cxDesired
    [in] Specifies the width, in pixels, of the icon or cursor. If this parameter is zero and the fuLoad parameter is LR_DEFAULTSIZE, the function uses the SM_CXICON or SM_CXCURSOR system metric value to set the width. If this parameter is zero and LR_DEFAULTSIZE is not used, the function uses the actual resource width.
    cyDesired
    [in] Specifi

datoucaicai      2008年07月20日 23点26分00秒 说:
    cxDesired
    [in] Specifies the width, in pixels, of the icon or cursor. If this parameter is zero and the fuLoad parameter is LR_DEFAULTSIZE, the function uses the SM_CXICON or SM_CXCURSOR system metric value to set the width. If this parameter is zero and LR_DEFAULTSIZE is not used, the function uses the actual resource width.
    cyDesired
    [in] Specifies the height, in pixels, of the icon or cursor. If this parameter is zero and the fuLoad parameter is LR_DEFAULTSIZE, the function uses the SM_CYICON or SM_CYCURSOR system metric value to set the height. If this parameter is zero and LR_DEFAULTSIZE is not used, the function uses the actual resource height.

datoucaicai      2008年07月20日 23点29分33秒 说:
    // 如果这样还不行的话,那直接在CStatic的属性中Image选IDC_STATIC_TEST试试看能不能显示出图片来




原创粉丝点击