CMFCToolBarEditBoxButton problem
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12

Thread: CMFCToolBarEditBoxButton problem

  1. #1
    Join Date
    May 2013
    Posts
    24

    CMFCToolBarEditBoxButton problem

    I am having a problem with the CMFCToolBarEditBox control. I have added the below code:

    MyMFCToolBar.h

    Code:
    #pragma once
    #include "resource.h"
    
    class CMyMFCToolBar : public CMFCToolBar
    {
    public:
    	CMyMFCToolBar(){};
    	~CMyMFCToolBar(){};
    
    protected:
    	void OnReset()
    	{
    		CMFCToolBarEditBoxButton TBEButton(ID_EDIT_BOX, GetCmdMgr()->GetCmdImage(ID_EDIT_BOX));
    
    		ReplaceButton(ID_EDIT_BOX, TBEButton);
    	};
    };
    and replaced the class of "wnd_ToolBar" with "CMyMFCToolBar". It is a standard MFC SDI project using the CMFC controls.
    I have also added a button to the tool bar resource(IDR_MAINFRAME_256) with the resource ID, "ID_EDIT_BOX".
    The problem is that the first time it runs the edit box is visible but inactive. Second time is fine. Also if the tool bar is reset the edit box becomes inactive until the app is rerun.
    I assume it is some problem to do with the previous state of the tool bar being stored in the registry, but I at a loss as to how to correct the behaviour. Help appreciated. p.s. I have Googled the problem but nothing so far fixes this issue.

  2. #2
    Join Date
    May 2013
    Posts
    24

    Re: CMFCToolBarEditBoxButton problem

    No ideas at all? Has anyone tried my code and had the same result?

  3. #3
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,352

    Re: CMFCToolBarEditBoxButton problem

    If you would like someone would test your code then you should have posted the complete test project, not just a peace of non-compilable code.
    Victor Nijegorodov

  4. #4
    Join Date
    May 2013
    Posts
    24

    Re: CMFCToolBarEditBoxButton problem

    Thank you Victor for the suggestion. Here is the requested project:MFCTBEditBox_1.zip

  5. #5
    Join Date
    May 2013
    Posts
    24

    Re: CMFCToolBarEditBoxButton problem

    Here is some alternate code that adds two CEdit controls to the CMFCToolBar. It is clumsy because you have to use dummy icons to preallocate the space:
    Attached Files Attached Files

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,067

    Re: CMFCToolBarEditBoxButton problem

    Have you stepped through the code when it does work and when it doesn't to see what the difference is?

    I saw the behavior too, but now it shows up every time. How do you reset it so it doesn't show up?

  7. #7
    Join Date
    May 2013
    Posts
    24

    Re: CMFCToolBarEditBoxButton problem

    If you go to the "toolbar options" button at the end of the toolbar and click it, you get "Add or Remove buttons" move your mouse to it, you'll see "standard" and "customize...", choose "standard"->"reset toolbar" and you will see the edit box but it won't be active.

    Not sure where to step through as a lot of the code is background.

  8. #8
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,067

    Re: CMFCToolBarEditBoxButton problem

    Start with where you're creating the edit box. Debugging is the best option you have. I would think if you'd used it on April 13th, you'd have your answer by now.

  9. #9
    Join Date
    May 2013
    Posts
    24

    Re: CMFCToolBarEditBoxButton problem

    I suspect that the CMFCToolBarEditBoxButton is being overwritten with the data from just the button in the registry.

  10. #10
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,352

    Re: CMFCToolBarEditBoxButton problem

    Quote Originally Posted by moffy View Post
    I suspect that the CMFCToolBarEditBoxButton is being overwritten with the data from just the button in the registry.
    But why don't you want to debug your code to confirm or refute this suspicion?
    Victor Nijegorodov

  11. #11
    Join Date
    May 2013
    Posts
    24

    Re: CMFCToolBarEditBoxButton problem

    Thank you both for your assistance and advice. I lost my projects recently and the only one not backed up was this one, so my postings inadvertently provided a backup.
    Debugging the CMFCToolBar/EditBoxButton can be quite time consuming. I already have a posted solution "MFCEditBox_2.zip" that works. It's not elegant but workable and could be used by anyone else that encounters the same problem.
    Anyway thanks again.

  12. #12
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,352

    Re: CMFCToolBarEditBoxButton problem

    But have you tested your "workaround" well enough to be sure it will work by all the possible conditions by all the possible users?
    Victor Nijegorodov

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center