用Delphi开发ActiveX应用于Web上。
用到的第三方控件是TMS的AdvStringGrid.问题就在这里:在AdvStringGrid显示的数据,需要超连结到对应的页面。在程序里已经写好,但在运行时,点击相应的数据,却不能连结的相应的页面。请问这是什么原因?是不是TMS还需要设置?谢谢!

解决方案 »

  1.   

    连接的网站需要登录,你跟踪看是否返回Http 500错误.在连接之前,先虚拟登录.int iAmount=0;
    DelTempFiles();
    ClearHistory();
    CInternetSession m_Session("DigitalTitan");
        CHttpConnection* pServer=NULL;
        CHttpFile* pFile=NULL;
    CHttpFile* pTaskFile=NULL;
        CString strServerName=strServerIP;
        INTERNET_PORT nPort=(INTERNET_PORT)atoi(strServerPort);
    CString strURL=strLoginAddress;
        try
        {
            pServer=m_Session.GetHttpConnection(strServerName,nPort);
    pFile=pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,strURL,NULL,1,NULL,NULL,INTERNET_FLAG_EXISTING_CONNECT);
            CString strHeaders=_T("Content-Type: application/x-www-form-urlencoded");
            CString strFormData;
    strFormData.Format("UserName=%s&Password=%s&action=submit",strLoginUserName,strLoginPassword);
    if(pFile->SendRequest(strHeaders,(LPVOID)(LPCTSTR)strFormData,strFormData.GetLength())==0)
    {
    //AfxMessageBox("网络异常...",MB_ICONINFORMATION);
    pFile->Close();
    delete pFile;
    pServer->Close();
    delete pServer;
    m_Session.Close();
    }
    else
    {
    pFile->Close();
    delete pFile;
    pServer->Close();
    delete pServer;

    pTaskFile=(CHttpFile*)m_Session.OpenURL(strLoginDataAddress);
    CString strBuf;
    CString strText;
    while(pTaskFile->ReadString(strText)) 
    {
    strBuf+="\r\n";
    strBuf+=strText;
    }
    pTaskFile->Close();
    delete pTaskFile;
    m_Session.Close();
    //AfxMessageBox(strBuf,MB_ICONINFORMATION);
    int iBegin,iEnd;
    iBegin=0;iEnd=0;
    CString strTemp;
    strTemp="";
    iBegin=strBuf.Find("待办方案",0);
    if(iBegin!=-1)
    {
    iEnd=strBuf.Find("更多方案",iBegin);
    strTemp=strBuf.Mid(iBegin+9,iEnd-(iBegin+9));
    int iResult=strTemp.Find("<td",0);
    if(iResult==-1)
    {
    //
    }
    else if(iResult<strTemp.GetLength())
    {
    while(iResult!=-1)
    {
    iAmount++;
    iResult=strTemp.Find("<td",iResult+3);
    }
    iAmount=iAmount-1;
    }
    }
    }
        }
        catch(CInternetException* e)
    {
    char strErrorBuf[255];
    e->GetErrorMessage(strErrorBuf,255,NULL);
    AfxMessageBox(strErrorBuf,MB_ICONINFORMATION);
    pFile=NULL;
    delete pFile;
    pTaskFile=NULL;
    delete pTaskFile;
    pServer=NULL;
    delete pServer;
    m_Session.Close();
    return 0;
    }
    return iAmount;
      

  2.   

    TO:aiirii
    路径是正确的,点是去根本没有任何的回应。
    是不是需要触发AdvStringGrid的某个属性或方法?
      

  3.   

    在连结时用绝对路径是可以的!
    可是我要连结不同的服务器,只能用相对路径!请帮帮我!部分代码:
    ............
    ............
    begin
      count := High(AValue);
      if count > AGrid.ColCount then
        count := AGrid.ColCount;  for c := 0 to count -1 do begin
        if c = 0 then
          AGrid.Cells[0, ARowIndex] := IntToStr(ARowIndex)
        else if c = 2 then begin
          AGrid.Cells[c, ARowIndex] := Format('<a href="%s=%s" target="_balnk">%</a>',
                                      ['http://10.90.50.190/public/enterpriseInfo.asp?entCode',AValue[0],Trim(AValue[1])])  //这样子联结是可以的**    AGrid.Cells[c, ARowIndex] := Format('<a href="%s=%s" target="_balnk">%</a>',
                                      ['../../public/enterpriseInfo.asp?ntCode',
    AValue[0],Trim(AValue[1])])  //这样子联结不可以,如何解决呢????????
    **
        end
        else if c = AGrid.ColCount -1 then begin
          dic := Dictionary.FindDictionary(C_Dictionary_audit_status);
    ...........
    ...........