开发者

need help in making toolbar using MFC

i added this in my header file

CToolBar myBar; 
public: 
int OnCreate(LPCREATESTRUCT lpCreateStruct); 
void OnToolBarButton1(); 
void OnToolBarButton2();

and i added this in .cpp file

BEGIN_MESSAGE_MAP(CtoolbarfDlg, CDialog) 
    ON_WM_SYSCOMMAND() 
    ON_WM_PAINT() 
    ON_WM_QUERYDRAGICON() 
    ON_WM_CREATE() 
    ON_COMMAND(IDC_TBBUTTON1,OnToolBarButton1) 
    ON_COMMAND(IDC_TBBUTTON2,OnToolBarButton2)   
    //}}AFX_MSG_MAP 
END_MESSAGE_MAP() 

void CtoolbarfDlg::OnToolBarButton1() 
{ 
} 
void CtoolbarfDlg::OnToolBarButton2() 
{ 
} 
int CtoolbarfDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{ 
   if (CDialog::OnCreate(lpCreateStruct) == -1) 
       return -1; 

   if (!myBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP 
          | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC)) 
   { 
        TRACE0("Failed to create toolbar"); 
        return -1; // fail to create 
   } 

     myBar.LoadToolBar(IDR_TOOLBAR1); 
     myBar.EnableDocking(CBRS_ALIGN_ANY); 
     EnableDocking(CBRS_ALIGN_ANY); 
     DockControlBar(&myBar); 
}

i got these errors :( error C3861: 'EnableDocking': identifier not found error C3861: 'DockControlBar': identi开发者_开发问答fier not found


CDialog doesn't have the members EnableDocking or DockControlBar; those are members of CFrameWnd. MFC assumes you're going to put the toolbar into a frame window, Microsoft never provided a way to put them into a dialog. It can be done, but you're going to have to do all the hard work yourself.


I have found this article on code project to be useful in the past when I attempted to do the same. codeproject article. It also derives from CDialog - just as you're attempting to do in the provided sample.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜