CPBContext::CPBContext

Class CPBContext

CPBContext(PCTSTR pszName, BOOL blEnable = TRUE, ULONG ulExclude = PB_DEFAULT_EXCLUDE, INT iOption = PB_THREAD_DEFAULT)

CPBContext(ULONG ulNameStringId, HINSTANCE hModule = NULL, BOOL blEnable = TRUE, ULONG ulExclude = PB_DEFAULT_EXCLUDE, INT iOption = PB_THREAD_DEFAULT)

CPBContext(PB_CONTEXT* pcx, INT iOption = PB_MODULE_DEFAULT)

Parameters

ulNameStringIdString table resource identifier of string that will be used for the szName field of the underlying PB_CONTEXT structure.

hModuleHandle to module containing the string table into which ulNameStringId is an index.

iOptionFlag governing whether context is to be set as the thread or module default or neither. May be one of the following:

PB_THREAD_DEFAULT The constructor calls PBSetDefaultContext to set the context as the default for this thread.

PB_MODULE_DEFAULT The constructor calls PBSetDefaultContext to set the context as the default for the entire module.

PB_NO_DEFAULT The constructor does not call PBSetDefaultContext.

pcpPointer to PB_CONTEXT structure to manage.

The remaining parameters simply map one for one to the elements of the underlying PB_CONTEXT structure.

Note that the ulExclude parameter defaults to PB_DEFAULT_EXCLUDE which changes value in builds where PB_DEBUG_LEVEL is set to 1.

Remarks

The first two constructors initialize an internal PB_CONTEXT structure by calling PBSetContext while the third assumes an externally initialized structure and so does no initialization. All constructors then call PBSetDefaultContext to set the context as the thread or module default as per the flags specified for the iOption parameter. If the context is set as the thread or module default by the constructor then the destructor will call PBSetDefaultContext to undo this action; creating in effect a push/pop operation.

Passing NULL (the default value) for the hModule parameter results in an attempt to load the string from the calling process. If the string table resides in a DLL, the parameter must be non-NULL.