Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. C / C++ / MFC
  3. CDialogBar in CView

CDialogBar in CView

Scheduled Pinned Locked Moved C / C++ / MFC
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Erik
    wrote on last edited by
    #1

    I'm new to MFC, and I have a little problem. Is there a way to have a dialog bar on the top of a CView in an MDI app? I have the following code, but the dialog bar doesn't get drawn! It works great if I create the dialog bar on the MainFrm. int MyView::OnCreate(LPCREATESTRUCT lpCreateStruct) { m_pDlgBar = new CDialogBar(); if (!m_pDlgBar) return -1; m_pDlgBar->Create( this, IDD_DLGBAR, WS_CHILD | CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY, ID_DIALOGBAR); // I don't really know what this parameter does m_pDlgBar->ShowWindow(SW_SHOWNORMAL); if (CView::OnCreate(lpCreateStruct) == -1) return -1; } Any suggestions? Thanks In Advance. Erik

    J 1 Reply Last reply
    0
    • E Erik

      I'm new to MFC, and I have a little problem. Is there a way to have a dialog bar on the top of a CView in an MDI app? I have the following code, but the dialog bar doesn't get drawn! It works great if I create the dialog bar on the MainFrm. int MyView::OnCreate(LPCREATESTRUCT lpCreateStruct) { m_pDlgBar = new CDialogBar(); if (!m_pDlgBar) return -1; m_pDlgBar->Create( this, IDD_DLGBAR, WS_CHILD | CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY, ID_DIALOGBAR); // I don't really know what this parameter does m_pDlgBar->ShowWindow(SW_SHOWNORMAL); if (CView::OnCreate(lpCreateStruct) == -1) return -1; } Any suggestions? Thanks In Advance. Erik

      J Offline
      J Offline
      jschacker
      wrote on last edited by
      #2

      You want to add the toolbar (or dialog bar) to the frame insted of the view. You can catch the button messages in the doc, view, or frame. The code below will add a toolbar to the child frame: int CFrameClass::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1) return -1; //Create the toolbar. { EnableDocking(CBRS_ALIGN_ANY); if(!m_wndToolBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP, IDR_TOOLBAR_DEFECTVIEW) || !m_wndToolBar.LoadToolBar(IDR_TOOLBAR_DEFECTVIEW)) { TRACE0("Failed to create toolbar\n"); } else { // TODO: Remove this if you don't want tool tips or a resizeable toolbar m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); // TODO: Delete these lines if you don't want the toolbar to // be dockable m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar, AFX_IDW_DOCKBAR_RIGHT); } return 0; } Good luck, Jonathan Craig

      E 1 Reply Last reply
      0
      • J jschacker

        You want to add the toolbar (or dialog bar) to the frame insted of the view. You can catch the button messages in the doc, view, or frame. The code below will add a toolbar to the child frame: int CFrameClass::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1) return -1; //Create the toolbar. { EnableDocking(CBRS_ALIGN_ANY); if(!m_wndToolBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP, IDR_TOOLBAR_DEFECTVIEW) || !m_wndToolBar.LoadToolBar(IDR_TOOLBAR_DEFECTVIEW)) { TRACE0("Failed to create toolbar\n"); } else { // TODO: Remove this if you don't want tool tips or a resizeable toolbar m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); // TODO: Delete these lines if you don't want the toolbar to // be dockable m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar, AFX_IDW_DOCKBAR_RIGHT); } return 0; } Good luck, Jonathan Craig

        E Offline
        E Offline
        Erik
        wrote on last edited by
        #3

        Thanks! It worked, but how can I get a pointer to the child from the view? Thanks again! Erik

        J 1 Reply Last reply
        0
        • E Erik

          Thanks! It worked, but how can I get a pointer to the child from the view? Thanks again! Erik

          J Offline
          J Offline
          jschacker
          wrote on last edited by
          #4

          Look up this document in the MSDN or on Microsoft's web site; "Relationships Among MFC Objects". I keep this one tacked to the wall next to my computer. The function you want is CWnd::GetParentFrame(). Remember the view is a child of the frame. Good luck and happy hacking... Jonathan Craig

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups