Hi all,
I try to create my own ActiveX Control that is shown as a toolbar. For that I used the VS2010 Wizard to create a MFC ActiveX Control.
After the automatic generation of some classes I add the member
CToolBar m_toolbar
and the message handler for the "WM_CREATE" message which creates the method "OnCreate(...)".
int MyCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (COleControl::OnCreate(lpCreateStruct) == -1)
return -1;
m_toolbar.Create(this, WS_CHILD | WS_VISIBLE, IDC_MYCTRL_TOOLBAR);
m_toolbar.LoadBitmap(IDB_TEXTCOMPLEMENT_TOOLBAR);
m_toolbar.SetButtons(NULL, 5);
m_toolbar.SetButtonInfo(0, IDC_MYCTRL_NEW, TBBS_BUTTON, 0);
m_toolbar.SetButtonInfo(1, IDC_MYCTRL_DELETE, TBBS_BUTTON, 1);
m_toolbar.SetButtonInfo(2, IDC_MYCTRL_MODIFY, TBBS_BUTTON, 2);
m_toolbar.SetButtonInfo(3, IDC_MYCTRL_PREVIOUS, TBBS_BUTTON, 3);
m_toolbar.SetButtonInfo(4, IDC_MYCTRL_NEXT, TBBS_BUTTON, 4);
return 0;
}
IDB_TEXTCOMPLEMENT_TOOLBAR
is a bitmap for the 5 buttons.
I do not get any error during compilation or runtime. The Create() and all other function finishing successfully.
Now I create a MFC Project with a Doc/View Architecture (also with the VS 2010 Wizard). To this project I add my control with the class wizard which generates a wrapper.
In the View-class' "OnCreate()" function I do the following:
int CMFC_OCXView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
m_toolbarCtrl.Create(NULL, WS_CHILD|WS_VISIBLE, CRect(0, 0, 200, 200), this, 1278);
return 0;
}
where m_toolbarCtrl is a member of the type of my control's wrapper.
When I start the MFC application nothing is shown in the view.
I tried already to show other components on the view and they worked fine. E.g. I created some buttons in my ActiveX Control project the same way I did with the CToolBar.
I don't find the mistake why my toolbar is never shown.