我做的一个控件把它嵌入到网页中了,那这个控件里的函数的参数设置怎么通过此网页提交给WEBSERVER,我的WEBSERVER是一个C语言写的程序,WEBSERVER又是怎样把他接收到的参数传回给这个控件的?能提供一些这方面的摸板吗?我没用过ASP,不知道怎么网页中怎么处理控件的函数和参数的,举个例子好吗?

解决方案 »

  1.   

    如果是控件内提交参数可以调用Microsoft Win32 Internet Functions,MSDN里面的相关代码很多。
    如果需要使用页面提交空间参数则在页面中使用javascript或vbscript将空间中的参数读出后在用一个form把数据提交上去。开发WEBSERVER需要了解HTTP协议该协议由元信息头和数据两部分组成,具体可以参照相关的RFC文档。我只能给你提示实现原理,关于具体的开发还需要你参考一些相关文档,他们在MSDN里都有详细说明。
      

  2.   

    Initializing from HTML
    In the same way that you can initialize a Visual Basic ActiveX control, you can initialize an ATL control using the <PARAM> tags. When you include the <PARAM> tags as children of the <OBJECT> tags, Internet Explorer sends the data that you specify to the control when the control is first instantiated. For example, to specify an initial value for the Message property, you can insert a <PARAM> tag between the opening and closing object tags for the control. This HTML code looks like this:<OBJECT ID="AtlCtrl"
            CLASSID="CLSID:638B718E-AEF1-11D2-A9BA-444553540001">
            <PARAM NAME="Message" VALUE="Hello, There!">
    </OBJECT> 
    This data is stored in a property bag object maintained by Internet Explorer. Internet Explorer will query the control for the IPersistPropertyBag interface. If the control returns a pointer to this interface, Internet Explorer calls the Load method of IPersistPropertyBag to instruct the control to load initialization data. When calling the Load method, Internet Explorer passes a pointer to IPropertyBag interface of its property bag object. The control then calls the Read method of the passed in IPropertyBag interface to retrieve the initialization data.To make this work correctly in the AtlCtrl control, you need to follow a few steps. As usual, ATL provides a default implementation of IPersistPropertyBag named IPersistPropertyBagImpl. Add this template class to the end of the inheritance list. After adding the template class, the declaration of CAtlCtrl should look like this:class ATL_NO_VTABLE CAtlCtrl : 
       
       
       public IPersistPropertyBagImpl<CAtlCtrl>
    {
       
       
    }; 
    Add the IPersistPropertyBag interface to the COM map. After adding this interface, the COM map should look like this:BEGIN_COM_MAP(CAtlCtrl)
       
       
       COM_INTERFACE_ENTRY(IPersistPropertyBag)
    END_COM_MAP() 
    Implement the Load method, as shown in the next code fragment. You can add this method to the bottom of the class declaration. With Load, you can retrieve the initialization data that you specified on the Web page by using <PARAM> tags.STDMETHOD(Load)(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog)
    {
       CComVariant vtVal;   HRESULT hr = pPropBag->Read(L"Message", &vtVal, pErrorLog);   if (SUCCEEDED(hr) && VT_BSTR == vtVal.vt)
       {
          m_bstrMessage = vtVal.bstrVal;
          m_fDirty = TRUE;
       }   return hr;

    In the Load method, we first have to declare a variable of CComVariant. The CComVariant variable is similar to CComBSTR in that it's a wrapper class that provides greater functionality than the data type it contains. In this case, a CComVariant wraps a VARIANT type. This variable is needed to retrieve the values of the parameters specified using <PARAM> tags. (If you need more information about CComVariant, refer to MSDN.)Next we call the Read method of the IPropertyBag interface that was passed into the Load method. The first parameter specifies the name of the property that we want to retrieve. This parameter tacks on the 'L' specifier that converts the ANSI string to an OLE string. Here we're reading the Message property from the property bag. The second parameter is a VARIANT that will contain the value of the Message property when this method returns. The third parameter is a pointer to IErrorLog interface that the Read method uses to report errors. This parameter can be NULL if we're not interested in error information. In this case, we simply pass the pointer to IErrorLog interface that we received from the argument of the Load method.Then we check the return value of the Read method. If the call to Read succeeded and the type of the VARIANT that was returned is a BSTR (as indicated by vtVal.vt being equal to VT_BSTR), we set the m_bstrMessage data member to the BSTR value that is contained in the vtVal variable. Now, when the OnDraw method is initially called, the value that we specified for the Message property will be displayed on the Web page. In addition to setting the m_bstrMessage data member, we also set the m_fDirty data member to TRUE. The m_fDirty data member indicates that the property has been changed. Here's how m_fDirty is defined in the CAtlCtrl class:BOOL m_fDirty; 
    We should also initialize m_fDirty in the CAtlCtrl constructor. The constructor will look like this:CAtlCtrl() : m_bstrMessage(bstrDefaultMsg),
                 m_fDirty(FALSE)
    {
      

  3.   

    <OBJECT id="cmd1" style="Z-INDEX: 101; LEFT: 24px; POSITION: absolute; TOP: 40px" classid="clsid:D7053240-CE69-11CD-A777-00DD01143C57" VIEWASTEXT>
    <PARAM NAME="ForeColor" VALUE="2147483666">
    <PARAM NAME="BackColor" VALUE="2147483663">
    <PARAM NAME="VariousPropertyBits" VALUE="27">
    <PARAM NAME="Caption" VALUE="Click Me">
    <PARAM NAME="PicturePosition" VALUE="458753">
    <PARAM NAME="Size" VALUE="2540;847">
    <PARAM NAME="MousePointer" VALUE="0">
    <PARAM NAME="Accelerator" VALUE="0">
    <PARAM NAME="TakeFocusOnClick" VALUE="-1">
    <PARAM NAME="FontName" VALUE="Times New Roman">
    <PARAM NAME="FontEffects" VALUE="1073741824">
    <PARAM NAME="FontHeight" VALUE="240">
    <PARAM NAME="FontOffset" VALUE="0">
    <PARAM NAME="FontCharSet" VALUE="0">
    <PARAM NAME="FontPitchAndFamily" VALUE="34">
    <PARAM NAME="ParagraphAlign" VALUE="3">
    <PARAM NAME="FontWeight" VALUE="400">
    </OBJECT>
      

  4.   

    CInternetSession m_Session("DigitalTitan");
        CHttpConnection* pServer=NULL;
        CHttpFile* pFile=NULL;
        CString strServerName=m_ServerName;
        INTERNET_PORT nPort=(INTERNET_PORT)atoi(m_ServerPort);
        CString strURL=m_DesignFile;
        try
        {

            pServer=m_Session.GetHttpConnection(strServerName,nPort);
    pFile=pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,strURL,NULL,1,NULL,NULL,INTERNET_FLAG_EXISTING_CONNECT);

    CString strBoundary="-----------------------------7d33a816d302b6";
            pFile->AddRequestHeaders("Content-Type: multipart/form-data, boundary="+strBoundary);
            pFile->AddRequestHeaders("Accept: */*");

    char* pBuf=new char[1024*1000];
    pFile->SendRequest(NULL,0,(LPVOID)pBuf,strlen(pBuf));

    pFile->Close();
    pServer->Close();
        }
        catch(CInternetException * e)
        {
    AfxMessageBox("...",MB_ICONINFORMATION);
        };
        delete pFile;
        delete pServer;
        m_Session.Close();