Home > Software engineering >  The webbrowser development for help
The webbrowser development for help

Time:10-17

Why I use webbrowser control after loading web pages, after verification code image copy to clipboard, program in the face of the clipboard operation paste pictures do not come out, but in Word document and paste, couldn't paste in drawing, could you tell me is what reason, the following is a copy code and clipboard operations
 HRESULT hr; 
PDisp IDispatch *=NULL;
PDisp=m_web. Get_Document ();//get the webBrowser control interface
PDoc IHTMLDocument2 *=NULL;
Hr=pDisp - & gt; QueryInterface (IID_IHTMLDocument2, (void * *) & amp; PDoc);//get web document interface

IHTMLElementCollection * pColl=NULL;
Hr=pDoc - & gt; The get_all (& amp; PColl);//get all the page elements record collection

IDispatch * pDisp2=NULL;
The VARIANT index;//used to receive return elements based on the index, general need not, as it is good, but with the IDispatch receives the element object interface
Index. N=VT_I4;
The index. The lVal=0;

The VARIANT varIdName;//to find HTML tag ID and the ID captcha images
TANGRAM__PSP_3__verifyCodeImg varIdName=StringToVariant (_T (" "));
/* varIdName=StringToVariant (_T (" randomCodeImg ")); */

Hr=pColl - & gt; The item (varIdName, index, & amp; PDisp2); The location of the//find the element
If (S_OK==hr & amp; & NULL!=pDisp2)
{
Cstrings dd.//temp
IHTMLElement * pelmBody=NULL;
If (FAILED (pDoc - & gt; Get_body (& amp; PelmBody) | | pelmBody==NULL)//the abnormal exit here
Goto the Cleanup.
IHTMLElement2 * pelmBodyTwo=NULL;
If (FAILED (pelmBody - & gt; QueryInterface (IID_IHTMLElement2, (void * *) & amp; PelmBodyTwo) | | pelmBodyTwo==NULL)
Goto the Cleanup.
IDispatch * pdispCtrlRange=NULL;
If (FAILED (pelmBodyTwo - & gt; CreateControlRange (& amp; PdispCtrlRange) | | pdispCtrlRange==NULL)
Goto the Cleanup.
IHTMLControlRange * pCtrlRange=NULL;
If (FAILED (pdispCtrlRange - & gt; QueryInterface (IID_IHTMLControlRange, (void * *) & amp; PCtrlRange) | | pCtrlRange==NULL)
Goto the Cleanup.
IHTMLControlElement * pCtrlElement=NULL;
If (FAILED (pDisp2 - & gt; QueryInterface (IID_IHTMLControlElement, (void * *) & amp; PCtrlElement) | | pCtrlElement==NULL)
Goto the Cleanup.

Hr=pCtrlRange - & gt; Add (pCtrlElement);
The VARIANT vEmpty;
VEmpty. N=VT_UINT;
VEmpty. LVal=0;
BSTR bstrCommand=SysAllocString (L "Copy");//the Cut
VARIANT_BOOL vbReturn;
//OpenClipboard ();
//clear clipboard
//EmptyClipboard ();
//long len.
If (SUCCEEDED (hr))
{
Hr=pCtrlRange - & gt; ExecCommand (bstrCommand, VARIANT_FALSE vEmpty, & amp; VbReturn);//copy to memory
//pCtrlRange - & gt; Get_length (& amp; Len);
}
//the clipboard format into a specified format,
//EnumClipboardFormats (CF_BITMAP);
//CloseClipboard ();
PCtrlElement - & gt; Release ();
Dd. The Format (" % d ", L vbReturn);
AfxMessageBox (dd);
The Cleanup:
SysFreeString (bstrCommand);

If (pCtrlRange)
PCtrlRange - & gt; Release ();
If (pdispCtrlRange)
PdispCtrlRange - & gt; Release ();
If (pelmBodyTwo)
PelmBodyTwo - & gt; Release ();
If (pelmBody)
PelmBody - & gt; Release ();
If (pColl)
PColl - & gt; Release ();
}
If (pDisp2)
PDisp2 - & gt; Release ();

 OpenClipboard (); 
//handle to obtain the clipboard data
HANDLE hBitmap=GetClipboardData (CF_BITMAP);//get the BMP handle!
If (hBitmap)
{
AfxMessageBox (L "data");
//to get equipment environment handle
CStatic * pWnd=(CStatic *) GetDlgItem (IDC_STATIC);//get the Picture Control handle
The CDC * pDc=pWnd - & gt; GetDC ();
HDC HDC=pDc - & gt; GetSafeHdc ();
//create the memory associated with equipment environment
HDC hdcMem=CreateCompatibleDC (HDC);
//select object
SelectObject (hdcMem hBitmap);
//set the mapping mode
SetMapMode (hdcMem, GetMapMode (hDC));
//get the bitmap object
BITMAP bm.
//bitmap copy
GetObject (hBitmap, sizeof (BITMAP), & amp; Bm);
BitBlt (hDC, 0, 0, bm. BmWidth, bm. BmHeight, hdcMem, 0, 0, SRCCOPY);
//release equipment environment handle
//ReleaseDC (hDC);
DeleteDC (hdcMem);
//delete memory environment

}
//off the clipboard
CloseClipboard ();

CodePudding user response:

Refer to the inside of the MSDN clipboard viewer source code,

CodePudding user response:

Can you give a website

CodePudding user response:

This is clear clipboard data format is not right

CodePudding user response:

I don't have you tried many format can website I am using https://passport.baidu.com/v2/? The login authentication code inside picture is PNG
 

If (OpenClipboard ())
{
UINT clipboard_format=0;
While (clipboard_format=EnumClipboardFormats (clipboard_format))
{
Printf (" Clipboard Data Format x=0 x % \ n ", clipboard_format);
HGLOBAL global_memory=GetClipboardData (clipboard_format);
LPCSTR clipboard_data=https://bbs.csdn.net/topics/(LPCSTR) GlobalLock (global_memory);
If (clipboard_data!=NULL)
{
//the address data on the clipboard
Printf (" Clipboard Data Address x=0 x % \ n ", global_memory);

//on the clipboard data size
DWORD data_size=GlobalSize (global_memory);
Printf (" Data Size=% d \ n ", data_size);
//hexadecimal output data
Printf (" Data: ");
The switch (clipboard_format)
{
Case CF_TEXT:
AfxMessageBox (L "CF_TEXT");
break;
Case CF_BITMAP:
AfxMessageBox (L "CF_BITMAP");
break;
Case CF_METAFILEPICT:
AfxMessageBox (L "CF_METAFILEPICT");
break;
Case CF_SYLK:
AfxMessageBox (L "CF_SYLK");
break;
Case CF_DIF:
AfxMessageBox (L "CF_DIF");
break;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related