积累系统性知识
积聚技术精华
  首页    个人中心    撰写积文    建立课题    订立目标    整理积文    管理课题    管理目标    技能Get    代码积累 
SDK创建工具条
error997 (error997)    2014-11-20 20:14:34      目标    课题
切换到: 纯代码  
   
//创建工具条
HWND CreateToolBar(HWND hWndParent)
{
    HWND hWndTB;
    TBBUTTON tbb[4];
    HIMAGELIST hImageList,hHotImageList,hDisableImageList;
    HBITMAP hBitmap;
    INITCOMMONCONTROLSEX icex;
    icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
    icex.dwICC  = ICC_BAR_CLASSES;
    InitCommonControlsEx(&icex);
    hWndTB = CreateWindowEx(0,
        TOOLBARCLASSNAME,TEXT(""),
        WS_CHILD|WS_VISIBLE|WS_BORDER|TBSTYLE_FLAT||CCS_NOMOVEY,
        0,0,0,0,
        hWndParent,
        (HMENU)IDR_TOOLBAR,
        g_hInst,
        NULL);
    if(!hWndTB)
        return 0;
    SendMessage(hWndTB, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
    hImageList = ImageList_Create(20,20,ILC_COLOR24,3,1);
    hBitmap = LoadBitmap(g_hInst,MAKEINTRESOURCE(IDR_TOOLBAR));
    ImageList_Add(hImageList,hBitmap,NULL);
    DeleteObject (hBitmap);
    SendMessage(hWndTB,TB_SETIMAGELIST,0,(LPARAM)hImageList);
   hHotImageList = ImageList_Create(20,20,ILC_COLOR24,3,1);
    hBitmap = LoadBitmap(g_hInst,MAKEINTRESOURCE(IDR_TOOLBARHOT));
    ImageList_Add(hHotImageList,hBitmap,NULL);
    DeleteObject (hBitmap);
    SendMessage(hWndTB,TB_SETHOTIMAGELIST,0,(LPARAM)hHotImageList);
   hDisableImageList = ImageList_Create(20,20,ILC_COLOR24,3,1);
    hBitmap = LoadBitmap(g_hInst,MAKEINTRESOURCE(IDR_TOOLBARDISABLE));
    ImageList_Add(hDisableImageList,hBitmap,NULL);
    DeleteObject (hBitmap);
    SendMessage(hWndTB,TB_SETDISABLEDIMAGELIST,0,(LPARAM)hDisableImageList);
   ZeroMemory(tbb, sizeof(tbb));
    tbb[0].iBitmap =MAKELONG(0,0) ;
    tbb[0].fsState = TBSTATE_ENABLED;
    tbb[0].fsStyle = TBSTYLE_BUTTON|BTNS_AUTOSIZE;
    tbb[0].idCommand = ID_MENU_NEW; 
    //tbb[0].iString = (INT_PTR)TEXT("查找");
    tbb[1].iBitmap =MAKELONG(1,0);
    tbb[1].fsState = TBSTATE_ENABLED;
    tbb[1].fsStyle = TBSTYLE_BUTTON|BTNS_AUTOSIZE;
    tbb[1].idCommand = ID_MENU_OPEN; 
    //tbb[1].iString = (INT_PTR)TEXT("后退");
    tbb[2].iBitmap =MAKELONG(2,0);
    tbb[2].fsState = TBSTATE_ENABLED;
    tbb[2].fsStyle = TBSTYLE_BUTTON|BTNS_AUTOSIZE;
    tbb[2].idCommand = ID_MENU_SAVE;
    //tbb[2].iString = (INT_PTR)TEXT("向前");
    tbb[3].iBitmap =MAKELONG(3,0);
    tbb[3].fsState = TBSTATE_ENABLED;
    tbb[3].fsStyle = TBSTYLE_BUTTON|BTNS_AUTOSIZE;
    tbb[3].idCommand = ID_MENU_EXIT;
    //tbb[3].iString = (INT_PTR)TEXT("视图");
    SendMessage(hWndTB, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);
    SendMessage(hWndTB,WM_SIZE,0,0);
    return hWndTB;
}


转自 http://blog.csdn.net/y___y/article/details/1955919
(+0)技能Get

建议楼主:搜索关键字 |参考其他资源 |回复 |追问
  error997(error997):   个人中心    课题    目标    代码积累