我发现成员m_spAmbientDispatch的值是0,也就是说这个接口指针没有创建。
我应该如何做?

解决方案 »

  1.   

    COleControl::GetAmbientProperty
    BOOL GetAmbientProperty( DISPID dwDispid, VARTYPE vtProp, void* pvProp );Return ValueNonzero if the ambient property is supported; otherwise 0.ParametersdwDispidThe dispatch ID of the desired ambient property.vtPropA variant type tag that specifies the type of the value to be returned in pvProp.pvPropA pointer to the address of the variable that will receive the property value or return value. The actual type of this pointer must match the type specified by vtProp.vtProp Type of pvProp 
    VT_BOOL BOOL* 
    VT_BSTR CString* 
    VT_I2 short* 
    VT_I4 long* 
    VT_R4 float* 
    VT_R8 double* 
    VT_CY CY* 
    VT_COLOR OLE_COLOR* 
    VT_DISPATCH LPDISPATCH* 
    VT_FONT LPFONTDISP* 
    ResCall this function to get the value of an ambient property of the container. If you use GetAmbientProperty to retrieve the ambient DisplayName and ScaleUnits properties, set vtProp to VT_BSTR and pvProp to CString*. If you are retrieving the ambient Font property, set vtProp to VT_FONT and pvProp to LPFONTDISP*.Note that functions have already been provided for common ambient properties, such as AmbientBackColor and AmbientFont.COleControl Overview |  Class Members |  Hierarchy ChartSee Also   COleControl::AmbientForeColor, COleControl::AmbientScaleUnits, COleControl::AmbientShowGrabHandles
      

  2.   

    GetAmbientProperty在SetClientSite后才有效
      

  3.   

    我用GetAmbientUserMode判断组件是运行时还是设计时,我看到的资料中都是在
    FinalConstruct中调用,可这时还没执行SetClientSite,我需要自己调用吗?还是其他什么方法?
      

  4.   

    自己调用?这些东西原则上是要container来调用的。你可以考虑改改程序的结构,在SetClientSite后来进行处理。