您知道如何在静态文本框上显示位图吗?书上说要显示位图,需要设置CStatic的SS_BITMAP属性
应该怎么设置呢? CBitmap hBitmap;
hBitmap.LoadBitmap(IDB_BITMAP1);
m_CStatic.SetBitmap(hBitmap);

解决方案 »

  1.   

    CStatic * cwm=(CStatic *)GetDlgItem(IDC_CYL);
    CBitmap bmpload;
    bmpload.LoadBitmap(IDB_WM4);
    cwm->SetBitmap(HBITMAP(bmpload.Detach()));
      

  2.   

    ◆静态文本框
    静态文本框是一种静态控件,可以显示字符串、矩形、图标、光标、位图、以及元文件。
    常用来作为其他控件的标签,也可以作为容器容纳其他控件,还可以分割控件。
    CStatic的成员函数有:SetBitMap(),GetBitMap();SetIcon();GetIcon();SetCursor();GetCursor();SetEnhMetaMap();GetEnhMetaMap();
    在使用上述函数时,要想让静态文本框显示某种类型的对象,必须设置静态框本身的相应的属性,比如SetBitMap(),显示位图时,要设置CStatic的SS_BITMAP属性。我的意思是如何在静态文本框上显示一个位图??/
      

  3.   

    m_CStatic.ModifyStyle(0, SS_BITMAP);
    就ok了。
      

  4.   

    m_CStatic.ModifyStyle(0, SS_BITMAP);
    就ok了。
      

  5.   

    m_static.Create( , SS_BITMAP...._)
      

  6.   

    CStatic::Create 
    BOOL Create( LPCTSTR lpszText, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID = 0xffff );Return ValueNonzero if successful; otherwise 0.ParameterslpszTextSpecifies the text to place in the control. If NULL, no text will be visible.dwStyleSpecifies the static control’s window style. Apply any combination of static control styles to the control.  rectSpecifies the position and size of the static control. It can be either a RECT structure or a CRect object.pParentWndSpecifies the CStatic parent window, usually a CDialog object. It must not be NULL.nIDSpecifies the static control’s control ID.ResConstruct a CStatic object in two steps. First call the constructor CStatic, then call Create, which creates the Windows static control and attaches it to the CStatic object. Apply the following window styles to a static control: WS_CHILD   Always
    WS_VISIBLE   Usually
    WS_DISABLED   Rarely 
    If you're going to display a bitmap, cursor, icon, or metafile in the static control, you'll need to apply one of the following styles: SS_BITMAP   Use this style for bitmaps.
    SS_ICON   Use this style for cursors and icons.
    SS_ENHMETAFILE   Use this style for enhanced metafiles. 
    For cursors, bitmaps, or icons, you may also want to use the following style: SS_CENTERIMAGE   Use to center the image in the static control. 
    ExampleCStatic myStatic;// Create a child static control that centers its text horizontally.
    myStatic.Create(_T("my static"), WS_CHILD|WS_VISIBLE|SS_CENTER, 
       CRect(10,10,150,50), pParentWnd);
      

  7.   

    假设你的控件为 m_CStatic,想加载的图片为 IDB_BITMAP 。用:HBITMAP hBitmap=::LoadBitmap(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDB_BITMAP));
    m_CStatic.SetBitmap(hBitmap);
      

  8.   

    搞定了,谢谢大家。 
            //...............
    CStatic m_CStatic_Bitmap;
    CBitmap m_Bitmap;
              //................
    m_Bitmap.LoadBitmap(IDB_BITMAP1);
    m_CStatic_Bitmap.ModifyStyle(0,SS_BITMAP);
    m_CStatic_Bitmap.SetBitmap(m_Bitmap);
              //...................
      

  9.   

    另一个:
        CStatic * cwm=(CStatic *)GetDlgItem(IDC_STATIC_BITMAP);
        CBitmap bmpload;
        bmpload.LoadBitmap(IDB_BITMAP1);
        cwm->ModifyStyle(0,SS_BITMAP);
        cwm->SetBitmap(HBITMAP(bmpload.Detach()));