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

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

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.
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 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:

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);
// Setup the calendar control appearance and behavior:
return pWndCalendar->Create(WS_VISIBLE | WS_CHILD, rect, pParent, nID);
return FALSE;