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. How to get image from IHTMLImgElement ?

How to get image from IHTMLImgElement ?

Scheduled Pinned Locked Moved COM
questiontutorialannouncement
2 Posts 2 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.
  • A Offline
    A Offline
    alexhalt
    wrote on last edited by
    #1

    Hello! There is interface IWebBrowser2, which I use to get IHTMLDocument2, IHTMLElementCollection, IHTMLElement, IHTMLImgElement from. I can get different picture options from IHTMLImgElement, but I can't get the picture itself. How can I do that? Please advise. P.S. I've tried to use the following code:

    IOleCommandTarget* pCT;
    CComVariant vGlyphTableEntry;
    vGlyphTableEntry = "c:\\temp.jpg";

    if (pElemDispatch->QueryInterface(__uuidof(IOleCommandTarget), (void**)&pCT)==S_OK)
    {
    pCT->Exec(&CGID_MSHTML, IDM_SAVEPICTURE , OLECMDEXECOPT_DONTPROMPTUSER ,&vGlyphTableEntry, 0);
    pCT->Release();
    }

    But this code shows the 'Save as' dialog, which shouldn't appear. What's wrong with this code? Is there some other way to do that? Thanks in advance

    S 1 Reply Last reply
    0
    • A alexhalt

      Hello! There is interface IWebBrowser2, which I use to get IHTMLDocument2, IHTMLElementCollection, IHTMLElement, IHTMLImgElement from. I can get different picture options from IHTMLImgElement, but I can't get the picture itself. How can I do that? Please advise. P.S. I've tried to use the following code:

      IOleCommandTarget* pCT;
      CComVariant vGlyphTableEntry;
      vGlyphTableEntry = "c:\\temp.jpg";

      if (pElemDispatch->QueryInterface(__uuidof(IOleCommandTarget), (void**)&pCT)==S_OK)
      {
      pCT->Exec(&CGID_MSHTML, IDM_SAVEPICTURE , OLECMDEXECOPT_DONTPROMPTUSER ,&vGlyphTableEntry, 0);
      pCT->Release();
      }

      But this code shows the 'Save as' dialog, which shouldn't appear. What's wrong with this code? Is there some other way to do that? Thanks in advance

      S Offline
      S Offline
      sdc395
      wrote on last edited by
      #2

      Take a look at IHTMLElementRender which you should be able to query the IHTMLImgElement for. This interface has a DrawToDC method that you could use to render the element to a DC of your own creation.

      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