Export (0) Print
Expand All
TRY
Expand Minimize

AfxOleLockControl

Locks the class factory of the specified control so that dynamically created data associated with the control remains in memory.

BOOL AFXAPI AfxOleLockControl(
   REFCLSID clsid 
);
BOOL AFXAPI AfxOleLockControl(
   LPCTSTR lpszProgID 
);

Parameters

clsid
The unique class ID of the control.
lpszProgID
The unique program ID of the control.

Return Value

Nonzero if the class factory of the control was successfully locked; otherwise 0.

Remarks

This can significantly speed up display of the controls. For example, once you create a control in a dialog box and lock the control with AfxOleLockControl, you do not need to create and kill it again every time the dialog is shown or destroyed. If the user opens and closes a dialog box repeatedly, locking your controls can significantly enhance performance. When you are ready to destroy the control, call AfxOleUnlockControl.

Example

BOOL CDlgApp::InitInstance()
{
...   
   // Starts and locks controls (Microsoft FlexGrid Control) class factory. 
   // Control will remain in memory for lifetime of
   // application or until AfxOleUnlockControl() is called.
   
   AfxOleLockControl("MSFlexGridLib.MSFlexGrid.1");
...
   return TRUE;
}

Requirements

Header: <afxwin.h>

See Also

MFC Macros and Globals | AfxOleUnlockControl

Show:
© 2014 Microsoft