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. How do you use combo boxes with a Doc View SDI Application

How do you use combo boxes with a Doc View SDI Application

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
5 Posts 3 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
    D_code_writer
    wrote on last edited by
    #1

    Hey Guys, I know the following might sound like a silly question, but I have a project which is a Doc-View SDI MFC project. Any way a requirement has emerged which means I need to use combo boxes in the actual view window. Does anyone have any experience at using something like this, In particular can you use a combo box in the view class of an SDI app? If so how do you incorporate it. Looking forward to your reply. Best Regards Danny Nowlan

    C M 2 Replies Last reply
    0
    • D D_code_writer

      Hey Guys, I know the following might sound like a silly question, but I have a project which is a Doc-View SDI MFC project. Any way a requirement has emerged which means I need to use combo boxes in the actual view window. Does anyone have any experience at using something like this, In particular can you use a combo box in the view class of an SDI app? If so how do you incorporate it. Looking forward to your reply. Best Regards Danny Nowlan

      C Offline
      C Offline
      cje
      wrote on last edited by
      #2

      have you looked at CFormView?

      cje

      1 Reply Last reply
      0
      • D D_code_writer

        Hey Guys, I know the following might sound like a silly question, but I have a project which is a Doc-View SDI MFC project. Any way a requirement has emerged which means I need to use combo boxes in the actual view window. Does anyone have any experience at using something like this, In particular can you use a combo box in the view class of an SDI app? If so how do you incorporate it. Looking forward to your reply. Best Regards Danny Nowlan

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

        Since controls are just windows you can use them as a child window on any window. An easy way is to add a CComboBox member to your window class:

        CComboBox m_MyCombobox;

        Add a WM_CREATE handler to the window class. In the handler call Create() for the combo box.

        int CMyWindow::OnCreate(LPCREATESTRUCT lpCreateStruct)
        {
        if (CWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

        m\_MyCombobox.Create(CBS\_DROPDOWN, CRect(10,10,100,15), this, IDC\_MYCOMBOBOX);
        
        ...possibly populate the combo box here using AddString() etc ...
        
        return 0;
        

        }

        This example places a 100 wide by 15 high CBS_DROPDOWN style combo box at 10,10 in the window. You could handle WM_SIZE in the window and move the combo box in response to the user resizing the window. Hope this helps get you started! Mark

        D 1 Reply Last reply
        0
        • M Mark Salsbery

          Since controls are just windows you can use them as a child window on any window. An easy way is to add a CComboBox member to your window class:

          CComboBox m_MyCombobox;

          Add a WM_CREATE handler to the window class. In the handler call Create() for the combo box.

          int CMyWindow::OnCreate(LPCREATESTRUCT lpCreateStruct)
          {
          if (CWnd::OnCreate(lpCreateStruct) == -1)
          return -1;

          m\_MyCombobox.Create(CBS\_DROPDOWN, CRect(10,10,100,15), this, IDC\_MYCOMBOBOX);
          
          ...possibly populate the combo box here using AddString() etc ...
          
          return 0;
          

          }

          This example places a 100 wide by 15 high CBS_DROPDOWN style combo box at 10,10 in the window. You could handle WM_SIZE in the window and move the combo box in response to the user resizing the window. Hope this helps get you started! Mark

          D Offline
          D Offline
          D_code_writer
          wrote on last edited by
          #4

          Hey Mark, Thanks for that mate. I implemented it and I had no errors, however the Combo box still isn't showing up. I also created a IDC_MYCOMBOX resource with the type set to child. Any ideas? For what its worth I am dealing with a view that is derived from CView as opposed to CFormView. Is that part of my problem? Thanks again to everyone for all their help. Danny

          M 1 Reply Last reply
          0
          • D D_code_writer

            Hey Mark, Thanks for that mate. I implemented it and I had no errors, however the Combo box still isn't showing up. I also created a IDC_MYCOMBOX resource with the type set to child. Any ideas? For what its worth I am dealing with a view that is derived from CView as opposed to CFormView. Is that part of my problem? Thanks again to everyone for all their help. Danny

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

            Danny Nowlan wrote:

            I implemented it and I had no errors, however the Combo box still isn't showing up.

            Sorry :) The limited example code didn't have enough style flags. try

            m_MyCombobox.Create(CBS_DROPDOWN|WS_VISIBLE|WS_CHILD, CRect(10,10,100,15), this, IDC_MYCOMBOBOX);

            Calling MyCombobox.ShowWindow(SW_SHOW) would make it show as well. Useful if you want to create it hidden and show it later I suppose. Mark

            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