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.
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:
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.
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.
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.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.