ALT编的一个控件,有一个属性Count。插入网页,代码为
<object classid="clsid:709DF088-BABF-4E2F-9E9C-593D090CE16C" width="800" height="600">
<param name="Count" value="5">
</object>
可是Param竟然没有作用! 请高手说说Param的原理。

解决方案 »

  1.   

    implement IPersistPropertyBag interface
      

  2.   

    A post found in newsgroup
    ==============================================================
    I've been spending some time trying to figure out
    how to code the "get custom property" from the value that
    I put in the PARAM tag in my HTML page.
    In fact it's really easy, the problem is that it was difficult to find
    a easy sample talking about MFC implementation and not ATL.
    SO...
    1. Create you OLE Control using Active X wizard
    2. Add a property using the GET/SET or the GlobalVariable
    3. if on step 2 you created using the GET/SET , add a global variable
    on your myolecontrolctl.cpp for example m_property
    4. Modify by hand the PropExchange method of your control
       using the PX_String, PX_Short, PX_....
       depending of the type of variable you're using
       you'll add the following
       if your variable is a CString
    void CActiveAdvCtrl::DoPropExchange(CPropExchange* pPX)
    {
    ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
    COleControl::DoPropExchange(pPX);
    if (pPX->GetVersion() == (DWORD)MAKELONG(_wVerMinor, _wVerMajor))
    {
    PX_String(pPX,_T("myproperty"),m_property);
    PX_String(pPX,_T("myproperty1"),m_property1);
    }
    }
    where m_property is the variable and myproperty is the external name you gave
    when you created the property.
    So when calling the page from the browser, the PARAM will be loaded
    to the different variables
    <OBJECT CLASSID="clsid:1AEDB630-4A08-4C22-BC74-0629C264B2CA"
        ALIGN="CENTER" WIDTH=100 HEIGHT=100 ID="DActiveX1">
        <PARAM NAME="myproperty" VALUE="123">
        <PARAM NAME="myproperty1" VALUE="555">
        <PARAM NAME="Enabled" VALUE=1>
        <PARAM NAME="_ExtentX" VALUE="0">
        <PARAM NAME="_ExtentY" VALUE="0">
        </OBJECT>
    Hope this help 
    Anthony.
    "Alexander Nickolov" <[email protected]> wrote in message news:<#4Ma63wmBHA.2084@tkmsftngp04>...
    > Did you implement IPersistPropertyBag on your control?
    > ============
    > Alexander Nickolov
    > Microsoft MVP [VC], MCSD
    > email: [email protected]
    > MVP VC FAQ: http://www.mvps.org/vcfaq
    > =========================
    > ============

    > "Anthony" <[email protected]> wrote in message 
    > news:[email protected]...
    > > Hi Everyone,
    > > 
    > > I created an active X in VC6 
    > > Everything seems to work perfectly if I call my methods and properties
    > > from a javascript. 
    > > BUT what ever I put in the PARAM tag are not initialized 
    > > my properties Get/Set are not called.. !
    > > 
    > > Any idea or anything I'm doing wrong?
    > > 
    > > Thanks for your help.
      

  3.   

    用ATL我实现不了啊,哪里有例子让我看看?
      

  4.   

    http://search.microsoft.com/gomsuri.asp?n=1&c=rp_Results&siteid=us&target=http://support.microsoft.com/support/kb/articles/Q197/9/21.asp
      

  5.   

    哎,这个例子用IPersistPropertyBag实现,怎么没用IPersistPropertyBagImpl实现?
      

  6.   

    masterz() si illustrate very clearly
      

  7.   

    哈哈哈,我找到解决的好例子了,共享共享:http://www.devx.com/upload/free/features/vcdj/2000/12dec00/ac0012/ac0012.asp