IWebBrowser2的问题 [英] Problem with IWebBrowser2
问题描述
嗨代码项目社区,
通常我从来没有打扰过我的问题的互联网论坛,但我现在有点绝望。
所以这就是问题:
我有一个带有web浏览器控件的MFC应用程序。为此,我创建了一个新类,该类从必要的com接口派生,以满足所有需求。到目前为止,它或多或少的工作相当不错,我遇到的唯一问题是我无法缩放或改变html控件内的字体大小。
通常我查找了msdn文档并提出了这段代码片段(根据互联网上的普遍共识,它应该有效):
Hi codeproject community,
normally I never bother an internet forum with my problems but I am kind of desperated right now.
So here''s the issue:
I have an MFC application with an webbrowser control in the gui contained. For this purpose I created a new class deriving from the necessary com interfaces to cope with all requirements. By now it more or less works pretty good, the only problem I''m still encountering is that I can''t zoom or rather alter the font size inside the html control.
As usually I looked up the msdn documentation and came up with this code snippet (which ought to work according to the general consensus on the internet):
VARIANT vFontSize;
VariantInit (&vFontSize);
V_VT(&vFontSize) = VT_I4;
V_I4(&vFontSize) = 4; //arbitrary picked zoom value out of a possible range from 0 to 4
//m_pBrowser->ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, &vFontSize, NULL);
//EDIT:
m_pBrowser->ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, &vFontSize, NULL);
但无论我尝试什么,显示的html内容都没有任何变化。
有人有想法吗?
But no matter what I try, there''s not any change of the displayed html content.
Anyone got an idea?
推荐答案
如果有人有兴趣,这就是我为解决这个问题所采取的措施:
由于通过调用带有相应参数的ExecWB函数来实现它的方法仍然不想工作,我做了一些有点难看的工作。
在OnDocumentComplete事件中,我只是调用Javascript为我做变焦的功能。 这本手册对我来说非常有帮助。再次感谢Khodakovsky先生。
If anybody is interested, here''s what I did to solve this:
Since the method to do it by calling the ExecWB function with the respective arguments still not want to work, I did a somewhat ugly work around.
On the OnDocumentComplete event, I simply call a Javascript function which does the zoom for me. This manual was of very big help for me. Thanks again Mr. Khodakovsky.
这篇关于IWebBrowser2的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!