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. General Programming
  3. C / C++ / MFC
  4. Tabs, toolbars, views, and MFC...

Tabs, toolbars, views, and MFC...

Scheduled Pinned Locked Moved C / C++ / MFC
c++comarchitecturetutorial
3 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.
  • D Offline
    D Offline
    dontknowitall
    wrote on last edited by
    #1

    I'm relatively new to the doc/view architecture. I have a splitter and two views (vertical splitter). One of the views is straight-forward stuff that MFC does already. The other view is where I want to: 1) Show a toolbar with buttons at the top. 2) Show a tab control just below that. 3) Show another view below that. The tab control should switch between 2 to 4 views and should not have any funky borders. That is, the view currently showing below the tab control should look seamless with the tab control. I've been everywhere on Google and CP. The closest thing I've found is somewhere between CTabView[^], CSDITrueColor[^], and CMDITabs[^]. However, none of these solutions includes a toolbar. I could roll my own control, but I've never done that and that still doesn't tell me how to manage a view inside a control (unless you count the SubView[^] article that doesn't make much sense to me). I should mention that I don't need icons on my tabs, but I do need a toolbar (which none of the above links have). And I'm looking to do this without buying some expensive package or using WTL.

    M 1 Reply Last reply
    0
    • D dontknowitall

      I'm relatively new to the doc/view architecture. I have a splitter and two views (vertical splitter). One of the views is straight-forward stuff that MFC does already. The other view is where I want to: 1) Show a toolbar with buttons at the top. 2) Show a tab control just below that. 3) Show another view below that. The tab control should switch between 2 to 4 views and should not have any funky borders. That is, the view currently showing below the tab control should look seamless with the tab control. I've been everywhere on Google and CP. The closest thing I've found is somewhere between CTabView[^], CSDITrueColor[^], and CMDITabs[^]. However, none of these solutions includes a toolbar. I could roll my own control, but I've never done that and that still doesn't tell me how to manage a view inside a control (unless you count the SubView[^] article that doesn't make much sense to me). I should mention that I don't need icons on my tabs, but I do need a toolbar (which none of the above links have). And I'm looking to do this without buying some expensive package or using WTL.

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      dontknowitall wrote:

      ...none of these solutions includes a toolbar...

      The trick to making it easy with MFC is to use a frame window as a "view" and use the actual CView-derived window as a client window of that frame. Toolbars work nicely with frame windows (CFrameWnd-derived windows). So, for your situation, the windows you'll need (from bottom upward in z-order) are (1) A CFrameWnd-derived window containing a toolbar (2) A CTabCtrl-derived window used as the "view" (client window) of the frame window (1) (3) CView-derived window(s) for each tab created as children of the frame window (1) but always resized in response to WM_SIZE to fit the "client area" of the tab control (CTabCtrl::AdjustRect() gives you the tab control's "client" rect). Used this way, there's no need to worry about the toolbar. It stays anchored to the frame (unless you make it dockable) and the client window (tab control) is automagically kept sized within the remaining client area of the frame window. You just need to keep track of each tab's window, as is necessary with tab controls anyway.

      dontknowitall wrote:

      The tab control should switch between 2 to 4 views and should not have any funky borders

      Not sure what you mean by "switch between 2 to 4 views " but you can control borders using the style flags used when creating the different windows. Hope this helps a bit, Mark

      D 1 Reply Last reply
      0
      • M Mark Salsbery

        dontknowitall wrote:

        ...none of these solutions includes a toolbar...

        The trick to making it easy with MFC is to use a frame window as a "view" and use the actual CView-derived window as a client window of that frame. Toolbars work nicely with frame windows (CFrameWnd-derived windows). So, for your situation, the windows you'll need (from bottom upward in z-order) are (1) A CFrameWnd-derived window containing a toolbar (2) A CTabCtrl-derived window used as the "view" (client window) of the frame window (1) (3) CView-derived window(s) for each tab created as children of the frame window (1) but always resized in response to WM_SIZE to fit the "client area" of the tab control (CTabCtrl::AdjustRect() gives you the tab control's "client" rect). Used this way, there's no need to worry about the toolbar. It stays anchored to the frame (unless you make it dockable) and the client window (tab control) is automagically kept sized within the remaining client area of the frame window. You just need to keep track of each tab's window, as is necessary with tab controls anyway.

        dontknowitall wrote:

        The tab control should switch between 2 to 4 views and should not have any funky borders

        Not sure what you mean by "switch between 2 to 4 views " but you can control borders using the style flags used when creating the different windows. Hope this helps a bit, Mark

        D Offline
        D Offline
        dontknowitall
        wrote on last edited by
        #3

        Thanks a ton. Your solution sounds a lot better (and simpler) than the solutions I was coming up with. Ignore the last bit you were confused over - it isn't important.

        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