//创建工具条
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;
}