Replace the clipboard data when pasted in your browser

zhaozj2021-02-08  225

At some point, you may need to override the clipboard, such as filtering the information in the input window when you filter your chat. For the editing mode of the browser control, the browser provides the IDOCHOSTUIHANDLER interface to support the paste to provide an alternative data source to override the data of the clipboard. The following code describes how to filter a clipboard format other than CF_Text

HRESULT CHtmlCtrl :: OnFilterDataObject (IDataObject * pDataObject, IDataObject ** ppDataObject) // This is my :: FilterDataObject implementation of IDocHostUIHandler {COleDataObject OleDataObject; OleDataObject.Attach (pDataObject, FALSE); COleDataSource * pOleDataSource = new COleDataSource; if (OleDataObject .IsDataAvailable (CF_TEXT)) {// Get text data from ColeDataObject HGLOBAL hGlobal = OleDataObject.GetGlobalData (CF_TEXT);. pOleDataSource-> CacheGlobalData (CF_TEXT, hGlobal); // here I simply use the original data, you certainly You can replace the data here,} refiid riid = IID_IDataObject; POLEDATASOURCE-> ExternalQueryInterface (& riid, (lpvoid *) PPDataObject); OLEDATAOBJECT.DETACH (); return s_ok;}

A method of implementing IDOchOchostuiHandler is mentioned in an article I translated (http://www.9cbs.net/develop/Article/19/19627.shtm).

转载请注明原文地址:https://www.9cbs.com/read-1851.html

New Post(0)