用CToolbar动态创建工具条就可以! CToolBar Class Members ConstructionCToolBar Constructs a CToolBar object. Create Creates the Windows toolbar and attaches it to the CToolBar object. CreateEx Creates a CToolBar object with additional styles for the embedded CToolBarCtrl object. SetSizes Sets the sizes of buttons and their bitmaps. SetHeight Sets the height of the toolbar. LoadToolBar Loads a toolbar resource created with the resource editor. LoadBitmap Loads the bitmap containing bitmap-button images. SetBitmap Sets a bitmapped image. SetButtons Sets button styles and an index of button images within the bitmap. Attributes CommandToIndex Returns the index of a button with the given command ID. GetItemID Returns the command ID of a button or separator at the given index. GetItemRect Retrieves the display rectangle for the item at the given index. GetButtonStyle Retrieves the style for a button. SetButtonStyle Sets the style for a button. GetButtonInfo Retrieves the ID, style, and image number of a button. SetButtonInfo Sets the ID, style, and image number of a button. GetButtonText Retrieves the text that will appear on a button. SetButtonText Sets the text that will appear on a button. GetToolBarCtrl Allows direct access to the underlying common control.
if (m_ImageList.Create(32,32,ILC_COLOR,7,1)==0) { AfxMessageBox("創建圖像列表框失敗!"); return -1; } for (int i=0;i<7;i++) { HICON hIcon=(HICON)LoadImage(AfxGetInstanceHandle(),"c:\\test.ico",IMAGE_ICON,0,0,LR_LOADFROMFILE); int pos=m_ImageList.Add(hIcon); DestroyIcon(hIcon); } m_ToolBar.SetImageList(&m_ImageList);
CToolBar Class Members
ConstructionCToolBar Constructs a CToolBar object.
Create Creates the Windows toolbar and attaches it to the CToolBar object.
CreateEx Creates a CToolBar object with additional styles for the embedded CToolBarCtrl object.
SetSizes Sets the sizes of buttons and their bitmaps.
SetHeight Sets the height of the toolbar.
LoadToolBar Loads a toolbar resource created with the resource editor.
LoadBitmap Loads the bitmap containing bitmap-button images.
SetBitmap Sets a bitmapped image.
SetButtons Sets button styles and an index of button images within the bitmap.
Attributes CommandToIndex Returns the index of a button with the given command ID.
GetItemID Returns the command ID of a button or separator at the given index.
GetItemRect Retrieves the display rectangle for the item at the given index.
GetButtonStyle Retrieves the style for a button.
SetButtonStyle Sets the style for a button.
GetButtonInfo Retrieves the ID, style, and image number of a button.
SetButtonInfo Sets the ID, style, and image number of a button.
GetButtonText Retrieves the text that will appear on a button.
SetButtonText Sets the text that will appear on a button.
GetToolBarCtrl Allows direct access to the underlying common control.
{
AfxMessageBox("創建圖像列表框失敗!");
return -1;
}
for (int i=0;i<7;i++)
{
HICON hIcon=(HICON)LoadImage(AfxGetInstanceHandle(),"c:\\test.ico",IMAGE_ICON,0,0,LR_LOADFROMFILE);
int pos=m_ImageList.Add(hIcon);
DestroyIcon(hIcon);
}
m_ToolBar.SetImageList(&m_ImageList);