BCGSuite for MFC
virtual BOOL CBCGPVisualContainer::OnCreateCustomControl ( CBCGPWndHostVisualObject pVisualObject,
CWnd *  pWnd,
const CRect &  rect,
int  nID,
CWnd *  pParent 
)
inlinevirtual

Called by the framework to create a Visual Container custom control.

Parameters
pVisualObjectThe visual object which hosts a custom control.
pWndThe custom control window.
rectThe custom control bounding rectangle.
nIDThe custom control identifier specified in Visual Designer (see below).
pParentThe parent window.
Returns
TRUE if it succeeds, FALSE if it fails.

This method should be implemented in CBCGPVisualContainer - derived classes.

Please make the following steps to add your own custom control to the Visual Container:

  • In the Visual Designer application (see https://bcgsoft.com/Support/DevArea/VisualDesigner) add a new "Custom Window" object.
  • Specify the object ID in the "Properties" window.
  • Specify your window class name in "C++ Class Name" property. Please note that your class should have DECLARE_SERIAL, otherwise the framework is not able to create this object!
  • Override OnCreateCustomControl method in your CBCGPVisualContainer - derived class. Please take a look at example below.

The following example demonstrates how to add a custom calendar control to the Visual Designer:

Copy
BOOL CMyContainer::OnCreateCustomControl(CBCGPWndHostVisualObject* pVisualObject, CWnd* pWnd, const CRect& rect, int nID, CWnd* pParent)
{
switch (nID)
{
case 101: // This value was specified in "ID" property.
{
// "CBCGPCalendar" was specified in ""C++ Class Name" property.
CBCGPCalendar* pWndCalendar = DYNAMIC_DOWNCAST(CBCGPCalendar, pWnd);
ASSERT_VALID(pWndCalendar);
// Setup the calendar control appearance and behavior:
pWndCalendar->SetCustomColors(&calendarColors);
pWndCalendar->EnableMutipleSelection();
pWndCalendar->SetSingleMonthMode();
pWndCalendar->EnableWeekNumbers();
return pWndCalendar->Create(WS_VISIBLE | WS_CHILD, rect, pParent, nID);
}
break;
}
return FALSE;
}