Article ID: 201879
Article Last Modified on 11/21/2006
bool Ambient...([in/out]type* name, [in]bool bInit = false);
//*****************************************************
// Method definitions for your control's .h file.
//*****************************************************
bool AmbientAppearance(short* pAppearance, bool bInit = false);
bool AmbientBackColor(OLE_COLOR* pBackColor, bool bInit = false);
bool AmbientDisplayName(CString* pDisplayName, bool bInit = false);
bool AmbientFont(LPFONTDISP pDisp, bool bInit = false);
bool AmbientForeColor(OLE_COLOR* pForeColor, bool bInit = false);
bool AmbientLocaleID(LCID* plcid, bool bInit = false);
bool AmbientScaleUnits(CString* pStrScaleUnits, bool bInit = false);
bool AmbientTextAlign(short* pITextAlign, bool bInit = false);
bool AmbientUserMode(BOOL* pbUserMode, bool bInit = false);
bool AmbientUIDead(BOOL* pbUIDead, bool bInit = false);
bool AmbientShowGrabHandles(BOOL* pbShowGrab, bool bInit = false);
bool AmbientShowHatching(BOOL* pbShowHatch, bool bInit = false);
//*****************************************************
// Method implementations for your control's .cpp file.
//*****************************************************
//***** AmbientAppearance *****
bool CMyOleControl::AmbientAppearance(short* pAppearance,
bool bInit)
{
ASSERT (pAppearance);
if (!GetAmbientProperty(DISPID_AMBIENT_APPEARANCE,
VT_I2,
pAppearance)) {
if (bInit) *pAppearance = 0;
return false;
}else{
return true;
}
}
//***** AmbientBackColor *****
bool CMyOleControl::AmbientBackColor(OLE_COLOR* pBackColor,
bool bInit)
{
ASSERT (pBackColor);
if (!GetAmbientProperty(DISPID_AMBIENT_BACKCOLOR,
VT_I4,
pBackColor)) {
if (bInit) *pBackColor = GetSysColor(COLOR_WINDOW);
return false;
}else{
return true;
}
}
//***** AmbientDisplayName *****
bool CMyOleControl::AmbientDisplayName(CString* pDisplayName,
bool bInit)
{
ASSERT (pDisplayName);
if (!GetAmbientProperty(DISPID_AMBIENT_DISPLAYNAME,
VT_BSTR,
pDisplayName)) {
if (bInit) *pDisplayName = "CMyOleControl";
return false;
}else
return true;
}
//***** AmbientFont *****
bool CMyOleControl::AmbientFont(LPFONTDISP pDisp,
bool bInit)
{
// pDisp must be NULL.
ASSERT (!pDisp);
// Note: Caller MUST Release the font!
if (!GetAmbientProperty(DISPID_AMBIENT_FONT,
VT_DISPATCH,
&pDisp)) {
if (bInit) pDisp = NULL;
return false;
}else{
return true;
}
}
//***** AmbientForeColor *****
bool CMyOleControl::AmbientForeColor(OLE_COLOR* pForeColor,
bool bInit)
{
ASSERT (pForeColor);
if (!GetAmbientProperty(DISPID_AMBIENT_FORECOLOR,
VT_I4,
pForeColor)) {
if (bInit) *pForeColor = GetSysColor(COLOR_WINDOWTEXT);
return false;
}else{
return true;
}
}
//***** AmbientLocaleID *****
bool CMyOleControl::AmbientLocaleID(LCID* plcid, bool bInit)
{
ASSERT (plcid);
if (!GetAmbientProperty(DISPID_AMBIENT_LOCALEID,
VT_I4,
plcid)) {
if (bInit) *plcid = 0;
return false;
}else{
return true;
}
}
//***** AmbientScaleUnits *****
bool CMyOleControl::AmbientScaleUnits(CString* pStrScaleUnits,
bool bInit)
{
ASSERT (pStrScaleUnits);
if (!GetAmbientProperty(DISPID_AMBIENT_SCALEUNITS,
VT_BSTR,
pStrScaleUnits)) {
if (bInit) *pStrScaleUnits = "";
return false;
}else{
return true;
}
}
//***** AmbientTextAlign *****
bool CMyOleControl::AmbientTextAlign(short* piTextAlign, bool bInit)
{
ASSERT (piTextAlign);
if (!GetAmbientProperty(DISPID_AMBIENT_TEXTALIGN,
VT_I2,
piTextAlign)) {
if (bInit) *piTextAlign = 0;
return false;
}else{
return true;
}
}
//***** AmbientUserMode *****
bool CMyOleControl::AmbientUserMode(BOOL* pbUserMode, bool bInit)
{
ASSERT(pbUserMode);
if (!GetAmbientProperty(DISPID_AMBIENT_USERMODE,
VT_BOOL,
pbUserMode)) {
if (bInit) *pbUserMode = TRUE;
return false;
}else{
return true;
}
}
//***** AmbientUIDead *****
bool MyOleControl::AmbientUIDead(BOOL* pbUIDead, bool bInit)
{
ASSERT(pbUIDead);
if (!GetAmbientProperty(DISPID_AMBIENT_UIDEAD,
VT_BOOL,
pbUIDead)) {
if (bInit) *pbUIDead = FALSE;
return false;
}else{
return true;
}
}
//***** AmbientShowGrabHandles *****
bool CMyOleControl::AmbientShowGrabHandles(BOOL* pbShowGrab, bool bInit)
{
ASSERT(pbShowGrab);
if (!GetAmbientProperty(DISPID_AMBIENT_SHOWGRABHANDLES,
VT_BOOL,
pbShowGrab)) {
if (bInit) *pbShowGrab = TRUE;
return false;
}else{
return true;
}
}
//***** AmbientShowHatching *****
bool CMyOleControl::AmbientShowHatching(BOOL* pbShowHatch, bool bInit)
{
ASSERT(pbShowHatch);
if (!GetAmbientProperty(DISPID_AMBIENT_SHOWHATCHING,
VT_BOOL,
pbShowHatch)) {
if (bInit) *pbShowHatch = TRUE;
return false;
}else{
return true;
}
}
Keywords: kbcontainer kbctrl kbhowto KB201879