|
Hello
this auto-fill method is compatible with multi-frame web site ?
regards
antonello
|
|
|
|
|
Hello,
I have problem to install the .dll.
I use Vista and IE7... work fine ?
antonello
|
|
|
|
|
After installed this dll, the hyperlinks on the webpage cannot be openned by the IE7. But if you right click the hyperlink and select "open in a new window", it works.
Fifth
|
|
|
|
|
The code works great on 99% of the machines that use our application. But on these machines at a customer site(XP IE 7) had a Visual Studio 2005 Just-In-Time Debugger error with a Win32 Exception in iexplore.exe. I cannot imagine why it would crash with that. The user is not even right-clicking, but it is apparent they have no other plug-ins on their IE. Our plug-in should only run when a substring of our website shows. Can anyone give me a clue as to why???
Thanks,
Brad
STDMETHODIMP CAUD::SetSite(IUnknown *pUnkSite)
{
sprintf(g_szMsg, "Begin CAUD::SetSite\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
if (!pUnkSite)
{
ATLTRACE(_T("SetSite(): pUnkSite is NULL\n"));
sprintf(g_szMsg, "SetSite():pUnkSite is NULL\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
}
else
{
// Query pUnkSite for the IWebBrowser2 interface.
m_pWebBrowser = pUnkSite;
if (m_pWebBrowser)
{
// Connect to the browser in order to handle events.
HRESULT hr = ManageBrowserConnection(ConnType_Advise);
if (FAILED(hr))
{
sprintf(g_szMsg, "Failure sinking events from IWebBrowser2\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
ATLTRACE(_T("Failure sinking events from IWebBrowser2\n"));
}
}
else
{
ATLTRACE(_T("QI for IWebBrowser2 failed\n"));
sprintf(g_szMsg, "QI for IWebBrowser2 failed\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
}
}
sprintf(g_szMsg, "End CAUD::SetSite\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
return S_OK;
}
STDMETHODIMP CAUD::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags,
DISPPARAMS* pDispParams, VARIANT* pvarResult,
EXCEPINFO* pExcepInfo, UINT* puArgErr)
{
sprintf(g_szMsg, "Begin CAUD::Invoke() with dispid of %ld\n", dispidMember);
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
if (!pDispParams)
{
sprintf(g_szMsg, "No pDispParams set, returning.\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
return E_INVALIDARG;
}
switch (dispidMember)
{
case DISPID_NEWWINDOW2:
ATLTRACE(_T("(%ld) DISPID_NEWWINDOW2\n"), ::GetCurrentThreadId());
sprintf(g_szMsg, "(%ld) DISPID_NEWWINDOW2\n", ::GetCurrentThreadId());
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
if (m_bBlockNewWindow && IsEnabled())
{
ATLTRACE(_T("(%ld) Blocked a popup\n"), ::GetCurrentThreadId());
sprintf(g_szMsg, "Blocked a popup. (DISPID_NEWWINDOW2)\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
// Set the cancel flag
pDispParams->rgvarg[0].pvarVal->vt = VT_BOOL;
pDispParams->rgvarg[0].pvarVal->boolVal = VARIANT_TRUE;
}
m_bBlockNewWindow = TRUE; // Reset
break;
case DISPID_BEFORENAVIGATE2:
ATLTRACE(_T("(%ld) DISPID_BEFORENAVIGATE2\n"), ::GetCurrentThreadId());
BSTR szUrl;
szUrl = (*pDispParams).rgvarg[5].pvarVal->bstrVal;
sprintf(g_szMsg, "(%ld)DISPID_BEFORENAVIGATE2.URL=%s\n", ::GetCurrentThreadId(), szUrl);
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
break;
case DISPID_NAVIGATECOMPLETE2:
ATLTRACE(_T("(%ld) DISPID_NAVIGATECOMPLETE2\n"), ::GetCurrentThreadId());
sprintf(g_szMsg, "(%ld)DISPID_NAVIGATECOMPLETE2.(Block NewWindow)\n", ::GetCurrentThreadId());
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
m_bBlockNewWindow = TRUE; // Reset
if (!m_pWBDisp)
{
m_pWBDisp = pDispParams->rgvarg[1].pdispVal;
}
break;
case DISPID_STATUSTEXTCHANGE:
break;
case DISPID_PROGRESSCHANGE:
break;
case DISPID_DOCUMENTCOMPLETE:
sprintf(g_szMsg, "case DISPID_DOCUMENTCOMPLETE: in Invoke().\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
ATLTRACE(_T("(%ld) DISPID_DOCUMENTCOMPLETE\n"), ::GetCurrentThreadId());
if (m_pWBDisp &&
m_pWBDisp == pDispParams->rgvarg[1].pdispVal)
{
ATLTRACE(_T("(%ld) DISPID_DOCUMENTCOMPLETE (final)\n"), ::GetCurrentThreadId());
sprintf(g_szMsg, "(%ld)DISPID_DOCUMENTCOMPLETE: (final).\n", ::GetCurrentThreadId());
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
m_pWBDisp = NULL;
CComPtr<IDispatch> pHtmlDocDispatch;
HRESULT hr = m_pWebBrowser->get_Document(&pHtmlDocDispatch);
// RWC experimenting m_pWebBrowser->put_StatusBar(
if (SUCCEEDED(hr) && pHtmlDocDispatch)
{
sprintf(g_szMsg, "get_Document() succeeded in Invoke().\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
// If this is not an HTML document (e.g., it's a Word doc or a PDF), don't sink.
CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> pHtmlDoc(pHtmlDocDispatch);
if (pHtmlDoc)
{
sprintf(g_szMsg, "Detected an HTML doc in Invoke().\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
// Get pointers to default interfaces
CComQIPtr<IOleObject, &IID_IOleObject> spOleObject(pHtmlDocDispatch);
if (spOleObject)
{
CComPtr<IOleClientSite> spClientSite;
hr = spOleObject->GetClientSite(&spClientSite);
if (SUCCEEDED(hr) && spClientSite)
{
m_spDefaultDocHostUIHandler = spClientSite;
m_spDefaultOleCommandTarget = spClientSite;
}
}
// Set this class to be the IDocHostUIHandler
CComQIPtr<ICustomDoc, &IID_ICustomDoc> spCustomDoc(pHtmlDocDispatch);
if (spCustomDoc)
{
sprintf(g_szMsg, "Get custom doc interface for the doc, in Invoke(). Calling SetUIHandler()\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
spCustomDoc->SetUIHandler(this);
}
}
}
}
break;
case DISPID_DOWNLOADBEGIN:
sprintf(g_szMsg, "(%ld)DISPID_DOWNLOADBEGIN()\n", ::GetCurrentThreadId());
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
ATLTRACE(_T("(%ld) DISPID_DOWNLOADBEGIN\n"), ::GetCurrentThreadId());
break;
case DISPID_DOWNLOADCOMPLETE:
sprintf(g_szMsg, "(%ld)DISPID_DOWNLOADCOMPLETE()\n", ::GetCurrentThreadId());
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
ATLTRACE(_T("(%ld) DISPID_DOWNLOADCOMPLETE\n"), ::GetCurrentThreadId());
break;
case DISPID_COMMANDSTATECHANGE:
sprintf(g_szMsg, "(%ld)DISPID_COMMANDSTATECHANGE()\n", ::GetCurrentThreadId());
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
break;
case DISPID_TITLECHANGE:
sprintf(g_szMsg, "(%ld)DISPID_TITLECHANGE()\n", ::GetCurrentThreadId());
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
break;
case DISPID_PROPERTYCHANGE:
sprintf(g_szMsg, "(%ld)DISPID_PROPERTYCHANGE()\n", ::GetCurrentThreadId());
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
break;
case DISPID_ONQUIT:
sprintf(g_szMsg, "case DISPID_ONQUIT: in Invoke().\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
ATLTRACE(_T("(%ld) DISPID_ONQUIT\n"), ::GetCurrentThreadId());
ManageBrowserConnection(ConnType_Unadvise);
g_szLogFileName.Close();
//_unlink(g_sLogFile);
_unlink(m_sRequestFile); // "AUDReq.txt"
this->m_formFile.Close();
DeleteFile(m_sFormFile); // "AUDFillData.txt"
_unlink(m_sResponseFile); // "AUDResponse.txt"
// end clean up my files
break;
default:
break;
}
return S_OK;
}
HRESULT CAUD::ManageBrowserConnection(ConnectType eConnectType)
{
if (eConnectType == ConnType_Unadvise && m_dwBrowserCookie == 0)
{
sprintf(g_szMsg, "ManageBrowserConnection, nothing to do, normal.\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
return S_OK; // not advised, nothing to do
}
ATLASSERT(m_pWebBrowser);
if (!m_pWebBrowser)
{
sprintf(g_szMsg, "ManageBrowserConnection, no m_pWebBrowser.\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
return S_OK;
}
HRESULT hr = E_FAIL;
if (eConnectType == ConnType_Advise)
{
//ATLASSERT(m_dwBrowserCookie == 0);
hr = AtlAdvise (m_pWebBrowser, (IDispatch*)this, __uuidof(DWebBrowserEvents2), &m_dwBrowserCookie);
sprintf(g_szMsg, "ManageBrowserConnection, eConnectType == ConnType_Advise.\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
}
else
{
hr = AtlUnadvise(m_pWebBrowser, __uuidof(DWebBrowserEvents2), m_dwBrowserCookie);
m_dwBrowserCookie = 0;
}
ATLASSERT(SUCCEEDED(hr));
return hr;
}
CAUD::CAUD() :
m_bBlockNewWindow(TRUE),
m_dwBrowserCookie(0),
m_pWBDisp(NULL) /*,
m_sLogid(_T("")),
m_sPassword(_T("")*/
{
memset(&g_szMsg, 0, 8192);
sprintf(g_szMsg, "Starting a CAUD constr");
#ifdef DEBUG
::MessageBox(NULL,g_szMsg,"DEBUG",NULL);
#endif
char szTempDir[_MAX_PATH + 1];
memset(&szTempDir, NULL, sizeof(szTempDir));
GetTempPath(_MAX_PATH, szTempDir);
m_sWorkDir = CString(szTempDir);
FILE* fp;
bool bNewLogFile = true;
// first establish a log file for basic browser functionality, apart from the app
CString x_sLogFile = m_sWorkDir + CString("CAUDLog.txt");
if (fileexist(x_sLogFile))
{
fp = fopen(x_sLogFile, "w");
fseek(fp, 0, 0);
fclose(fp);
if(_unlink(x_sLogFile))
{
bNewLogFile = false; // cannot delete
m_hCAUDLogFile = NULL;
}
}
if (bNewLogFile)
{
HANDLE hCAUDLogFile = CreateFile(_T(x_sLogFile),GENERIC_READ|GENERIC_WRITE, FILE_SHARE_WRITE,NULL, CREATE_ALWAYS,
NULL,NULL);
if (hCAUDLogFile == INVALID_HANDLE_VALUE)
{
#ifdef DEBUG
::MessageBox(NULL,"Error in creating CAUD log file CAUD constr","Error",NULL);
#endif
}
else
{
m_hCAUDLogFile = hCAUDLogFile;
m_szLogFileName = CAtlFile(m_hCAUDLogFile);
sprintf(g_szMsg, "Created CAUDLog.txt log file\n");
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
}
}
g_sLogFile = m_sWorkDir + CString("AUDLogfile.txt");
m_sRequestFile = m_sWorkDir + CString("AUDReq.txt");
m_sFormFile = m_sWorkDir + CString("AUDFillData.txt");
m_sResponseFile = m_sWorkDir + CString("AUDResponse.txt");
m_nFillRecursion = 0;
this->m_pRequestData = new char[512];
}
LRESULT CALLBACK CtxMenuWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_INITMENUPOPUP)
{
if (wParam == (WPARAM) g_hAUDMenu || wParam == (WPARAM) g_hCommentMenu)
{
// This is our menu
return 0;
}
}
return CallWindowProc(g_lpPrevWndProc, hwnd, uMsg, wParam, lParam);
}
HRESULT CAUD::ShowContextMenu(DWORD dwID,
POINT *ppt,
IUnknown *pcmdTarget,
IDispatch *pdispObject)
{
// Return S_OK to tell MSHTML not to display its own menu
// Return S_FALSE displays default MSHTML menu
// get any user settings stored away
// 8/22 stop storing confidential login data in reg.
int jX = 0;
int iIndex = 0;
int iItems = 0;
int iCount = 0;
int iZ = 0;
int iCnt = 0;
int idItem = 0;
int iParse = 1;
char szBuffer[512];
char szBuffer2[512];
char szComments[30][256];
char szStr[8192];
char szItemStr[512];
char szDataElement[512];
char szTempMenuItem[512];
char szOriginalText[512];
char szItem[512];
sprintf(g_szMsg, "In ShowContextMenu()\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
//::MessageBox(NULL,"In CAUD::ShowContextMenu", "AUD.cpp, AutoFill DLL",MB_OK|MB_ICONWARNING);
memset(&szBuffer, NULL, sizeof(szBuffer));
memset(&szBuffer2, NULL, sizeof(szBuffer2));
LoadRegistrySettings();
//::MessageBox(NULL,"In CAUD::ShowContextMenu", "AUD.cpp, AutoFill DLL",MB_OK|MB_ICONWARNING);
#define IDR_BROWSE_CONTEXT_MENU 24641
#define IDR_FORM_CONTEXT_MENU 24640
#define SHDVID_GETMIMECSETMENU 27
#define SHDVID_ADDMENUEXTENSIONS 53
HRESULT hr;
CComPtr<IOleCommandTarget> spCT;
hr = pcmdTarget->QueryInterface(IID_IOleCommandTarget, (void**)&spCT);
if (FAILED(hr))
return S_FALSE;
CComPtr<IOleWindow> spWnd;
hr = pcmdTarget->QueryInterface(IID_IOleWindow, (void**)&spWnd);
if (FAILED(hr))
return S_FALSE;
HWND hwnd;
hr = spWnd->GetWindow(&hwnd);
if (FAILED(hr))
return S_FALSE;
hr = S_FALSE;
BSTR bssURL;
if (m_pWebBrowser->get_LocationURL(&bssURL) == S_OK )
{
CString strURL;
strURL = bssURL;
sprintf(g_szMsg, "URL is %s\n", strURL);
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
}
HINSTANCE hinstSHDOCLC = LoadLibrary(_T("SHDOCLC.DLL"));
if (hinstSHDOCLC)
{
HMENU hCtxMenu = LoadMenu(hinstSHDOCLC, MAKEINTRESOURCE(IDR_BROWSE_CONTEXT_MENU));
if (hCtxMenu)
{
sprintf(g_szMsg, "Loaded BrowseContextMenu\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
HMENU hSubMenu = GetSubMenu(hCtxMenu, dwID);
if (hSubMenu)
{
sprintf(g_szMsg, "Got handle to SubMenu\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
// Get the language submenu
CComVariant var;
sprintf(g_szMsg, "Getting language submenu\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
hr = spCT->Exec(&CGID_ShellDocView, SHDVID_GETMIMECSETMENU, 0, NULL, &var);
if (SUCCEEDED(hr))
{
sprintf(g_szMsg, "Exec(&CGID_ShellDocView\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
MENUITEMINFO mii = {0};
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_SUBMENU;
mii.hSubMenu = (HMENU) var.byref;
// Add language submenu to Encoding context item
SetMenuItemInfo(hSubMenu, IDM_LANGUAGE, FALSE, &mii);
// Insert Shortcut Menu Extensions from registry
CComVariant var1;
V_VT(&var1) = VT_INT_PTR;
V_BYREF(&var1) = hSubMenu;
CComVariant var2;
V_VT(&var2) = VT_I4;
V_I4(&var2) = dwID;
#pragma message( "AUD.cpp: compiling ShowContextMenu, line 1228")
hr = spCT->Exec(&CGID_ShellDocView, SHDVID_ADDMENUEXTENSIONS, 0, &var1, &var2);
if (SUCCEEDED(hr))
{
// Insert our menu at the top of the context menu
BSTR bsURL;
if (m_pWebBrowser->get_LocationURL(&bsURL) == S_OK )
{
CString sURL;
sURL = bsURL;
sprintf(g_szMsg, "URL is %s\n", sURL);
// ::MessageBox(NULL, g_szMsg, "DEBUG", NULL);
g_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
SysFreeString(bsURL);
sURL.MakeLower();
memset(&szItemStr, NULL, sizeof(szItemStr));
if ( (sURL.Find("eoscar", 0) >= 0 || sURL.Find("e-oscar", 0) >= 0) && sURL.Find("login.jsp") <= 0 )
{
char szFinalStr[256], szFinalStr2[256];
memset(&szFinalStr, NULL, sizeof(szFinalStr));
memset(&szFinalStr2, NULL, sizeof(szFinalStr2));
g_hAUDMenu = LoadMenu(g_hinstAUD, MAKEINTRESOURCE(IDR_AUDMENU));
LoadRegistrySettings();
if(strlen(this->m_sComments))
{
CString sToken = this->m_sComments;
memset(&szDataElement, NULL, sizeof(szDataElement));
memset(&szStr, NULL, sizeof(szStr));
memset(&szComments, NULL, sizeof(szComments));
strcpy(szStr, this->m_sComments);
while(newline_parse(szStr,iParse,
(char *)szDataElement,sizeof(szDataElement)))
{
if(strlen(szDataElement) && iParse < 32)
{
strcpy(szComments[iCount++], szDataElement);
}
iParse++;
}
for(int iX = 0;iX < iCount;iX++)
{
sprintf(g_szMsg, "szComments[%i]: %s\n", iX, szComments[iX]);
strcpy(g_szComments[iX], szComments[iX]);
}
g_iCommentCount = iCount;
g_hCommentMenu = LoadMenu(g_hinstAUD, MAKEINTRESOURCE(IDR_COMMENTS));
iItems = GetMenuItemCount(g_hCommentMenu);
sprintf(g_szMsg, "CommentMenu:iItems=%i\n", iItems);
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
memset(&szItem, NULL, sizeof(szItem));
for(iZ = 0;iZ < iItems+1;iZ++)
{
memset(&szBuffer, NULL, sizeof(szBuffer));
memset(&szBuffer2, NULL, sizeof(szBuffer2));
GetMenuString(g_hCommentMenu, iZ, szItem, sizeof(szItem), MF_BYPOSITION);
idItem = GetMenuItemID(g_hCommentMenu, iZ);
sprintf(g_szMsg, "CommentMenu:szItem[%i]: %s\n", iZ, szItem);
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
if(iZ < g_iCommentCount)
{
iCnt = iZ;
sprintf(szBuffer, "%-50.50s", g_szComments[iZ]);
remove_trailing_blanks(szBuffer);
if(strstr(szBuffer, "&&") != NULL)
{
CString sBuf = szBuffer;
sBuf.Replace("&&", "&&&&");
strcpy(szBuffer, sBuf);
}
sprintf(szBuffer2, "%i) %s", iZ + 1, szBuffer);
sprintf(g_szMsg, "CommentMenu:szItem[%i]: %s\n", iZ, szBuffer2);
//m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
ModifyMenu(g_hCommentMenu, iZ, MF_BYPOSITION | MF_STRING, idItem, szBuffer2);
}
else
{
for(int b = g_iCommentCount;b < GetMenuItemCount(g_hCommentMenu);b++)
{
GetMenuString(g_hCommentMenu, b, szItem, sizeof(szItem), MF_BYPOSITION);
if(!strncmp("Static", szItem, 6))
{
iCnt = b;
break;
}
}
idItem = GetMenuItemID(g_hCommentMenu, iCnt);
sprintf(g_szMsg, "CommentMenu:Deleting szItem[%i]: %s, idItem=%i\n", iZ, szItem, idItem);
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
DeleteMenu(g_hCommentMenu, idItem, MF_BYCOMMAND);
}
}
}
if(g_hAUDMenu)
{
iItems = GetMenuItemCount(g_hAUDMenu);
memset(&szItem, NULL, sizeof(szItem));
for(jX = 0;jX < iItems;jX++)
{
GetMenuString(g_hAUDMenu, jX, szItemStr, sizeof(szItemStr), MF_BYPOSITION);
sprintf(g_szMsg, "Menu:szItemStr[%i]: %s\n", jX, szItemStr);
if if( g_sAcctNumber.GetLength() > 0 && strstr(szItemStr, "PreFill") != NULL)
{
memset(&szFinalStr, NULL, sizeof(szFinalStr));
sprintf(szFinalStr2, "%s%s", "PreFill from ", LPCSTR(g_sAcctNumber));
sprintf(g_szMsg, "Menu:szFinalStr2=: %s\n", szFinalStr2);
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
idItem = GetMenuItemID(g_hAUDMenu, jX);
if(g_sAcctNumber.GetLength() > 0 && strcmp(szFinalStr2,szItemStr) )
{
sprintf(szFinalStr, "%s%s", "PreFill from ", LPCSTR(g_sAcctNumber));
ModifyMenu(g_hAUDMenu, jX, MF_BYPOSITION | MF_STRING, idItem, szFinalStr);
}
}
}
}
if (g_hAUDMenu)
{
::InsertMenu(hSubMenu, 0, MF_POPUP | MF_BYPOSITION, (UINT_PTR) g_hAUDMenu, _T("Dispute AutoFill"));
iItems = 1;
if(g_hCommentMenu && g_iCommentCount > 0)
{
iItems++;
::InsertMenu(hSubMenu, 1, MF_POPUP | MF_BYPOSITION, (UINT_PTR) g_hCommentMenu, _T("Copy Dispute Comment"));
}
::InsertMenu(hSubMenu, iItems, MF_BYPOSITION | MF_SEPARATOR, NULL, NULL);
}
}
}
// Subclass IE window.
// This is required in order to enable our menu. Otherwise, IE
// disregards menu items it doesn't recognize.
#pragma warning( push )
#pragma warning( disable : 4311 )
#pragma warning( disable : 4312 )
g_lpPrevWndProc = (WNDPROC)SetWindowLong(hwnd, GWL_WNDPROC, (LONG)CtxMenuWndProc);
#pragma warning( pop )
// Show shortcut menu
int nPopUpSelection = ::TrackPopupMenu(hSubMenu,
TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD,
ppt->x,
ppt->y,
0,
hwnd,
(RECT*)NULL);
// Unsubclass IE window
#pragma warning( push )
#pragma warning( disable : 4311 )
SetWindowLong(hwnd, GWL_WNDPROC, (LONG)g_lpPrevWndProc);
#pragma warning( pop )
if (g_hAUDMenu)
{
DestroyMenu(g_hAUDMenu);
sprintf(g_szMsg, "Destroying AUDMenu\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
g_hAUDMenu = NULL;
}
if (g_hCommentMenu)
{
sprintf(g_szMsg, "Destroying CommentMenu\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
DestroyMenu(g_hCommentMenu);
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
g_hCommentMenu = NULL;
}
CString path = m_sFormFile;
if (nPopUpSelection == ID_SAVEFORM)
{
CSaveForm dlg;
dlg.DoModal();
CString strpath=dlg.GivePath();
//::MessageBox(NULL, "SaveForm modal finished OK", "Debug Autofill", MB_OK);
if(strpath!="")
{
HRESULT hr = SaveFormAs(strpath);
if (FAILED(hr))
ATLTRACE(_T("Failure sinking SaveForm events from IWebBrowser2\n"));
}
}
else if(nPopUpSelection == ID_STARTNEW )
{
// call StartNew();
if (this->StartNewDispute() && fileexist(path))
{
//::MessageBox(NULL, "Calling AutoFill", "Debug Autofill", MB_OK);
sprintf(g_szMsg, "Calling AutoFill:path %s\n", path);
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
HRESULT hr = AutoFill(path);
if (FAILED(hr))
{
ATLTRACE(_T("Failure sinking AutoFill events from IWebBrowser2\n"));
sprintf(g_szMsg, "AutoFill failed:path %s\n", path);
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
}
}
//m_SearchData.m_sSSN = dialog;
// send the data to the web server
}
else if (nPopUpSelection == ID_MENU_PREFILL_PAGE)
{
//FlushFormData();
// CAutoFillDlg dialog;
// int nRC = dialog.DoModal();
// char szMsg[128];
sprintf(g_szMsg, "Inside MenuPrefill()\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
// ::MessageBox(NULL, szMsg, "Debug Autofill", MB_OK);
//::MessageBox(NULL, "Closed AutoFill Dlg", "Debug Autofill", MB_OK);
if(fileexist(path))
{
sprintf(g_szMsg, "Menu:path: %s\n", path);
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
//::MessageBox(NULL, "Calling AutoFill", "Debug Autofill", MB_OK);
if ( m_formFile.m_h == 0 )
{
// ::MessageBox(NULL, "Prefill, handle is null, re-attach", "DEBUG", NULL);
m_formFile.Attach(this->m_hformFile);
}
HRESULT hr = AutoFill(path);
if (FAILED(hr))
{
ATLTRACE(_T("Failure sinking AutoFill events from IWebBrowser2\n"));
}
}
else
{
::MessageBox(NULL, "No Pre-fill data available.", "", MB_OK);
}
}
else if (nPopUpSelection == ID_CONFIGURE )
{
sprintf(g_szMsg, "Configuring plug-in\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
CConfigDlg cDlg;
INT_PTR nRC = cDlg.DoModal();
if (nRC == IDOK ) // //meaning //they clicked OK
{
m_sLogid = cDlg.GetLogid();
m_sPassword = cDlg.GetPassword();
m_sComments = cDlg.GetComments();
SaveRegistrySettings();
sprintf(g_szMsg, "Configured plug-in\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
}
}
else if(nPopUpSelection == ID_FLUSHFORM )
FlushFormData();
//======================================================================
//These are the comments menu items. Please do not change the resource
//ids for these. It makes the math a lot easier.
//======================================================================
else if(nPopUpSelection >= 32787 && nPopUpSelection <= 32816)
{
memset(&szTempMenuItem, NULL, sizeof(szTempMenuItem));
memset(&szOriginalText, NULL, sizeof(szOriginalText));
sprintf(g_szMsg, "ContextMenu:(Comments)cmd: %i\n", nPopUpSelection);
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
GetMenuString(hSubMenu, nPopUpSelection, szTempMenuItem, sizeof(szTempMenuItem), MF_BYCOMMAND);
sprintf(g_szMsg, "ContextMenu:(Comments)MenuStr: %s\n", szTempMenuItem);
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
sprintf(g_szMsg, "ContextMenu:(Comments)Actual Comment: %s\n(array int is %i)\n", g_szComments[nPopUpSelection - 32787], nPopUpSelection - 32787);
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
sprintf(g_szMsg, "ContextMenu:(Comments)putting comment into clipboard: %s\n", g_szComments[nPopUpSelection - 32787]);
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
strcpy(szOriginalText, g_szComments[nPopUpSelection - 32787]);
//=====================================================
//Need to replace tags with actual data if it exists.
//=====================================================
//==========================================
//Replacing &&account_number tag
//==========================================
CString sFilledData = szOriginalText;
CopyTextToClipboard(sFilledData);
}
else
{
ATLTRACE(_T("ContextMenu cmd = %d\n"), nPopUpSelection);
sprintf(g_szMsg, "ContextMenu:cmd: %i\n", nPopUpSelection);
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
if (nPopUpSelection == IDM_FOLLOWLINKN)
{
// Allow user to open link in new window
m_bBlockNewWindow = FALSE;
}
// Send selected shortcut menu item command to shell
LRESULT lr = ::SendMessage(hwnd, WM_COMMAND, nPopUpSelection, NULL);
}
}
}
}
DestroyMenu(hCtxMenu);
}
FreeLibrary(hinstSHDOCLC);
}
else
{
sprintf(g_szMsg, "hinstSHDOCLC is %ld, LoadLibrary failed on SHDOCLC.DLL\n", hinstSHDOCLC);
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
}
return (SUCCEEDED(hr) ? hr : S_FALSE);
}
HRESULT FinalConstruct()
{
//LoadRegistrySettings();
return S_OK;
}
void FinalRelease()
{
}
public:
//
// IDispatch Methods
//
STDMETHOD(Invoke)(DISPID dispidMember,REFIID riid, LCID lcid, WORD wFlags,
DISPPARAMS * pdispparams, VARIANT * pvarResult,
EXCEPINFO * pexcepinfo, UINT * puArgErr);
//
// IOleObjectWithSite Methods
//
STDMETHOD(SetSite)(IUnknown *pUnkSite);
//
// IDocHostUIHandler
//
STDMETHOD(ShowContextMenu)(DWORD dwID, POINT FAR* ppt, IUnknown FAR* pcmdTarget, IDispatch FAR* pdispReserved);
STDMETHOD(ShowUI)(DWORD dwID, IOleInPlaceActiveObject FAR* pActiveObject,
IOleCommandTarget FAR* pCommandTarget,
IOleInPlaceFrame FAR* pFrame,
IOleInPlaceUIWindow FAR* pDoc)
{
if (m_spDefaultDocHostUIHandler)
return m_spDefaultDocHostUIHandler->ShowUI(dwID, pActiveObject, pCommandTarget, pFrame, pDoc);
return S_FALSE;
}
STDMETHOD(GetHostInfo)(DOCHOSTUIINFO FAR *pInfo)
{
if (m_spDefaultDocHostUIHandler)
return m_spDefaultDocHostUIHandler->GetHostInfo(pInfo);
return S_OK;
}
STDMETHOD(HideUI)(void)
{
if (m_spDefaultDocHostUIHandler)
return m_spDefaultDocHostUIHandler->HideUI();
return S_OK;
}
STDMETHOD(UpdateUI)(void)
{
if (m_spDefaultDocHostUIHandler)
return m_spDefaultDocHostUIHandler->UpdateUI();
return S_OK;
}
STDMETHOD(EnableModeless)(BOOL fEnable)
{
if (m_spDefaultDocHostUIHandler)
return m_spDefaultDocHostUIHandler->EnableModeless(fEnable);
return S_OK;
}
STDMETHOD(OnDocWindowActivate)(BOOL fActivate)
{
if (m_spDefaultDocHostUIHandler)
return m_spDefaultDocHostUIHandler->OnDocWindowActivate(fActivate);
return S_OK;
}
STDMETHOD(OnFrameWindowActivate)(BOOL fActivate)
{
if (m_spDefaultDocHostUIHandler)
return m_spDefaultDocHostUIHandler->OnFrameWindowActivate(fActivate);
return S_OK;
}
STDMETHOD(ResizeBorder)(LPCRECT prcBorder, IOleInPlaceUIWindow FAR* pUIWindow, BOOL fFrameWindow)
{
if (m_spDefaultDocHostUIHandler)
return m_spDefaultDocHostUIHandler->ResizeBorder(prcBorder, pUIWindow, fFrameWindow);
return S_OK;
}
STDMETHOD(TranslateAccelerator)(LPMSG lpMsg, const GUID FAR* pguidCmdGroup, DWORD nCmdID)
{
if (m_spDefaultDocHostUIHandler)
return m_spDefaultDocHostUIHandler->TranslateAccelerator(lpMsg, pguidCmdGroup, nCmdID);
return E_NOTIMPL;
}
STDMETHOD(GetOptionKeyPath)(LPOLESTR FAR* pchKey, DWORD dw)
{
if (m_spDefaultDocHostUIHandler)
return m_spDefaultDocHostUIHandler->GetOptionKeyPath(pchKey, dw);
return E_FAIL;
}
STDMETHOD(GetDropTarget)(IDropTarget* pDropTarget, IDropTarget** ppDropTarget)
{
if (m_spDefaultDocHostUIHandler)
return m_spDefaultDocHostUIHandler->GetDropTarget(pDropTarget, ppDropTarget);
return S_OK;
}
STDMETHOD(GetExternal)(IDispatch** ppDispatch)
{
if (m_spDefaultDocHostUIHandler)
return m_spDefaultDocHostUIHandler->GetExternal(ppDispatch);
return S_FALSE;
}
STDMETHOD(TranslateUrl)(DWORD dwTranslate, OLECHAR* pchURLIn, OLECHAR** ppchURLOut)
{
if (m_spDefaultDocHostUIHandler)
return m_spDefaultDocHostUIHandler->TranslateUrl(dwTranslate, pchURLIn, ppchURLOut);
return S_FALSE;
}
STDMETHOD(FilterDataObject)(IDataObject* pDO, IDataObject** ppDORet)
{
if (m_spDefaultDocHostUIHandler)
return m_spDefaultDocHostUIHandler->FilterDataObject(pDO, ppDORet);
return S_FALSE;
}
//
// IOleCommandTarget
//
STDMETHOD(QueryStatus)(
/*[in]*/ const GUID *pguidCmdGroup,
/*[in]*/ ULONG cCmds,
/*[in,out][size_is(cCmds)]*/ OLECMD *prgCmds,
/*[in,out]*/ OLECMDTEXT *pCmdText)
{
return m_spDefaultOleCommandTarget->QueryStatus(pguidCmdGroup, cCmds, prgCmds, pCmdText);
}
STDMETHOD(Exec)(
/*[in]*/ const GUID *pguidCmdGroup,
/*[in]*/ DWORD nCmdID,
/*[in]*/ DWORD nCmdExecOpt,
/*[in]*/ VARIANTARG *pvaIn,
/*[in,out]*/ VARIANTARG *pvaOut)
{
sprintf(g_szMsg, "InsideExec()nCmdID=%d.,nCmdExecOpt=%d\n", nCmdID, nCmdExecOpt);
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
if(nCmdID == OLECMDID_SHOWMESSAGE)
{
sprintf(g_szMsg, "InsideExec()Showing OLECMDID_SHOWMESSAGE\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
}
if (nCmdID == OLECMDID_SHOWSCRIPTERROR)
{
sprintf(g_szMsg, "InsideExec()Preventing OLECMDID_SHOWSCRIPTERROR\n");
if (this->m_hCAUDLogFile != NULL )
m_szLogFileName.Write(g_szMsg, strlen(g_szMsg));
// Don't show the error dialog, but
// continue running scripts on the page.
(*pvaOut).vt = VT_BOOL;
(*pvaOut).boolVal = VARIANT_TRUE;
return S_OK;
}
return m_spDefaultOleCommandTarget->Exec(pguidCmdGroup, nCmdID, nCmdExecOpt, pvaIn, pvaOut);
}
|
|
|
|
|
It doesnt look like my code, although I never tested it on IE7 but it should not crash in-theory .
Well, I could not get the real idea where it is crashing. If you have VS2005 enabled can you through the DebugTrace(if any) or Call Browser's window output when it crashes.
Thanks
Vishal
Vishal Swarnkar
|
|
|
|
|
Vishal,
I do have log messages in my code. The customer has Visual Studio 2005 happened to be on the machine. There are no strange settings I can recall. I wonder if not having the ATL update of headers on the customer's machine may make an impact. I can WebEx with the user. The user has no other plug-ins enabled. What function would likely cause it? What is stranger still is that the user is left mouse-clicking which should not even instantiate the plug-in in theory. The user has frames turned on. It happens when it opens a new window in IE. By the way, what is a disp id of 282 from Invoke() mean. I cannot seem to find the result of that.
Thanks,
Brad
|
|
|
|
|
How to install the toolbar on Internet Explorer ?
I've tried to register the dll, and some other small things but it didn't work.
|
|
|
|
|
Well there is no toolbar as such. You can use it on Right Click button of your mouse.
As far as registration is concerned you have to regedit your output dll and that's it, nothing much.
Right Click on your web page and see if new menu appears for AutoFill, read the above description for detail usage.
Thanks
Vishal Swarnkar
|
|
|
|
|
Your job is excellent for saving and auto filling the web form. I need this type of thing in my BHO. But one problem is: How to handle if the web form is under frame/iframe?
I have solved this issue by parsing for frame/iframe and then do its document2 again the same thing. This is working only when the source of frame/iframe is within the same domain as page domain e.g. www.vu.edu.pk
But if there is difference in page domain and frame/iframe domain (cross-domain problem) it gives me permission error(Access is denied).
The RoboForm Form Filler do this thing successfully but how to overcome this issue.
Many bundles of Thanks in advance
Rizwan
|
|
|
|
|
Hi Rizwan,
Thanks!
This BHO works when your form is fully loaded in IE. It does all the parsing in the loaded document.
If inside your page,you are uploading frames from different location, you need to modify the code. Currently it does all the processing on loaded form, you need to change it to processing at loading time.
But this can be done only when you know in advance the location of your page. I mean its hardcoded , doesnt change all the time. Its difficult to make it generic. I nee to think about this more.
Vishal Swarnkar
|
|
|
|
|
I installed the autofill.dll provided with the article by using regsvr32. When I try to auto-fill a page by selecting a previously saved .dat file, IE hangs. I have tried this on two different machines running IE 5 and IE 6 with same results. Is anyone else having this problem? I am currently trying to compile the code on my VS .NET 2002 so maybe I can figure out the source of the hang.
|
|
|
|
|
Yes the basic COM component (BHO) behind the whole project is not very stable and sometimes your IE hangs. I have seen this behaviour before and can't help with it.
I think its an issue with BHO but you can re-verify with my code, to ensure its a BHO error.
Vishal Swarnkar
|
|
|
|
|
Vishal,
Can you please share the source code which is compatible with VS 2003/2005. I have converted the source to VS 2005 and I am trying to compile the code it is giving me error saying "fatal error C1083: Cannot open include file: 'atlcontrols.h': No such file or directory c:\inetpub\wwwroot\generic_autofill_vs5\aboutdlg.h". I have never used ATL/VC++ can you please help me if you have readme file or how to solve your error. Very URGENT help needed!!!
vijay
|
|
|
|
|
Like you i also had problems compiling. Got it to work by searching web for file 'atlcontrols.h' and pasting it into ..\Vc7\include directory. I had a couple of compile errors due to 2 lines in this header file commented them out and it compiled, however with a few warnings. Good luck.
|
|
|
|
|
Probably you are using an old .Net framework, so you need to manually add atlcontrols.h in your include directory.
Vishal Swarnkar
|
|
|
|
|
Hi,
Great to see a concise code.
I am doing a similar thing but with a small difference where I would like to have a javascript window pop-up instead of a form. My case is where for any search field in a webpage, I should bring a pop-up with some hardcoded keywords.
Can that be done using Javascript from IWebBrowser2 handler ?.
If yes, would you like to share a snippet of the same ?
Thanks,
Andy
|
|
|
|
|
Hi Andy,
Sorry for Very late reply. I dont know if you are still looking for solution or not.
If I am clear with your issue, you need to pop-up a JavaScript window, if an user enteres for some particular keyword?
If yes, message me with clear question, probably I can help in COM side( IWebBrowser2) side.
thnx
Vishal Swarnkar
|
|
|
|
|
Hello Vishal Swarankar
Vishal Can we use your source in our own programs. And then
Distribute the .Dll
Would appreciate very much
thankyou
|
|
|
|
|
Yes!
Sure,Go ahead.
I dont have any issue. Sorry for late reply.
Thanks
Vishal
Vishal Swarnkar
|
|
|
|
|
I am trying to link your code in a solution with an MFC project that references the ATL attributed class. No matter what I do I keep getting those linker errors in the MFC project when I build the solution:
c1xx : error C3174: module attribute was not specified
LINK : fatal error LNK1250: failed to merge IDL content
I have googled the error and some people suggested using [emitidl(restricted)] at the begining of the attributed class but it doesnt fix my problem. I also tried another suggestion which is to switch the "Ignore Embedded IDL" switch to yes but that resulted in unresolved external symbol errors. Am I missing something?
Help please.
|
|
|
|
|
Sorry ibrahim. I never used MFC. if you paste the whole error log then may be I can help you but again the source will be google only.
If you have entry points for ATL in your project space then I think it should work fine, i cant understand whats wrong with IDL.
Sorry man.
Vishal Swarnkar
|
|
|
|
|
does this code work with pages that have javascript in it? like bank login forms?
|
|
|
|
|
Do you mean that whthr this code follow the action attached in javascript code? is this then no I am not playing with javascript in this code. Even I have done that in another project and u can play easily with javascript action using simple C++. its possible. If you need one I can google and can give some good link to easily gets uor hands on.
thanks
Vishal
Vishal Swarnkar
|
|
|
|
|
what if the html website has 2 forms, one for sign in and one for registration. How will the code know which one to save?
|
|
|
|
|
Hi Ibrahim,
In case of multiple forms you have to change in the code. This code is for sinlge form. But u can do that easily. Just query the document about no of forms and put them in loop. This time I dont remember the code but once you know the no of form you have same logic will apply on the every form and you have to put the logic in the loop(by no of forms).
One more thing you should take care is Save another tag with every Input Filed at the time of template form data saving process,because at the time of form filling you need that a particular field belong to which form.
so the code is very easy to extend and customizable.
So I'll request you to customize it for multiple forms and you can post the code so that others can be get benefitted.
still if u face ne problem buzz me immediately.
Vishal Swarnkar
|
|
|
|
|