LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
CComPtr<IWebBrowser2> browser;
CComPtr<IServiceProvider> isp;
HRESULT hr;
hr = m_spClientSite->QueryInterface(IID_IServiceProvider, reinterpret_cast<void **>(&isp));
hr = isp->QueryService(IID_IWebBrowserApp, IID_IWebBrowser2, reinterpret_cast<void **>(&browser));
CComVariant postData("userid=me;password=test");
char* postDataString = "userid=me;password=test";
int len = strlen(postDataString);
postData.vt = VT_ARRAY;
postData.parray = SafeArrayCreateVector(VT_UI1, 0, len);
void HUGEP* safeData;
hr = SafeArrayAccessData(postData.parray, &safeData);
memcpy(safeData, postDataString, len);
hr = SafeArrayUnaccessData(postData.parray);
CComVariant targetFrame(L"_blank");
CComVariant vNull;
CComVariant flags((int)navNoReadFromCache); // workaround
// Use a different window to navigate.
hr = browser->Navigate(L"http://www.yahoo.com", &vNull, &targetFrame, &postData, &vNull);
// Use the original window to navigate.
hr = browser->Navigate(L"http://www.yahoo.com", &vNull, &vNull, &vNull, &vNull);
// Use the workaround to navigate.
//hr = browser->Navigate(L"http://www.yahoo.com", &flags, &vNull, &vNull, &vNull);
return 0;
}