让Toolbar显示大小不同的ICONs

转载 2006年06月23日 13:53:00

It's said in MSDN that:“Microsoft Windows assumes that all of a toolbar's bitmapped images are the same size. ” So the question is : How can we implement a toolbar with different sized images, which is just like as Google Toolbar?


There are two ways:

1.To use double ImageLists

You should note that the image's size of the toolbar is decided by the first ImageList, even though the second one is different from the first one. So after registering double ImageLists, you also have to reset the button's size to suit the second imagelist.
This is the code segment:

a. setting double imagelist
    //1st ImageList, with normal images
    m_hImage1st = ImageList_Create(1616, ILC_COLOR24, 10);
    
int nIdx11 = ImageList_Add(m_hImageFirst,,NULL);
    
int nIdx12 =  ImageList_Add(m_hImageFirst,,NULL);

        
//2nd ImageList, with bigger image
    m_hImage2nd = ImageList_Create(4816, ILC_COLOR24, 20);
    
int nIdx21 =ImageList_Add(m_hImage2nd ,,NULL);

    
// add imagelists, the order is very important
    ::SendMessage(m_hWnd, CCM_SETVERSION, (WPARAM) 50);
    ::SendMessage(m_hWnd, TB_SETIMAGELIST, 
0, (LPARAM)m_hImage1st);
    ::SendMessage(m_hWnd, TB_SETIMAGELIST, 
1, (LPARAM)m_hImage2nd);

    
// set button image
    pTBBtn[0].iBitmap = MAKELONG(nIdx21, 1);
    pTBBtn[
1].iBitmap = MAKELONG(nIdx11, 0);
    pTBBtn[
2].iBitmap = MAKELONG(nIdx12, 0);

b. resize the button with bigger image
    TBBUTTONINFO tbi;            
    tbi.cbSize 
= sizeof(TBBUTTONINFO);
    tbi.dwMask 
= TBIF_STYLE | TBIF_SIZE;
    tbi.fsStyle 
= pTBBtn[0].fsStyle;
    tbi.cx 
= 48;
        ::SendMessage(m_hWnd, TB_SETBUTTONINFO, nID, (LPARAM)
&tbi);

And now,  the first button of the toolbar has different sized image from others.

2. To use Rebar control

A rebar control may have many toolbars, so you can create two toolbars with different sized imagelist.(See MSDN.). But we can only create one toolbar in WTL by default, so it's a little complex to implement using WTL in this method. You can try this in MFC.

相关文章推荐

toolbar-icons

  • 2014-09-15 18:28
  • 2.42MB
  • 下载

APP-ICONS尺寸大小的总结--图示

Android不同分辨率图片实际显示大小的计算

Android应用多分辨率屏幕匹配,如何计算图片在手机上实际显示大小

iOS开发 label上显示不同颜色不同大小的字

// 要显示不同颜色的数字     NSString *numberStr = [NSString stringWithFormat:@"%d",121]; // _myabel创建的label ...

怎样能在大小不同的屏幕上显示同样的网页(自适应网页设计)?

怎样能在大小不同的屏幕上显示同样的网页(自适应网页设计)? 2014/5/4 12:26:57 随着3G的普及,越来越多的人使用手机上网。 移动设备正超过桌面设备,成为访问互联网的最...

【android】图片放错文件夹引起显示大小不同的原因与屏幕适配原理

大纲 1、android中res目录下的文件夹所对应屏幕尺寸 2、用dp表示尺寸的原理 3、对于720p尺寸的适配需要注意什么 4、ui切图按什么尺寸给最好 参考:htt...

更改ToolBar的样式(侧边栏联动箭头颜色,字体大小和颜色)

更改ToolBar的样式(侧边栏联动箭头颜色,字体大小和颜色) true @android:color/white ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)