专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »C 教程 » mfc属性页:属性表标签上的位图在MFC,CB下的实现 »正文

mfc属性页:属性表标签上的位图在MFC,CB下的实现

来源: 发布时间:星期四, 2009年2月12日 浏览:136次 评论:0



属性表标签(tab control)支持在每个item上放Image 图片在mfc下实现相当简单可分为以下几步:
    
    step1: create a bitmap resource with the images
           
           you can also use icons or even create the images at run time.
           the size of the images should be in proportion to the height
           of the label.
    step2: add member variable of type Cimagelist
           
            protected:
                      CImagelist m_imagetab;

    step3:  Override _disibledevent=>                m_imagetab.create(IDB_TABIMAGES,13,1,RGB(255,255,255));
                CTabCtrl *pTab=GetTabControl;
                pTab->SetImageList(&m_imagetab);
                
                tc_item tcitem;
                tcitem.mask=tc_image;
                
                for( i=0;i<3;i)
                {  
                    tcitem.iimage=i;

                     pTab->SetItem(i,&tcitem);
                }
                 bresult;
              }

CBuilder 没有提供 SetImageListSetItem这样但我们可以直接处理WINDOWS API 消息:TCM_SETIMAGELISTTCM_SETITEM. 看下面代码可以体会区别编程风格

void __fastcall TForm1::FormPa(TObject *Sender)
{


    TabControl1->Perform ( TCM_SETIMAGELIST, 0, ImageList1->Handle );
    TCITEM tcitem;
    tcitem.mask=TCIF_IMAGE ;
    for( i=0;i<3;i)
    {
        tcitem.iImage=i;
        TabControl1->Perform ( TCM_SETITEM, i,(LPARAM) (LPTCITEM)     &tcitem );

     }

}


0

相关文章

读者评论

发表评论

  • 昵称:
  • 内容: