CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2004
    Posts
    62

    CToolbar in a Formview

    Hi,

    I have formviews with their own toolbars.

    The problem now is that I cannot get a messagehandler for the toolbar in the formviews but I have to make it in the Mainfrm or the icons won't look enabled.

    I have to put the messagehandler into the formview where it belongs and not into the mainfrm where there is already another one for its own toolbar.

    Can someone help with this ?

  2. #2
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: CToolbar in a Formview

    Firstly, why would you create tool bar in a view. Usually frame windows have build-in functionality to handle toolbars and routing command messages.
    If you place a toolbar in a view, you may encounter UI updating problems, if update handlers for given command ID are placed in other windows. In addition, changing default routing by overriding OnCmdMsg, can be a culprit. That may prevent from enabling certain buttons.

    Views are hosted in frames and MFC routing mechanism ensures proper UI updating. Is your application MDI or SDI?
    I would suggest posting entire project here so we can see what is a causing a problem.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  3. #3
    Join Date
    Apr 2004
    Posts
    62

    Re: CToolbar in a Formview

    Quote Originally Posted by JohnCz
    Firstly, why would you create tool bar in a view.
    Well, its not a normal view but a formview and to use a toolbar there is the most elegant way to solve what I want.

    Is your application MDI or SDI?
    My application is a SDI.

    Usually frame windows have build-in functionality to handle toolbars and routing command messages.
    But I need the formview to handle its own toolbars.

    If you place a toolbar in a view, you may encounter UI updating problems, if update handlers for given command ID are placed in other windows.
    Thanks for the advice, I'll make sure that each ID is only used once.

    I would suggest posting entire project here so we can see what is a causing a problem.
    The project is unfortunately huge so I cannot post it but what I want is actually quite simple. I just have a SDI MFC App with a formview and many dialogs that are switched by the big toolbar in mainframe (which works nice) but each of those CDialogs has toolbars too.

    And I cannot get those toolbars to work.

    They don't enable (unless I put the handler in mainfrm where it doesn't belong) and they cannot be clicked to call functions in the dialog.

    I hope that makes it clearer.

  4. #4
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: CToolbar in a Formview

    Quote Originally Posted by Zaph-0
    Well, its not a normal view but a formview
    A formview (of class CFormView) is also a very "normal" view as well as the others derived from CView.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  5. #5
    Join Date
    Apr 2004
    Posts
    62

    Re: CToolbar in a Formview

    Quote Originally Posted by ovidiucucu
    A formview (of class CFormView) is also a very "normal" view as well as the others derived from CView.
    And how does that help me with my problem ?

  6. #6
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: CToolbar in a Formview

    Quote Originally Posted by Zaph-0
    And how does that help me with my problem ? .
    Well in a first place, it tells you are trying to go against a current.
    Quote Originally Posted by Zaph-0
    But I need the formview to handle its own toolbars.
    Toolbars should work if there is no conflict.
    As I have said, without seeing your code it is virtually impossible to help you. If you have multiple message (or UI update) handlers for the same command ID you may experience problems you have described.
    Quote Originally Posted by Zaph-0
    Well, its not a normal view but a formview and to use a toolbar there is the most elegant way to solve what I want.
    "elegant way" is very subjective. Consider using one common toolbar and specific one for a given view.
    Quote Originally Posted by Zaph-0
    The project is unfortunately huge so I cannot post it but what I want is actually quite simple.
    How big is your project? You are supposed to post only a source code, resources and project file. If you do not want to do it, create small test project that illustrate a problem and post it.
    Quote Originally Posted by Zaph-0
    I just have a SDI MFC App with a formview and many dialogs that are switched by the big toolbar in mainframe (which works nice) but each of those CDialogs has toolbars too.
    There you go; you have mentioned CFormView as the culprit. As it turns you are using dialogs (CDialog derived classes).
    Since dialogs are not a part of the Doc/view architecture, they are not included in MFC message routing, hence you cannot expect automatic update.
    Quote Originally Posted by Zaph-0
    I hope that makes it clearer.
    Not really since we have just encountered new element in your post that has not been mentioned before. I know I maybe sound (look) annoying but from my experience, in cases like that working on the project together saves time and makes thread considerably shorter.
    There may be no more such details but on the other hand, even insignificant in your opinion, may be very significant.

    For example:
    How dialogs are displayed? Are they modal or modeless? Are they children of any windows or just pop up dialogs. If popup are they owned by any window?
    Last edited by JohnCz; December 28th, 2007 at 10:47 AM.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  7. #7
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: CToolbar in a Formview

    Another thing that is very significant and I just remembered.
    How do you create views? Is every view properly initialized and activated? Is every view added to a document’s views list?
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured