我的程序是一个单文档的Program,我选定了CEditView作为其基类,我希望能够象vcIDE中的某些List Box(如WizardBar)那样?
 欢迎各位高手赐教
很久没有来问问题了,我的分数很多的,绝对不会吝惜的啦:)

解决方案 »

  1.   

    那不是一般的工具栏,
    一般用dialogbar来实现,向操作diaolog一样
    到微软网站上有关于dialogbar的详细使用说明
      

  2.   

    http://www.codeguru.com/toolbar/VCMenu.shtml
    http://www.codeguru.com/toolbar/VSOMenu.shtml
    http://www.codeguru.com/toolbar/demo_toolbar_d.shtml
    http://www.codeguru.com/toolbar/combo_in_flatbar.shtml
      

  3.   

    我保存了ms的下载
    具体如下:
    Change the base class from CDialog to CDialogBar in the class declaration. Don't forget to also change the base class in BEGIN_MESSAGE_MAP in the .cpp file. 
    Change the constructor in both the .h and the .cpp files. Also make the change to the DoDataExchange(). Below are three items to change. Change the following from 
          CMyDlgBar (CWnd* pParent = NULL);   // standard constructor      CMyDlgBar:: CMyDlgBar (CWnd* pParent /*=NULL*/)
             : CDialog(CMyDlgBar::IDD, pParent)
          {
             ...      void CMyDlgBar::DoDataExchange(CDataExchange* pDX)
          {
             CDialog::DoDataExchange(pDX);
             ...
    to the following: 
          CMyDlgBar ();   // standard constructor      CMyDlgBar:: CMyDlgBar ()
          {
             ...      void CMyDlgBar::DoDataExchange(CDataExchange* pDX)
          {
             CDialogBar::DoDataExchange(pDX);
             ...
    The key to the transformation is the conversion of the virtual OnInitDialog() member function to the WM_INITDIALOG message mapped method by changing the OnInitDialog method and by adding the ON_MESSAGE() handler. You may not have an override of OnInitDialog(). If not, add one before proceeding. 
    Remove "virtual BOOL OnInitDialog();" from the class header and add "afx_msg LONG OnInitDialog ( UINT, LONG );" in its place. For example: 
          class CMyDlgBar : public CDialogBar
          {
             ...
          // Implementation
          protected:         // Generated message map functions
             //{{AFX_MSG(CMyDlgBar)
             virtual BOOL OnInitDialog();                // <-Remove this line.
             //}}AFX_MSG         afx_msg LONG OnInitDialog ( UINT, LONG );   // <-Add this line.
             DECLARE_MESSAGE_MAP()
          };
    Now, in the class implementation section, make the corresponding changes. 
    Add "ON_MESSAGE(WM_INITDIALOG, OnInitDialog );" to the message map in the .CPP implementation file. For example: 
          BEGIN_MESSAGE_MAP(CMyDlgBar, CDialogBar)         //{{AFX_MSG_MAP(CMyDlgBar)
             ...
             //}}AFX_MSG_MAP
             ON_MESSAGE(WM_INITDIALOG, OnInitDialog )    // <-- Add this line.
          END_MESSAGE_MAP()
    Now, convert the virtual OnInitDialog() to the message-mapped OnInitDialog(). 
    Make the OnInitDialog() conversion as follows: 
       Change the following:      BOOL CMyDlgBar::OnInitDialog()
          {
             CDialog::OnInitDialog();   // <-- Replace this line:
                ...
    to the following: 
          LONG CMyDlgBar::OnInitDialog ( UINT wParam, LONG lParam)
          {
                           // <-- with these lines. -->         if ( !HandleInitDialog(wParam, lParam) || !UpdateData(FALSE))
             {
                TRACE0("Warning: UpdateData failed during dialog init.\n");
                return FALSE;
             }
             ...
    The CDialogBar class doesn't have a virtual OnInitDialog(), and therefore calling one does not work. UpdateData is called to subclass or initialize any child controls. 
    Make sure the dialog box resource styles to the following: 
    Style: Child 
    Boarder: None 
    Visible: Unchecked 
    At this point, everything has been reconnected to make the transformation from a CDialog class to a CDialogBar class work correctly. Now, create and use it. 
    Add an instance of the derived CDialogBar to the CframeWnd-derived class (normally called CMainFrame). For example: 
          class CMainFrame : public CFrameWnd
          {
              ...
              CMyDlgBar m_myDlgBar;
              ...
          };
    Call the create method for the m_myDlgBar variable in the CFrameWnd::OnCreate() method similar to the following: 
          int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
          {
             ...
             if (!m_myDlgBar.Create(this, IDD_DLGBAR1, CBRS_LEFT,
                IDD_DLGBAR1))
             {
                TRACE0("Failed to create dialog bar\n");
                return -1;      // fail to create
             }
             ...
          }
    Finally, if you want to support dynamic docking and resizing of the CDialogBar, add the following lines to the end of CMainFrame::OnCreate(): 
          int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
          {
             ...
             m_myDlgBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
                CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
             m_myDlgBar.EnableDocking(CBRS_ALIGN_ANY);
             DockControlBar(&m_myDlgBar);         return 0;
         
     }
      

  4.   

    // 实例50  位图按钮
    // 创建一个Dialog,style设为child,去掉Titlebar,四个按钮style设为Owner Draw 和Bitmap
    // 加载位图资源,设置的ID要与按钮"Caption"中的一致,例如按钮的Caption为:IDB_BITMAP1,相应的位图名为"IDB_BITMAP1U"
    class CMainFrame : public CFrameWnd
    {
    public:
    CDialogBar m_DlgBar;
    CBitmapButton m_MyBitmapButton1;
    CBitmapButton m_MyBitmapButton2;
    CBitmapButton m_MyBitmapButton3;
    CBitmapButton m_MyBitmapButton4;
    }
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
    return -1;
    m_DlgBar.Create(this, IDD_MYDIALOG, CBRS_TOP, AFX_IDW_DIALOGBAR); // 把其余的代码删掉
    m_MyBitmapButton1.AutoLoad(IDC_BUTTON1, &m_DlgBar);
    m_MyBitmapButton2.AutoLoad(IDC_BUTTON2, &m_DlgBar);
    m_MyBitmapButton3.AutoLoad(IDC_BUTTON3, &m_DlgBar);
    m_MyBitmapButton4.AutoLoad(IDC_BUTTON4, &m_DlgBar);
    return 0;
    }
      

  5.   

    楼上的这位兄弟,能不能说的详细一点啊
    微软的msdn也看了不少,可是好象也没有讲具体怎么来实现,当然,他们提到这个过程将是非常复杂的事情了
    我觉得,如果弄通了也没有那么恐怖的所谓会者不难,可惜的是我现在是难者不会啊
    继续等待各位高手的赐教啊
    学无止境!
      

  6.   

    就是创建一个对话框,但要把它的基类变为CdialogBar
    然后作响应得改变,不难,你读一读我粘贴的代码,公分9步,
      

  7.   

    然后你自己把CBitmapButton ,改成CListBox就行了呀,真的很简单的。
    这100分我要定了。
      

  8.   

    to lxg_dut:
    正在实验中.........
      

  9.   

    to lxg_dut:
    Change the base class from CDialog to CDialogBar in the class declaration
    这是说必须自己先插入一个资源Dialog么?
    注意我的可停靠工具栏已经是mfc自动给好了的
    我现在只是想在其中再加个List Box 而已,我可不想另外做出来一个toolbar
      

  10.   

    是的将dialog改为CDialogBar后,会自动停靠的
      

  11.   

    to lxg_dut:
    好的
    我正在实验中
    先谢谢这位 lxg_dut朋友了
      

  12.   

    呵呵我成功了
    ,给分了lxg_dut!分不是重要的
    再次致谢这位lxg_dut朋友