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. Question on CMFCToolBarComboBoxButton -- MDI program.

Question on CMFCToolBarComboBoxButton -- MDI program.

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 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.
  • S Offline
    S Offline
    SAMZCN
    wrote on last edited by
    #1

    Working on an MDI program. There is a toolbar ,in which there is an CMFCToolBarComboBoxButton item, in one of the views. User need to open multiple views of the same type. The question is the combox item will change together when user changed it in one view, even through the combox is in different views. What's wrong? Is it designed by Microsoft? :doh: :confused:

    N 1 Reply Last reply
    0
    • S SAMZCN

      Working on an MDI program. There is a toolbar ,in which there is an CMFCToolBarComboBoxButton item, in one of the views. User need to open multiple views of the same type. The question is the combox item will change together when user changed it in one view, even through the combox is in different views. What's wrong? Is it designed by Microsoft? :doh: :confused:

      N Offline
      N Offline
      Niklas L
      wrote on last edited by
      #2

      Since the button will have the same ID in all views, and you probably have hooked up event handlers for it, they will behave as one. It's the same code running for all, and also, you have the same document. To avoid this, you could change the control ID for each new view created. Takes a bit of house keeping to keep within allowed ranges and maybe managing reuse of ID's. Are you really sure you have to display the same view more than once? It also sounds as instead of opening a new view, you should create a new document with the same view type.

      home

      S 1 Reply Last reply
      0
      • N Niklas L

        Since the button will have the same ID in all views, and you probably have hooked up event handlers for it, they will behave as one. It's the same code running for all, and also, you have the same document. To avoid this, you could change the control ID for each new view created. Takes a bit of house keeping to keep within allowed ranges and maybe managing reuse of ID's. Are you really sure you have to display the same view more than once? It also sounds as instead of opening a new view, you should create a new document with the same view type.

        home

        S Offline
        S Offline
        SAMZCN
        wrote on last edited by
        #3

        Thanks for your reply. Yes. It is same views of same document. In the program, I really need multiple views of same type in one document. Simply, the program is a Single Docment Multiple Views one. More than one view of same type are displayed to view different data from data controller with SQL query support. But I find if I use normal CCombox control other than CMFCToolBarComboBoxButton, it works well. I guess it may be a question with CMFCToolBarComboBoxButton. Any more inputs?

        N 1 Reply Last reply
        0
        • S SAMZCN

          Thanks for your reply. Yes. It is same views of same document. In the program, I really need multiple views of same type in one document. Simply, the program is a Single Docment Multiple Views one. More than one view of same type are displayed to view different data from data controller with SQL query support. But I find if I use normal CCombox control other than CMFCToolBarComboBoxButton, it works well. I guess it may be a question with CMFCToolBarComboBoxButton. Any more inputs?

          N Offline
          N Offline
          Niklas L
          wrote on last edited by
          #4

          In case of the classic CComboBox implementation, the toolbar does not deal with the control at all. It just reserves some space and paints it in-place. You explicitly manipulate the control when some event is triggered in you program. With the new MFC classes, this is done for you. I think the reason is the customization possibilities, where in theory you can put the same button/control more than once in a toolbar.

          home

          S 1 Reply Last reply
          0
          • N Niklas L

            In case of the classic CComboBox implementation, the toolbar does not deal with the control at all. It just reserves some space and paints it in-place. You explicitly manipulate the control when some event is triggered in you program. With the new MFC classes, this is done for you. I think the reason is the customization possibilities, where in theory you can put the same button/control more than once in a toolbar.

            home

            S Offline
            S Offline
            SAMZCN
            wrote on last edited by
            #5

            ooh...okey. Now it seems a problem for me. :( Originally, I think the view instance is not the same one in spite of same type of view. So the CMFCToolBarComboBoxButton control object is also created onece for each view. Only the ID is the same. The click/change message for the control may be routed to different target view. I think only the control box which is clicked actually should changed. Whatever, any way to make it happen? I really donot want to use CComboBox control to implement. it is not a easy way to do. In that case, you need to control the the box by yourself completely, including its possition and behave.

            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