BOOL CWnd::CreateControl( LPCTSTR lpszClass, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE, BSTR bstrLicKey = NULL );
BOOL CWnd::CreateControl( REFCLSID clsid, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE, BSTR bstrLicKey = NULL );
Return Value
Nonzero if successful; otherwise 0.
Parameters
lpszClass
This string may contain the OLE "short name" (ProgID) for the class, e.g., "CIRC3.Circ3Ctrl.1". The name needs to match the same name registered by the control. Alternatively, the string may contain the string form of a CLSID, contained in braces, e.g., "{9DBAFCCF-592F-101B-85CE-00608CEC297B}". In either case, CreateControl converts the string to the corresponding class ID.
lpszWindowName
A pointer to the text to be displayed in the control. Sets the value of the control's Caption or Text property (if any). If NULL, the control's Caption or Text property is not changed.
dwStyle
Windows styles. The available styles are listed under Remarks.
rect
Specifies the control’s size and position. It can be either a CRect object or a RECT structure.
pParentWnd
Specifies the control’s parent window. It must not be NULL.
nID
Specifies the control’s ID.
pPersist
A pointer to a CFile containing the persistent state for the control. The default value is NULL, indicating that the control initializes itself without restoring its state from any persistent storage. If not NULL, it should be a pointer to a CFile-derived object which contains the control’s persistent data, in the form of either a stream or a storage. This data could have been saved in a previous activation of the client. The CFile can contain other data, but must have its read-write pointer set to the first byte of persistent data at the time of the call to CreateControl.
bStorage
Indicates whether the data in pPersist should be interpreted as IStorage or IStream data. If the data in pPersist is a storage, bStorage should be TRUE. If the data in pPersist is a stream, bStorage should be FALSE. The default value is FALSE.
bstrLicKey
Optional license key data. This data is needed only for creating controls that require a run-time license key. If the control supports licensing, you must provide a license key for the creation of the control to succeed. The default value is NULL.
clsid
The unique class ID of the control.
Remarks
Use this member function to create an OLE control that will be represented in the MFC program by a CWnd object. CreateControl is a direct analog of the CWnd::Create function, which creates the window for a CWnd. CreateControl creates an OLE control instead of an ordinary window.
Only a subset of the Windows dwStyle flags are supported for CreateControl:
CWnd Overview | Class Members | Hierarchy Chart
See Also In Visual C++ Programmer’s Guide: ActiveX Control Topics