<FORM action="" method="POST" name="Test"> void CTestHTMLView::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. if( m_bProcessNavigate ) { // 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); // Let's NOT Navigate! //*pbCancel = TRUE; } CHtmlView::OnBeforeNavigate2(lpszURL, nFlags, lpszTargetFrameName, baPostedData, lpszHeaders, pbCancel); } form http://www.codeproject.com/miscctrl/process_htmlform.asp
楼上的老兄,你说是吗?
我写过现成的代码,不过使用了很多自定义的宏,读起在不太方便。
如果需要,我整理一份给你。
谢了!!!!
void CTestHTMLView::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.
if( m_bProcessNavigate )
{
// 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); // Let's NOT Navigate!
//*pbCancel = TRUE;
} CHtmlView::OnBeforeNavigate2(lpszURL, nFlags,
lpszTargetFrameName, baPostedData,
lpszHeaders, pbCancel);
}
form
http://www.codeproject.com/miscctrl/process_htmlform.asp