CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    May 2002
    Posts
    5

    Unhappy Toolbar In CView

    I have a CToolBar inside a CView dirived class. It works pretty well, you can click on the buttons and all and the corrent messages are sent. But there is a problem. If the view that the ToolBar is in is not in focus, the ToolBar is disabled. You have to click on the view that the ToolBar is in to make it re-enable itself.

    Please help me on this, Thanks.

  2. #2
    Join Date
    May 2002
    Location
    Poland
    Posts
    48
    Update commands are by default sent to the active view only. Try adding the following to CMainFrame to change this routing:

    Code:
    BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
    {
        CDocument *pDoc = GetActiveDocument();
        if(pDoc)
        {
    	POSITION pos = pDoc->GetFirstViewPosition();
    	CView *pView = NULL;
    	while(pView = pDoc->GetNextView(pos))
    	{
    	    if(pView != GetActiveView()
    		&& pView->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
    		return TRUE;
    	}
        }
    
        return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
    }
    regards,
    MiMec

  3. #3
    Join Date
    May 2002
    Posts
    5
    Thanks man, that worked great. Man, you guys here at CC rock.

  4. #4
    Join Date
    Aug 2012
    Posts
    9

    Unhappy Re: Toolbar In CView

    Dear Yonax,
    how u managed to get CToolBar inside a CView dirived class.I m also trying to do ir, can you please share the code to achieve it.

    Thanx in advance.

  5. #5
    Join Date
    Jan 2003
    Location
    Wallisellen (Zürich), Switzerland
    Posts
    16,177

    Re: Toolbar In CView

    Why do you need to have a toolbar in the View? Toolbars are designed to be inside the Frame windows!
    Victor Nijegorodov

  6. #6
    Join Date
    Aug 2012
    Posts
    9

    Re: Toolbar In CView

    I am using splitted views and I want to keep options specific to a view in a toolbar assigned to it.

  7. #7
    Join Date
    Jan 2003
    Location
    Wallisellen (Zürich), Switzerland
    Posts
    16,177

    Re: Toolbar In CView

    But you could just update an already used toolbar or replace toolbars while toggling between the splitter panes!
    Victor Nijegorodov

  8. #8
    GCDEF is offline Elite Member Power Poster GCDEF has a reputation beyond repute (3000+) GCDEF has a reputation beyond repute (3000+) GCDEF has a reputation beyond repute (3000+) GCDEF has a reputation beyond repute (3000+) GCDEF has a reputation beyond repute (3000+) GCDEF has a reputation beyond repute (3000+) GCDEF has a reputation beyond repute (3000+) GCDEF has a reputation beyond repute (3000+) GCDEF has a reputation beyond repute (3000+) GCDEF has a reputation beyond repute (3000+) GCDEF has a reputation beyond repute (3000+)
    Join Date
    Nov 2003
    Posts
    11,562

    Re: Toolbar In CView

    Quote Originally Posted by vinay kaul View Post
    Dear Yonax,
    how u managed to get CToolBar inside a CView dirived class.I m also trying to do ir, can you please share the code to achieve it.

    Thanx in advance.
    Yonax hasn't posted here in over 10 years.

+ Reply to Thread

Bookmarks

Posting Permissions

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



HTML5 Development Center

Click Here to Expand Forum to Full Width