How to Redraw/Repaint an IHTMLElement pointing to an image element in the DOM in IE9?
-
20-04-2021 - |
質問
I've got a valid IHTMLElement object that points to an image in IE9. The image data was recently updated via an IDirectDrawSurface. I'm trying to find a way to force IE9 to repaint the image in the DOM after I update the image data. Could anyone please direct me to a method of forcing a repaint of an image that has been updated in this fasion?
Approaches I've tried:
HRESULT ret = pElement->get_style(&pStyle);
pStyle->put_visibility(L"hidden");
pStyle->put_visibility(L"visible");
// Or
pStyle->put_display(L"none");
pStyle->put_display(L"block");
Thanks for your time, and any tips would be greatly appreciated.
-Will
解決
Have you tried resetting the src of the element? From what I can see, IE won't do anything if you set the same src that is already present, but looks like it can be tricked;
IHTMLImgElement pImg;
m_pElement->QueryInterface(IID_IHTMLImgElement, (void**)(&pImg));
_bstr_t bstrOriginalSrc;
pImg->get_src(bstrOriginalSrc.GetAddress());
pImg->put_src(L""); //Trick to avoid setting the same src as already present
pImg->put_src(bstrOriginalSrc);
所属していません StackOverflow