Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. method executing too many times

method executing too many times

Scheduled Pinned Locked Moved COM
c++questioncomtools
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mgriffith
    wrote on last edited by
    #1

    i just asked this on the visual c++ forum, but i think this is probably a better place to ask....here goes nothing i have 2 methods that are using IWebBrowser2 to execute a print method from a com object that is hosted on a webpage. here is the code for the methods: --------------------------------- STDMETHODIMP CTemplatePrinter::IEPrintNoPrompt(VARIANT varTemplateURL) { CComPtr spContainer; CComPtr spSP; CComPtr spWB; CComPtr spDisp; CComPtr spDoc; CComPtr spCT; CComVariant vPTPath = varTemplateURL; m_spClientSite->GetContainer(&spContainer); spContainer->QueryInterface(IID_IServiceProvider, (void**)&spSP); spSP->QueryService(SID_SWebBrowserApp, IID_IWebBrowser, (void**)&spWB); spWB->get_Document(&spDisp); spDisp->QueryInterface(IID_IHTMLDocument2, (void**)&spDoc); spDoc->QueryInterface(IID_IOleCommandTarget, (void**)&spCT); // ******* THIS IS WHERE IT'S GOING CRAZY!!!! ******* // spCT->Exec(&CGID_MSHTML, IDM_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, &vPTPath, NULL); return S_OK; } --------------------------------------- STDMETHODIMP CTemplatePrinter::IEPrint(VARIANT varTemplateURL) { CComPtr spContainer; CComPtr spSP; CComPtr spWB; CComPtr spDisp; CComPtr spDoc; CComPtr spCT; CComVariant vPTPath = varTemplateURL; m_spClientSite->GetContainer(&spContainer); spContainer->QueryInterface(IID_IServiceProvider, (void**)&spSP); spSP->QueryService(SID_SWebBrowserApp, IID_IWebBrowser, (void**)&spWB); spWB->get_Document(&spDisp); spDisp->QueryInterface(IID_IHTMLDocument2, (void**)&spDoc); spDoc->QueryInterface(IID_IOleCommandTarget, (void**)&spCT); // ***** IT CALLS THIS 2 TIMES? ******** // spCT->Exec(&CGID_MSHTML, IDM_PRINT, OLECMDEXECOPT_PROMPTUSER, &vPTPath, NULL); return S_OK; } -------------------------- my question is: does anyone have any idea why the IOleCommandTarget::Exec method it going berzerk? when i call the method from a script, the first one keeps spooling pages into the printer, and the second one opens 2 print dialogs in a row...i also have another function for opening a print preview window that works fine....the only difference is my call to Exec is as follows: spCT->Exec(&CGID_MSHTML, IDM_PRINTPREVIEW, OLECMDEXE

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups