我有一个CHtmlView,我想要获取在这个view里面浏览网页时,点击submit按钮产生的post数据,应该怎么办呢~~~~重谢....

解决方案 »

  1.   

    void CMyHtmlView::OnBeforeNavigate2(LPCTSTR lpszURL, DWORD nFlags, LPCTSTR lpszTargetFrameName, CByteArray& baPostedData, LPCTSTR lpszHeaders, BOOL* pbCancel) 
    {/////////////////////////////////////////////////////////////////
    // Are we on the initial navigation thrown by the 
    // OnInitialUpdate?  If not, process the POST.
    // Build a message box from the submitted data
    CString strMessage, strBytes;

    strMessage = _T("");

    // Get general info from the submitted form
    strMessage.Format(
    _T("Browse To:\n%s\n\nFlags: %d\nTarget Frame:\n%s\n\nHeaders:\n%s\n"),
    lpszURL, nFlags, lpszTargetFrameName, lpszHeaders);

    // Get the POST data
    // This is where this sample gets semi-cool
    strBytes = _T("\n\nPosted Bytes :\n\n");
    if (baPostedData.GetSize())
    {
    // This is a kludgy copy, but you get the idea
    for(int i = 0;i < baPostedData.GetSize();i++)
    {
    strBytes += (char)baPostedData[i];
    }
    // Let's split the posted data into separate lines
    // for the messagebox
    strBytes.Replace("&","\n");
    }

    // Once the data is copied, we can do anything we 
    // want with it, but I'll just display the silly
    // MessageBox
    AfxMessageBox((strMessage + strBytes),MB_OK);
    }