CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2008
    Location
    India
    Posts
    780

    Problem in using toolbar.

    Hi all,

    i have SDI type application,and split it in two columns.
    for one column i m using a Treeview and for another one i m using a FormView.

    in toolbar two buttons functions override in Treeview class because they are related to treeview here i m inserting,deleting the tree items.

    when i focus on formview and than click on those toolbar buttons than they are not working ,while when i have focus on TreeView and than click on those buttons than those are working perfectly.

    please tell me how can i use as general.

    if possible please explain me with example.

    thanks in advance.
    IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Problem in using toolbar.

    1. Define "not working".
    2. Where (in what class) are the message handlers for all these buttons that are "not working"?
    Victor Nijegorodov

  3. #3
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Problem in using toolbar.

    in toolbar two buttons functions override in Treeview class because they are related to treeview here i m inserting,deleting the tree items.
    What is that suppose to mean? That you have handlers for the button commands in the tree view class?

    When you say "not working" you mean they are not called, or that they don't do what you expected?
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  4. #4
    Join Date
    Jan 2008
    Location
    India
    Posts
    780

    Re: Problem in using toolbar.

    I mean to say,in my toolbar i have 5 buttons,where out of five i have add message handler of two buttons in Treeview class.

    because these buttons used for inserting items in tree or deleteing items of tree.

    When i have focus on Formview and than click on these two buttons than these not called.

    so please tell me what can i do.
    IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Problem in using toolbar.

    I wonder why do you ever "click on these two buttons" being in FormView while "these buttons used for inserting items in tree or deleteing items of tree" and therefore you "have add message handler of two buttons in Treeview class"
    The FormView should nothnig know about any other view, so your design with toolbar buttons message handler is correct: while FormView is active they have to be either disabled or hidden.
    Victor Nijegorodov

  6. #6
    Join Date
    Apr 2009
    Posts
    57

    Re: Problem in using toolbar.

    What he means is that only certain button are active depending on what view was last selected.


    I had the same problem when creating split views.



    What you need to do is call the buttons from the CMainFrame and then execute the functions in the appropriate view classes. You will need to have pointers to the view classes.

  7. #7
    Join Date
    Jan 2008
    Location
    India
    Posts
    780

    Re: Problem in using toolbar.

    In those functions i m using thread that is used in Treeview class and i dont knoe how can i use it from class pointer in mainframe.
    IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

  8. #8
    Join Date
    Apr 2009
    Posts
    57

    Re: Problem in using toolbar.

    Quote Originally Posted by vjshankwar View Post
    In those functions i m using thread that is used in Treeview class and i dont knoe how can i use it from class pointer in mainframe.
    Code:
     if(!this->m_wndSplitter.CreateStatic(this,1,2)){
      return FALSE;
     };
     
     if(!this->m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CLeftFormView),CSize(350,100), pContext)||
        !this->m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CMfcieView),CSize(100,100),pContext))
     {
    
      this->m_wndSplitter.DestroyWindow();
      return FALSE; 
     }
     //return CFrameWnd::OnCreateClient(lpcs, pContext);
     //Setup Pointers
     this->m_pHTMLView =      (CMfcieView*)m_wndSplitter.GetPane(0,1);
     this->m_pCLeftFormView = (CLeftFormView*)m_wndSplitter.GetPane(0,0);
     
     return TRUE;

    I copied the code from my app, but you should have the idea.

    Create two member pointer variables to the view classes in CMainFrame.

    Now from CMainFrame you should be able to call any member functions of either View Classes and the buttons will always be active.

    I could be wrong, but I believe you can even set the active view.

  9. #9
    Join Date
    Jan 2002
    Location
    Houston, TX
    Posts
    1,421

    Re: Problem in using toolbar.

    Since you have an SDI application, you can put the message handler for the button in the doc class. Then there are a couple of alternatives... if you want to handle everthing in the doc (not the best idea perhaps), you may need to get pointer to the views (see GetFirstViewPostion, etc).

    Alternatively, you could call UpdateAllViews from within the doc class. This calls OnUpdate in each view, and in the view's OnUpdate handler, do whatever is needed. This is the "MFC" way of doing things.

    You might check out "Command Routing in MFC" from MSDN.

    Hope that helps.
    Be sure to rate those who help!
    -------------------------------------------------------------
    Karl - WK5M
    PP-ASEL-IA (N43CS)
    PGP Key: 0xDB02E193
    PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

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