Hello- I'm Using a WinForms (.NET) control within an MFC 9.0 application.
Problem: My WM_COMMAND message handler "OnStartTestMode()" is not getting called in my "CWinFormsControl<n:c>"-derived MFC class.
A "pWnd->PostMessage(WM_COMMAND, IDM_START_CMD);" is posting the WM_COMMAND message to the child control "NAnalogMeter" from the view class, in response to a menu item selection.
See the Winforms-derived control class "NAnalogMeter" below, along with the command message declaration for message map: (note: replacing the intermediate "CEnhGauge" class directly with "CWinFormsControl<>" in the code does not resolve the issue) --
----------------------------------------------------------------
NAnalogMeter.h header file:
#include "afxwinforms.h"
class CEnhGauge : public CWinFormsControl<AquaControls::AquaGauge>
{
};
class NAnalogMeter : public CEnhGauge
{
public:
NAnalogMeter (const CRect& r, CWnd *pParent );
public:
virtual ~NAnalogMeter();
protected:
afx_msg void OnPaint();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnStartTestMode();
DECLARE_MESSAGE_MAP()
};
------------------------------------------------------------------
And its implementation file, NAnalogMeter.cpp:
BEGIN_MESSAGE_MAP(NAnalogMeter, CEnhGauge)
ON_WM_PAINT()
ON_COMMAND(IDM_START_TEST_MODE, OnStartTestMode)
END_MESSAGE_MAP()
NAnalogMeter::NAnalogMeter (const CRect& r, CWnd *pParent )
{
BOOL bCreatedOK = this->CreateManagedControl(WS_VISIBLE | WS_CHILD
}
void NAnalogMeter::OnStartTestMode ( )
{
}
----------------------------------------------------------------
I've used Spy++ to monitor the messages to the child Winforms control in my MFC app -- I could see the WM_COMMAND message appear in the Spy++ message log for the child window, but alas my "OnStartTestMode" handler is never getting invoked.
Thank you very much for any help in resolving this.
Tom
=======================================================