Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
MFC
TRY
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

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  
);

clsid

The unique class ID of the control.

lpszProgID

The unique program ID of the control.

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

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.

// Starts and locks control's (Microsoft Calendar) class factory.  
// Control will remain in memory for lifetime of 
// application or until AfxOleUnlockControl() is called.

AfxOleLockControl(_T("MSCAL.Calendar"));

Header: <afxwin.h>

Community Additions

ADD
Show:
© 2015 Microsoft