用MFC写ActiveX时,用函数 BOOL AmbientUserMode();
返回TRUE为运行时,返回FALSE为设计时
如:
if(AmbientUserMode())
{
// 运行时
}
else
{
// 设计时
}
用ATL写ActiveX时,用函数 HRESULT GetAmbientUserMode(BOOL& bUserMode);
bUserMode为TRUE为运行时,为FALSE为设计时
如:
BOOL bUserMode;
GetAmbientUserMode(bUserMode);
if(bUserMode)
{
// 运行时
}
else
{
// 设计时
}
返回TRUE为运行时,返回FALSE为设计时
如:
if(AmbientUserMode())
{
// 运行时
}
else
{
// 设计时
}
用ATL写ActiveX时,用函数 HRESULT GetAmbientUserMode(BOOL& bUserMode);
bUserMode为TRUE为运行时,为FALSE为设计时
如:
BOOL bUserMode;
GetAmbientUserMode(bUserMode);
if(bUserMode)
{
// 运行时
}
else
{
// 设计时
}
本文介绍了如何在MFC和ATL中编写ActiveX组件时判断当前处于设计时还是运行时状态。通过使用特定函数,可以实现不同状态下的相应操作。

137

被折叠的 条评论
为什么被折叠?



