使用更大颜色的更大图标工具栏 [英] Use Larger Icon Toolbar With More color

查看:126
本文介绍了使用更大颜色的更大图标工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想制作一个支持图标的大工具栏,其深度超过Visual Studio中的默认值。



我正在使用Visual Studio 2005.所以人们,我可以创建一个支持256色的工具栏(例如)。



注意:我的工具栏位于CDialog窗口。



我使用了代码:这里但没有用。



Hi all,

I wanna make a large toolbar with support of icons with more colors depth than default in Visual Studio.

I am using Visual Studio 2005. So people, hwo can I create a toolbar with support of 256 colors (for instance).

NB: my toolbar is on a CDialog Window.

I used the Code found : here but did not work.

int CSalariesForm::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CDialog::OnCreate(lpCreateStruct) == -1)
        return -1;

    HBITMAP hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(),
        MAKEINTRESOURCE(IDR_MAINFRAME1), IMAGE_BITMAP,
        0,0, LR_CREATEDIBSECTION | LR_LOADMAP3DCOLORS);

    CBitmap bm;
    bm.Attach(hBitmap);


    CImageList m_imagelist;
    m_imagelist.Create(20, 20, ILC_COLOR8, 4, 4);
    m_imagelist.Add(&bm, (CBitmap*) NULL);

    cToolBar.Create(this);
    cToolBar.GetToolBarCtrl().SetImageList(&m_imagelist);

    cToolBar.ShowWindow(SW_SHOW);
    cToolBar.SetBarStyle(CBRS_TOOLTIPS | CBRS_FLOATING | CBRS_ALIGN_TOP | CBRS_FLYBY);
    RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
    return 0;
}





帮助!!!



谢谢



Help !!!

Thank you

推荐答案

我找到了答案,所以这就是我的进展:



I found the answer, so this is how I proceeded :

//header file
private:
    CImageList m_imagelist;
    CToolBar   m_toolbar;



&


&

// source file
enum { width = 20, height = 20 }; // width and height of one button image

m_toolbar.Create(this);

// create the image list
m_imagelist.Attach(
    ImageList_LoadImage(
        AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1), width, 4, 
        CLR_DEFAULT, IMAGE_BITMAP, LR_CREATEDIBSECTION | LR_LOADTRANSPARENT )
);

// set button and image sizes (copied from CToolBar::LoadToolBar)
m_toolbar.SetSizes(CSize(width+7,height+7), CSize(width,height));

// set image list
m_toolbar.GetToolBarCtrl().SetImageList(&m_imagelist);

// define command ids for each button
const UINT cmdIds[] = { 
    IDOK,
    0,        // separator
    IDCANCEL,
};

// assign ids to the toolbar
m_toolbar.SetButtons(cmdIds, sizeof(cmdIds)/sizeof(UINT));

RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);


这篇关于使用更大颜色的更大图标工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆