pdwMode [in, out] Storage for conversion context. A calling function should only provide storage that is initialized with zero at the first call to the method. The caller should not modify the value. dwEncoding [in] Code page identifier value for the destination multibyte string. This value is equivalent to the uiCodePage member of the MIMECPINFO structure assigned to dwEncoding. pSrcStr [in] Address of the Unicode string that is to be converted. pcSrcSize [in, out] Address of the buffer that stores the length of the source string, in character counts. If this is NULL, or if -1 is specified as the length, the API assumes pSrcStr is null-terminated. When conversion is successful, the method returns the number of characters processed to this buffer. pDstStr [in] Address of the string buffer where the conversion result will be stored. pcDstSize [in, out] Address of the buffer that stores the length of pDstStr, in byte counts. When conversion is successful, the method returns the number of bytes copied to pDstStr to this buffer. Return Value
Returns one of the following values:
S_OK Success. S_FALSE The specified conversion is not supported on the system. E_FAIL An error occurred.
Remarks
Note that the size of the Unicode string to be converted is specified with a character count, while the size of the multibyte string returned is given in bytes.
http://www.batutis.com/i18n/papers/mlang/ Using IMultiLanguage2
To access the methods provided by IMultiLanguage2, a program must instantiate a MultiLanguage object and request the IMultiLanguage2 interface. This is can be done via the COM API CoCreateInstance. For example:
hr = CoCreateInstance(
CLSID_CMultiLanguage, //Class identifier (CLSID) of the object
NULL,//Pointer to controlling IUnknown
CLSCTX_INPROC_SERVER,//Context for running executable code
IID_IMultiLanguage2 ,//Reference to the identifier of the interface
(void**) &pMultiLanguage2//Address of output variable that receives
// the interface pointer requested in riid
);
This call will return the address of the IMultiLanguage2 interface in pMultiLanguage2.
Note that if you are using Microsoft Visual C++ (MSVC) to create an IMultiLanguage2 client you will need to install a recent version of the Microsoft Platform SDK (the April 2000 version is sufficient). The Mlang.h and UUID.LIB that are supplied with MSVC itself do not support IMultiLanguage2.
Once the program has retrieved the interface pointer, it can then make calls into the IMultiLanguage2 API methods. For example:
pMultiLanguage2->ConvertString(pdwMode,
1252,
437,
pSrcStr,
pcSrcSize,
pDstStr,
pcDstSize
);
This call copies characters from the source buffer to the destination buffer while doing an encoding conversion from code page 1252 to code page 437.
One might wonder why Microsoft created this API when there’s a pair of perfectly good Win32 APIs that can be used to do the same thing: MultibyteToWideChar and WideCharToMultibyte. Not only can this pair of calls do what IMultiLanguage2::ConvertString can do, but also you can supply a number of additional options in the Win32 APIs to control the conversion more completely. In addition, the Win32 APIs return more useful error codes.
One reason might be the apparent inability of MultibyteToWideChar and WideCharToMultibyte to support popular Internet encodings like EUC‑KR and ISO‑2022‑JP on Windows NT 4 and Windows 95/98 even with the appropriate language pack installed. (There is no such limitation on Windows 2000.) Perhaps the Windows and IE development teams are finally in synch in this respect. However, at this writing, there are some useful options available via the MLang Converter object that are not available via the Win32 APIs (see below).
注意看Browser Helper Objects: The Browser the Way You Want It的这一段
By calling the IConnectionPoint's Advise() method, the BHO lets the browser know that it is interested in receiving notifications about events. Due to the COM event-handling mechanism, all this actually means that the BHO provides the browser with a pointer to its IDispatch interface. The browser will then call back the IDispatch's Invoke() method, passing the ID of the event as the first argument.
It's important to remember to disconnect from the browser when events are no longer needed. If you forget to do this, the BHO will remain locked even after you close the browser's window. (Among other things, this means you can't recompile or delete the object.) A good time to disconnect is when you receive the OnQuit event.
Extending the Dynamic HTML Object Model It is possible for the hosting application to extend the Dynamic HTML Object Model so that scripts can refer to functionality implemented by the host. Such scripts refer to the host by specifying the external object that is available from the window object. For example, a reference to "window.external.speech" will call the host to resolve the name "speech." All standard script within the document will be executed normally.
This extension mechanism is implemented in the host by providing an IDispatch interface for the object model extension that will have IDispatch::GetIDsOfNames and IDispatch::Invoke called on it to resolve any references to the external object. The IDispatch that the host provides is obtained by the WebBrowser Control or MSHTML component by calling the host's IDocHostUIHandler::GetExternal method.
For an example of how to extend the Dynamic HTML Object Model, see the Driller Sample Source Page
Q
请教:如何用VC得到当前IE正在浏览的网页的网址和title?
T
我想在IE右键快捷菜单中加入一项,选择时即可获得当前网页的网址和title,我该如何做?
A
Knowledge Base Articles
HOWTO: Connect to a Running Instance of Internet Explorer Q176792
Q
如何获得IE Frame 当中的scroll bar 的位置 masterz Jiangsheng help!!!!
T
使用给位已经提供的方法可以获得IE Scroll bar 的位置
但是如果是一个子frame 中,简单的使用IHTMLBody的方法,在有些IE版本 无法获得相对应的scroll bar 的位置 (总是0)请问如何获得frame 中的滚动条的位置
A
Frame.document.Body是否支持IHTMLTextContainer?
Q
急!!!!!关于IE控件 500分相送!!!
T
请问我已经得到IHTMLDocument2 如何把它显示到CWebBrowser2控件中呢?
A
query IPersistStream for HtmlDocument object,and then call IPersistStream::Load from a memory stream created by CreateStreamOnHGlobal.
1 Create a WebBrowser host in Microsoft Visual C++ 6.0 or 7.0. For a sample implementation that uses the Active Template Library (ATL), see the following Microsoft Developer Network (MSDN) Web site:
Web and Internet Samples: ATLBrowser http://msdn.microsoft.com/downloads/samples/internet/default.asp?url=/Downloads/samples/Internet/browser/atlbrowser/Default.asp
2 Sink DWebBrowserEvents2 on the WebBrowser control. For more information about sinking WebBrowser events, see the following MSDN Web site:
Reusing the WebBrowser Control: Working with WebBrowser Events http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/webbrowser/webbrowser.asp
3 When your application is created, call the IWebBrowser2 Navigate() method to move the WebBrowser to "about:blank".
4 Add code to your DWebBrowserEvents2::DocumentComplete() event handler to load a file from memory:
If (m_bInitial)//m_bInitial is used to prevent the DocumentComplete event from being fired recursively, set it to TRUE after the Navigate() call. { HRESULT hr = E_FAIL;
BOOL CDlgEdit::SaveData() { _variant_t varVal; try{ //given id? if(m_varItemID.vt!=VT_CLSID){ //new record,add new m_rst->AddNew(); } FieldsPtr pFields=m_rst->Fields; FieldPtr pItem; CString strFieldName; long lFields=pFields->Count; //for each field for(long i=0;ipItem=pFields->Item[i]; strFieldName=(LPCTSTR)pItem->Name; IHTMLInputTextElementPtr pElement; //get html element by id GetElementInterface(strFieldName,IID_IHTMLInputTextElement,reinterpret_cast (&pElement)); if(pElement){ CComBSTR bstrFieldValue; pElement->get_value(&bstrFieldValue); //if natural data type CString strDataType=DataTypeGetFieldProperty(m_strDataType,strFieldName,"FieldType"); //clear before use varVal=g_varEmpty;
if(strDataType.IsEmpty()){//default translate g_SetValueString(varVal,_bstr_t(bstrFieldValue),g_AdoType2VARTYPE(pItem->Type)); } else{//find alias or name g_SetValueString(varVal,_bstr_t(bstrFieldValue),strDataType,TRUE); } pItem->Value=varVal; } } m_rst->Update(); } catch(_com_error &e){ ESErrPrintProviderError(g_connection); ESErrPrintComError(e); return FALSE; } return TRUE; }
// Get the DISPID of the document's Script property. hr = pDocDisp->GetIDsOfNames(IID_NULL, &szScript, 1, LOCALE_USER_DEFAULT, &dispidScriptObject); ASSERT(SUCCEEDED(hr));
varResult.Clear(); // Get the DISPID of the script method to invoke. hr = pDispScriptObject->GetIDsOfNames(IID_NULL, &szFuncName, 1, LOCALE_USER_DEFAULT, &dispidMethodToInvoke); ASSERT(SUCCEEDED(hr));
The hyperlink object A hyperlink object implements the IHlink interface and encapsulates four pieces of reference information: a moniker to the hyperlink target; a string for the location within the target; a friendly name for the target; and additional parameters.
The hyperlink object completely encapsulates the behavior of navigating to a referenced location. It also supports the ability to save and load itself through the IPersistStream interface, and the ability to be transferred through the clipboard or through drag-and-drop operations by means of IDataObject. A standard hyperlink object implementation is provided with the system, and it is not advisable to implement another version. A document can use the standard hyperlink object to represent hyperlinks within itself, thus encapsulating the work of navigating, saving, loading, dragging, dropping, cutting, and pasting hyperlinks. Standard hyperlink objects are created through the HlinkCreateFromData, HlinkCreateFromMoniker, HlinkCreateFromString, and OleLoadFromStream functions. The standard hyperlink object implements the IHlink, IPersistStream, and IDataObject interfaces.
IHlink::GetHlinkSite Method
The hyperlink container A hyperlink container is a document or application that contains hyperlinks. The container supports hyperlinks by implementing the IHlinkSite interface and, if the container's objects can be targets of other hyperlinks, the IHlinkTarget interface.
NoteGenerally, an object that acts as a hyperlink container can also act as a hyperlink target. An HTML page, for example, can contain a number of hyperlinks to other pages, while at the same time it can be the target of hyperlinks from other HTML pages. The hyperlink site A hyperlink site is a COM object that implements the IHlinkSite interface and supplies either the moniker or interface identifier of its hyperlink container. One hyperlink site can serve multiple hyperlinks. The moniker supplied by the hyperlink site is used to evaluate relative monikers to the hyperlink target. If the relative moniker is NULL, the target of the link is in the same container object, and IHlink::Navigate can result in an efficient internal jump
NoteThe standard hyperlink object performs internal jumps by retrieving the container's IHlinkTarget moniker using IHlinkTarget::GetMoniker (which avoids an unnecessary moniker bind). The object then asks the container to navigate directly through the IHlinkTarget::Navigate method
Retrieves an interface pointer to a zero-based collection of all the A objects in an HTML document. The elements are in the same order as they appear in the document.
p Address of a pointer to an IHTMLElement interface that receives the element that has the focus. Return Value
Returns S_OK if successful, or an error value otherwise. Remarks
Set the active element with the setActive or focus methods. Using the setActive method has no effect on document focus. Using the focus method on an individual element causes the element to gain focus and become the active element.
The active element remains the active element even when focus has been placed outside the parent document. If no particular object is given focus when focus returns to the parent document, then the active element will gain focus. Select the title bar of a different application and then select the initial browser title bar to confirm this. Focus is shifted to the other application initially, but returns to the same active element as before the selection
-------------------------------------------------------------------------------- The information in this article applies to:
Microsoft Internet Explorer (Programming) versions 4.0, 4.01, 4.01 SP1, 4.01 SP2, 5, 5.5
Q I use the Active Accessibility SDK to obtain an IHTMLDoc-ument2 pointer from a window handle (HWND). Is there any way to obtain an IWebBrowser2 pointer from the IHTMLDocument2 pointer? I抳e tried QueryInterface on both the document pointer as well as the IHTMLWindow2 pointer without results. I also tried the IOmNavigator * from get_navigator on the HTMLWindow2 pointer. Any ideas?
A This is a common cause for COM consternation. You have the window, document, or browser and you know you should be able to get the others, but everywhere you turn, QueryInterface delivers a big fat NULL. The answer lies in the mysterious IServiceProvider whose job it is, well, to provide services. IServiceProvider is a great interface: it has only one method, QueryService. If you抮e using ATL smart pointers, it looks like this. First, you have to get the IServiceProvider.
CComQIPtr isp = pIHTMLDocument2;
This does a QueryInterface on the document for IServiceProvider. Once you have it, you can get the browser like so.
If all this seems confusing, there抯 a good reason for it. A cardinal rule of COM is that QueryInterface must always return an interface to the object queried. But the document doesn抰 implement IWebBrowser2; it only knows how to get the object that does. The document, browser, and window are all separate objects. In general, IServiceProvider is used whenever a bunch of separate but related COM objects together implement some kind of service. QueryInterface asks an object, do you implement this interface? QueryService tells a service provider, "get me whatever object implements this interface, please." With QueryService, the interface pointer returned may or may not be the same object as the one queried. Figure 6 illustrates the system. All the objects implement their various interfaces and store internal pointers to one another; IServiceProvider is your way to get whichever object implements a particular interface. IServiceProvider::QueryService chases the internal pointers to retrieve the object that implements the interface you want.
Figure 6 Many Objects, One IServiceProvider
IServiceProvider is essential for navigating the DHTML object hierarchy. Say you抮e writing an ActiveX® control and you want to navigate the object model. How do you do it? First, query your IOleClientSite for IServiceProvider like so:
CComQIPtr isp = pSite;
then, once you have IServiceProvider, you can QueryService it for the application object.
In all these examples, SID_SWebBrowserApp identifies the service, but you抣l often see code that uses IID_IWebBrowserApp as the service ID. Either will work, since #defines SID_SWebBrowserApp to IID_IWebBrowserApp, but for programming pedants SID_SWebBrowserApp is technically more correct, and more clear to anyone reading your code. By the way, if you抮e brave enough to implement some far-reaching colossal object system such as the DHTML object model (Lord help you!), then you should implement IServiceProvider too.
主 题:超超超超超级难题!!!!给你10个URL,你能把自动他们都存成*.mht文件吗?????? 作 者:111222 (张小白) http://www.csdn.net/expert/topic/786/786376.xml 回复人: masterz() () 信誉:982002-6-7 17:42:45得分:300 #import "c:/program files/common files/system/ado/msado15.dll" no_namespace rename("EOF", "EndOfFile") #import no_namespace rename("EOF", "EndOfFile") ............ void CSavemhtDlg::OnOK() { // save url as a single file, in fact I don't know if it is mht file, but it can be opened by IE, can someone tell me? CoInitialize(NULL); { IMessagePtriMsg(__uuidof(Message)); IConfigurationPtr iConf(__uuidof(Configuration)); iMsg->Configuration = iConf; try { iMsg->CreateMHTMLBody( "http://example.microsoft.com", cdoSuppressNone, "domain//username", "password"); } catch(_com_error err) { // handle exception } _StreamPtr pStream=iMsg->GetStream(); pStream->SaveToFile("test.mht",adSaveCreateOverWrite); } CoUninitialize(); }
Q
如何获得对网页上按钮之类控制的消息?(在VC里)
T
如在里使用IE控件作浏览网站的东东时,如何得到对网页按钮的点击消息呢?
A
Receiving Element Events Each element in the DHTML Object Model supports an outgoing HTMLElementEvents2 interface. This interface defines the events that an HTML element can fire. You implement this interface to provide an event sink, which is a Component Object Model (COM) object that implements an outgoing interface and is used as the mechanism for firing events.
NoteInterfaces implemented by a server usually have their methods called by the client, but to fire an event, the server calls the respective method on the client event sink. These interface are called outgoing interfaces. A COM object that implements an outgoing interface is also known as a connectable object. The following steps are required to receive events from an outgoing interface:
Implement the event sink.
The event sink implements the appropriate outgoing interface and methods. Internet Explorer event interfaces are dispinterfaces, so calls to event methods are made through IDispatch::Invoke . This means that you only need to implement the IDispatch interface to handle events.
Determine if the server is a connectable object.
Call QueryInterfaceto retrieve a pointer to the IConnectionPointContainerinterface.
Find the appropriate connection point.
Call the IConnectionPointContainer::FindConnectionPointmethod to find the connection point you need. For Internet Explorer WebBrowser Control events, such as DWebBrowserEvents2::DocumentComplete, this is DWebBrowserEvents2. For element events, this is HTMLElementEvents2. You can also call the IConnectionPointContainer::EnumConnectionPointsto enumerate through all the connection points a server supports.
Advise the connection point that you want to receive events.
Using the IConnectionPointinterface pointer returned in the previous step, call IConnectionPoint::Advise , passing the IUnknowninterface pointer of your event sink.
NoteThe connectable object will use the IUnknown interface pointer to query the client for the event sink interface. If the event sink does not support the outgoing interface, Internet Explorer will query the client for the IDispatch interface. When you no longer want to receive events, you can call the IConnectionPoint::Unadvisemethod, passing the cookie you received from the call to IConnectionPoint::Advise
The following sample code demonstrates how to begin receiving HTML element events for an element on an HTML page. void CMyClass::ConnectEvents(IHTMLElement* pElem) { HRESULT hr; IConnectionPointContainer* pCPC = NULL; IConnectionPoint* pCP = NULL; DWORD dwCookie;
// Check that this is a connectable object. hr = pElem->QueryInterface(IID_IConnectionPointContainer, (void**)&pCPC);
if (SUCCEEDED(hr)) { // Find the connection point. hr = pCPC->FindConnectionPoint(DIID_HTMLElementEvents2, &pCP);
if (SUCCEEDED(hr)) { // Advise the connection point. // pUnk is the IUnknown interface pointer for your event sink hr = pCP->Advise(pUnk, &dwCookie);
if (SUCCEEDED(hr)) { // Successfully advised }
pCP->Release(); }
pCPC->Release(); } } The following sample code demonstrates how you would detect the firing of an HTMLElementEvents2::onclick event in your implementation of IDispatch::Invoke.
// Get the current URL // LPOLESTR lpURL = NULL; m_spWebBrowser2->get_LocationURL(&lpURL);
switch (dispidMember) { // The parameters for this DISPID are as follows: // [0]: Cancel flag- VT_BYREF|VT_BOOL // [1]: HTTP headers - VT_BYREF|VT_VARIANT // [2]: Address of HTTP POST data- VT_BYREF|VT_VARIANT // [3]: Target frame name - VT_BYREF|VT_VARIANT // [4]: Option flags - VT_BYREF|VT_VARIANT // [5]: URL to navigate to - VT_BYREF|VT_VARIANT // [6]: An object that evaluates to the top-level or frame //WebBrowser object corresponding to the event. // case DISPID_BEFORENAVIGATE2: strEventInfo << "BeforeNavigate2: ";
// The parameters for this DISPID: // [0]: URL navigated to - VT_BYREF|VT_VARIANT // [1]: An object that evaluates to the top-level or frame //WebBrowser object corresponding to the event. // case DISPID_NAVIGATECOMPLETE2: if (pDispParams->rgvarg[0].vt == (VT_BYREF|VT_VARIANT)) { CComVariant varURL(*pDispParams->rgvarg[0].pvarVal); varURL.ChangeType(VT_BSTR); strEventInfo << "NavigateComplete2: " << OLE2T(varURL.bstrVal) << ends; } break;
// The parameters for this DISPID: // [0]: New status bar text - VT_BSTR // case DISPID_STATUSTEXTCHANGE: LPOLESTR lpStatusText;
if (!strcmp(OLE2T(lpStatusText), "")) strEventInfo << "NULL"; else strEventInfo << OLE2T(lpStatusText);
strEventInfo << ends; break;
// The parameters for this DISPID: // [0]: Maximum progress - VT_I4 // [1]: Amount of total progress - VT_I4 // case DISPID_PROGRESSCHANGE: strEventInfo << "ProgressChange: ";
if (pDispParams->cArgs == 0) strEventInfo << "NULL"; else { if (pDispParams->rgvarg[0].vt == VT_I4) strEventInfo << pDispParams->rgvarg[0].lVal;
VARIANT vDummy = {0}; // Instantiate a browser if (FAILED(hr = CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_SERVER, IID_IWebBrowser2, (LPVOID*)&pWebBrowser))) { goto Error; }
// Show the browser, and navigate to the special location // represented by the pidl hr = pWebBrowser->put_Visible(VARIANT_FALSE); hr = pWebBrowser->Navigate2(&vPIDL, &vDummy, &vDummy, &vDummy, &vDummy);
// 多态, 在JAVA中是这样用的, 其实在PHP当中可以自然消除, 因为参数是动态的, 你传什么过来都可以, 不限制类型, 直接调用类的方法
abstract class Tiger {
public abstract function climb();
}
class XTiger extends Tiger {
public function climb()
jQuery.extend({
handleError: function( s, xhr, status, e ) {
// If a local callback was specified, fire it
if ( s.error ) {
s.error.call( s.context || s, xhr, status, e );
}
always 总是
rice 水稻,米饭
before 在...之前
live 生活,居住
usual 通常的
early 早的
begin 开始
month 月份
year 年
last 最后的
east 东方的
high 高的
far 远的
window 窗户
world 世界
than 比...更
最近使用mybatis.3.1.0时无意中碰到一个问题:
The errors below were detected when validating the file "mybatis-3-mapper.dtd" via the file "account-mapper.xml". In most cases these errors can be d