LRESULT CMFToolbar::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{

SendMessage(m_hWnd,TB_BUTTONSTRUCTSIZE,sizeof(TBBUTTON),0);
SendMessage(m_hWnd,TB_SETMAXTEXTROWS,4,0L);
TCHAR*   pCaption   =   _T("MEUU");
int   iIndex   =   ::SendMessage(m_hWnd,   TB_ADDSTRING,   0,(LPARAM)pCaption);
TCHAR* pCaption1=_T("交友");
iIndex   =::SendMessage(m_hWnd,   TB_ADDSTRING,   0,(LPARAM)pCaption1);
TCHAR* pCaption2=_T("活动");
iIndex   =::SendMessage(m_hWnd,   TB_ADDSTRING,   0,(LPARAM)pCaption2);
TCHAR* pCaption3=_T("博客");
iIndex   =::SendMessage(m_hWnd,   TB_ADDSTRING,   0,(LPARAM)pCaption3); 
//   load   our   button's   icon   and   create   the   image   list   to   house   it.
HICON   hMotley   =   LoadIcon(_Module.GetResourceInstance(),   MAKEINTRESOURCE(IDI_MOTLEY));
m_hImageList   =   ImageList_Create(16,16,   ILC_COLOR16,   1,   0);
int   iImageIndex   =   ImageList_AddIcon(m_hImageList,   hMotley);
DestroyIcon(hMotley);
hMotley   =   LoadIcon(_Module.GetResourceInstance(),   MAKEINTRESOURCE(IDI_MOTLEY));
iImageIndex   =   ImageList_AddIcon(m_hImageList,   hMotley);
DestroyIcon(hMotley);
//   Set   the   toolbar's   image
::SendMessage(m_hWnd,   TB_SETIMAGELIST,   0,   (LPARAM)m_hImageList); //   add   the   button   for   the   toolbar   to   the   window
TBBUTTON   Button;
ZeroMemory((void*)&Button,   sizeof(TBBUTTON));
Button.idCommand   =   IDM_GETQUOTE;
Button.fsState   =   TBSTATE_ENABLED;
Button.fsStyle   =   BTNS_BUTTON   |   BTNS_AUTOSIZE   |   BTNS_SHOWTEXT;
Button.dwData   =   0;
Button.iString   =   0;
Button.iBitmap   =   0;
int   num=::SendMessage(m_hWnd,   TB_INSERTBUTTON,   1,   (LPARAM)&Button);
TBBUTTON   Button1;
ZeroMemory((void*)&Button1,   sizeof(TBBUTTON)); 
Button1.idCommand=IDM_GETQUOTE;
Button1.fsState   =   TBSTATE_ENABLED;
Button1.fsStyle   =   BTNS_BUTTON   |   BTNS_AUTOSIZE   |   BTNS_SHOWTEXT;
Button1.dwData   =   0;
Button1.iString   =   2;
Button1.iBitmap   =   0;
num=::SendMessage(m_hWnd,   TB_INSERTBUTTON,2,   (LPARAM)&Button1);
TBBUTTON   Button2;
ZeroMemory((void*)&Button2,   sizeof(TBBUTTON)); 
Button2.idCommand=IDM_GETQUOTE;
Button2.fsState   =   TBSTATE_ENABLED;
Button2.fsStyle   =   BTNS_BUTTON   |   BTNS_AUTOSIZE   |   BTNS_SHOWTEXT;
Button2.dwData   =   0;
Button2.iString   =   3;
Button2.iBitmap   =   0;
num=::SendMessage(m_hWnd,   TB_INSERTBUTTON,3,   (LPARAM)&Button2); //   create   our   EditQuote   window   and   set   the   font.
RECT   rect   =   {0,0,0,0};
m_EditWnd.Create(m_hWnd,   rect,   NULL,   WS_CHILD|WS_VISIBLE,   WS_EX_CLIENTEDGE);
m_EditWnd.SetFont(static_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT)));
return   0;

}
这段是代码
为什么我只能得到MENU这个按钮
其他的按钮都不能创建
我也在CSDN找了
他们的好像度可以啊
为什么我得不可以呢
谢谢关注

解决方案 »

  1.   

    IE添加按钮不是这么整的吧,GOOGLE一下
      

  2.   

    TO SeekTruth(鹤舞白沙):IE添加按钮是通过操作注册表得
    这个我知道
    但是我现在哪个已经实现了
    我已经通过Google search了很多遍了
    这段代码没有编译问题
    就是出来不了效果
    谢谢你
    希望这位大侠继续关注
      

  3.   

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/toolbar/toolbar_using.asp
      

  4.   

    to laiyiling:
       谢谢你的关注, 编译的时候出现如下问题
    C:\Documents and Settings\Administrator\桌面\WholeProject\MotleyFool_src\MotleyFool\MFToolbar.cpp(212) : error C2065: 'g_hinst' : undeclared identifier也就是说HINSTANCE这个参数我没有,,
    而且我得程序是一个DLL,
    所以我也的确不能生成这个东西
    希望您继续关注 
    谢谢
      

  5.   

    BTW:您的这篇文章我已经看过
    还是找不到我得解决方案..
      

  6.   

    // add the button for the toolbar to the window
    TBBUTTON Button;
    ZeroMemory((void*)&Button, sizeof(TBBUTTON));
    Button.idCommand = IDM_GETQUOTE;
    Button.fsState = TBSTATE_ENABLED;
    Button.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT;
    Button.dwData = 0;
    Button.iString = 0;
    Button.iBitmap = 0;
    int num=::SendMessage(m_hWnd, TB_INSERTBUTTON, 1, (LPARAM)&Button);
    TBBUTTON Button1;
    ZeroMemory((void*)&Button1, sizeof(TBBUTTON)); 
    Button1.idCommand=IDM_GETQUOTE;
    Button1.fsState = TBSTATE_ENABLED;
    Button1.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT;
    Button1.dwData = 0;
    Button1.iString = 2;
    Button1.iBitmap = 0;
    num=::SendMessage(m_hWnd, TB_INSERTBUTTON,2, (LPARAM)&Button1);
    TBBUTTON Button2;
    ZeroMemory((void*)&Button2, sizeof(TBBUTTON)); 
    Button2.idCommand=IDM_GETQUOTE;
    Button2.fsState = TBSTATE_ENABLED;
    Button2.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT;
    Button2.dwData = 0;
    Button2.iString = 3;
    Button2.iBitmap = 0;
    num=::SendMessage(m_hWnd, TB_INSERTBUTTON,3, (LPARAM)&Button2);/////////////////
    改成如下代码,试试TBBUTTON tbb[3]; 
    tbb[0].iBitmap = -1; 
        tbb[0].idCommand = IDM_GETQUOTE; 
        tbb[0].fsState = TBSTATE_ENABLED; 
        tbb[0].fsStyle = TBSTYLE_BUTTON; 
        tbb[0].dwData = 0; 
        tbb[0].iString = 0; 
     
        tbb[1].iBitmap = -1; 
        tbb[1].idCommand = IDM_GETQUOTE; 
        tbb[1].fsState = TBSTATE_ENABLED; 
        tbb[1].fsStyle = TBSTYLE_BUTTON; 
        tbb[1].dwData = 0; 
        tbb[1].iString = 0; 
     
        tbb[2].iBitmap = -1; 
        tbb[2].idCommand = IDM_GETQUOTE; 
        tbb[2].fsState = TBSTATE_ENABLED; 
        tbb[2].fsStyle = TBSTYLE_AUTOSIZE; 
        tbb[2].dwData = 0; 
        tbb[2].iString = 0; //(int) pszBuf2;
        
    SendMessage( TB_ADDBUTTONS, (WPARAM) NUM_BUTTONS, 
            (LPARAM) (LPTBBUTTON) &tbb);SendMessage(TB_AUTOSIZE, 0, 0); 
    ShowWindow(SW_SHOWNORMAL);
      

  7.   

    HINSTANCE参数直接用AfxGetInstanceHandle得到
      

  8.   

    Button.idCommand = IDM_GETQUOTE; Button1.idCommand=IDM_GETQUOTE; Button2.idCommand=IDM_GETQUOTE;
    Button.fsState = TBSTATE_ENABLED;
    Button.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT;
    这些代码都有问题的。
      

  9.   

    to laiyiling(陌生人) :
        我的程序不通过那个得到Instance
    程序代码参考地方如下
    http://www.codeproject.com/atl/ietoolbartutorial.asp
    http://blog.wdjl.net/post/422.htmlto yanedanny(守望者):
    既然你觉的有问题
    能不能帮我修改一下
    或者说明错误的缘由
    代码的编译是没有问题的