// assure that control containment is on AfxEnableControlContainer();
RECT rectClient; GetClientRect(&rectClient);
// create the control window // AFX_IDW_PANE_FIRST is a safe but arbitrary ID if (!m_wndBrowser.CreateControl(CLSID_WebBrowser, lpszWindowName, WS_VISIBLE | WS_CHILD, rectClient, this, AFX_IDW_PANE_FIRST)) { DestroyWindow(); return FALSE; }
return TRUE; } BOOL CHtmlEditCtrl::Create(LPCTSTR lpszWindowName, DWORD /*dwStyle*/, const RECT& rect, CWnd* pParentWnd, int nID, CCreateContext *pContext) { BOOL bRet = FALSE; // create the control window
AfxEnableControlContainer(); if (CreateControl(CLSID_WebBrowser, lpszWindowName, WS_VISIBLE | WS_CHILD, rect, pParentWnd, nID)) { // in order to put the webbrowser in design mode, you must // first load a document into it. "about:blank" seems to // be the safest thing to load for a good starting point. CComQIPtr pBrowserApp = GetControlUnknown(); ASSERT(pBrowserApp); if (pBrowserApp) { CComVariant vEmpty; LPCTSTR szDoc = GetStartDocument(); if (szDoc) { CComBSTR bstrStart(szDoc); if (S_OK == pBrowserApp->Navigate(bstrStart, &vEmpty, &vEmpty, &vEmpty, &vEmpty)) { bRet = TRUE; } } else bRet = TRUE;
} }
if (!bRet) DestroyWindow(); return bRet; } this是webbrowser2控件的父窗口 忘记CComPtr在哪里定义的了。去看一下MSDN this应该是一个有窗口的CWnd Do not create this control every time...place it on a CDialog/CFormView, or a controlbar.
two way to get HTML interfaces 1 call CWnd::GetControlUnknown to get IWebbrowser2 Interface LPUNKNOWN lpUnk = m_wndBrowser.GetControlUnknown(); HRESULT hr = lpUnk->QueryInterface(IID_IWebBrowser2, (void**) &m_pBrowserApp);
void CSRWOnlineView::OnDocumentComplete(LPDISPATCH pDisp, LPCTSTR lpszUrl) { // make sure the main frame has the new URL.This call also stops the animation ((CChildFrame*)GetParentFrame())->SetAddress(lpszUrl); CString strURL(lpszUrl); CComQIPtr pWebBrowser2(pDisp); CHTMLCodeDlg HTMLCodeDlg; if(pWebBrowser2){ CComQIPtr pqiDisp; pWebBrowser2->get_Document(&pqiDisp); HTMLCodeDlg.m_pdocument=pqiDisp; } HTMLCodeDlg.DoModal(); } BOOL CHTMLCodeDlg::OnInitDialog() { CDialog::OnInitDialog(); USES_CONVERSION; if (m_pdocument){ CComQIPtr pBody; HRESULT hr = m_pdocument->get_body(&pBody); if (FAILED(hr)) return FALSE; CComBSTR bstrHTMLText; hr = pBody->get_outerHTML(&bstrHTMLText); if (FAILED(hr)) return FALSE; // Convert the text from Unicode to ANSI m_strText=OLE2T(bstrHTMLText); }
UpdateData(FALSE); return TRUE;// return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CHTMLCodeDlg::OnApply() { if(!UpdateData())return; USES_CONVERSION; if (m_pdocument){ CComQIPtr pBody; HRESULT hr = m_pdocument->get_body(&pBody); if (FAILED(hr)) return ; CComBSTR bstrHTMLText((LPCTSTR)m_strText); pBody->put_innerHTML(bstrHTMLText); // Convert the text from Unicode to ANSI } OnOK(); }
see Programming and Reusing the Browser Overviews and Tutorials in Platform SDK
//You may derive a class from CComModule and use it if you want to override //something, but do not change the name of _Module #include //for atlcom.h extern CComModule _Module;//for atlbase.h #include //for OLE2T
hr = m_pBrowserApp->QueryInterface(IID_IDispatch, (void**) &spDisp); // Is the IDispatch* passed to us for the top-level window ? if (pDisp == spDisp) { MSHTML::IHTMLDocument2Ptr spDoc;
// Get the active document spDoc = GetHtmlDocument(); if ( spDoc ) { MSHTML::IHTMLWindow2Ptr spWin;
// Get the top-level window spDisp = spDoc->Script; spWin = spDisp; if ( spWin ) { // Get the document spDoc = spWin->document; if ( spDoc ) { IDispatchExPtr spDispEx;
// Get the document's IDispatchEx spDoc->QueryInterface( IID_IDispatchEx, (void**)&spDispEx ); if ( spDispEx ) { _bstr_tbstrName("XMLDocument"); DISPID dispid;
// Get the XMLDocument expando property spDispEx->GetDispID( bstrName, fdexNameCaseSensitive, &dispid ); if ( SUCCEEDED(hr) && dispid != DISPID_UNKNOWN ) { VARIANT var; DISPPARAMS dpNoArgs = {NULL, NULL, 0, 0};
// Get the XMLDocument value hr = spDispEx->Invoke( dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &dpNoArgs, &var, NULL, NULL ); if ( SUCCEEDED(hr) && var.vt == VT_DISPATCH ) { MSXML2::IXMLDOMDocument* pXMLDoc=NULL;
// Get the IXMLDOMDocument interface var.pdispVal->QueryInterface( IID_IXMLDOMDocument, (void**)&pXMLDoc ); VariantClear( &var ); if ( pXMLDoc ) { // Get the root element MSXML2::IXMLDOMElement* pXMLElem=NULL;
你不会在NewWindow的时候做个标记,在BeforeNavigate的时候检察这个标记? set ppDisp to the existing webbrowser object will result page to be opened in the same window Knowledge Base
BUG: Using NewWindow or NewWindow2 to Always Navigate in the Same Window Fails in Some Instances void CIEDlg::OnNewWindow2(LPDISPATCH FAR* ppDisp, BOOL FAR* Cancel) {
IUnknown* pUnk = m_Browser.GetControlUnknown(); if (pUnk) { IDispatch* pDisp = NULL; HRESULT hr = pUnk->QueryInterface(IID_IDispatch, (void**)&pDisp);
在我这个程序中能不能直接用WebBrowser Control里面的一些函数对 html document对象是否已经产生进行判断呢?
呵呵,各位大虾不好意思 小弟表达能力不好,罗嗦的写了这么多 还望给为抽空指点一下! 万分感谢!
A
The WebBrowser Control fires the DWebBrowserEvents2::DocumentComplete event when the document has completely loaded and the READYSTATE property has changed to READYSTATE_COMPLETE. Here are some important points regarding the firing of this event.
In pages with no frames, this event fires once after loading is complete. In pages where multiple frames are loaded, this event fires for each frame where the DWebBrowserEvents2::DownloadBegin event has fired. This event's pDisp parameter is the same as the IDispatch interface pointer of the frame in which this event fires. In the loading process, the highest level frame (which is not necessarily the top-level frame) fires the final DWebBrowserEvents2::DocumentComplete event. At this time, the pDisp parameter will be the same as the IDispatch interface pointer of the highest level frame.
For specific code examples using Microsoft® Visual Basic® and Microsoft Foundation Classes (MFC), see Knowledge Base article Q180366 .
Currently, the DWebBrowserEvents2::DocumentComplete does not fire when the IWebBrowser2::Visible property of the WebBrowser Control is set to false. For more information, see Knowledge Base Article Q259935 .
换用IWebBrowser2看看 // Get the IDispatch of the document LPDISPATCH lpDisp = NULL; lpDisp = m_webBrowser.GetDocument();
if (lpDisp) { IOleContainer* pContainer;
// Get the container HRESULT hr = lpDisp->QueryInterface(IID_IOleContainer, (void**)&pContainer); lpDisp->Release();
if (FAILED(hr)) return hr;
IEnumUnknown* pEnumerator;
// Get an enumerator for the frames hr = pContainer->EnumObjects(OLECONTF_EMBEDDINGS, &pEnumerator); pContainer->Release();
if (FAILED(hr)) return hr;
IUnknown* pUnk; ULONG uFetched;
// Enumerate all the frames for (UINT i = 0; S_OK == pEnumerator->Next(1, &pUnk, &uFetched); i++) { // QI for IWebBrowser here to see if we have an embedded browser IWebBrowser2* pBrowser;
建立一个临时的COleVariant对象保存字符串,然后复制它的值到需要的位置。 VariantCopy This function frees the destination variant and makes a copy of the source variant.
HRESULT VariantCopy( VARIANTARG FAR *pvargDest, VARIANTARG FAR *pvargSrc ); Parameters pvargDest Pointer to the VARIANTARG to receive the copy. pvargSrc Pointer to the VARIANTARG to be copied. Return Values One of the values obtained from the returned HRESULT and described in the following table is returned.
Value Description S_OK Success. DISP_E_ARRAYISLOCKED The variant contains an array that is locked. DISP_E_BADVARTYPE The source and destination have an invalid variant type (usually uninitialized). E_OUTOFMEMORY Memory could not be allocated for the copy. E_INVALIDARG One of the arguments is invalid.
Remarks Passing into this function any invalid and, under some circumstances, NULL pointers will result in unexpected termination of the application.
First, free any memory that is owned by pvargDest, such as VariantClear (pvargDest must point to a valid initialized variant, and not simply to an uninitialized memory location). Then pvargDest receives an exact copy of the contents of pvargSrc.
If pvargSrc is a VT_BSTR, a copy of the string is made. If pvargSrc is a VT_ARRAY, the entire array is copied. If pvargSrc is a VT_DISPATCH or VT_UNKNOWN, AddRef is called to increment the object’s reference count.
Command group CGID_MSHTML (defined in mshtmhst.h) Symbolic constant IDM_SAVEAS User interface Optional. This command displays a dialogue box if the nCmdExecOpt argument of IOleCommandTarget::Execis set to MSOCMDEXECOPT_DODEFAULT, MSOCMDEXECOPT_PROMPTUSER, or NULL. It does not display a dialogue box if the argument is set to MSOCMDEXECOPT_DONTPROMPTUSER. IOleCommandTarget::Exec parameters pvaIn VARIANT of type VT_BSTR that specifies the path and file name of the file to which to save the Web page. When the path contains more than one folder name, separate the folder names with two backward slashes (//). pvaOut Set to NULL. Header file mshtmcid.h Applies to IHTMLDocument2::execCommand, IHTMLDocument2::queryCommandEnabled, IHTMLDocument2::queryCommandIndeterm, IHTMLDocument2::queryCommandState, IHTMLDocument2::queryCommandSupported, IHTMLDocument2::queryCommandValue, emit_hlink;, IOleCommandTarget::QueryStatus .
保存到一个.mht文件,并且设置DONTPROMPTUSER看看
Accomplishing this task from a Visual C++ host is very straightforward. You can use an IWebBrowser2 interface to call the QueryInterface method for the IHTMLDocument2 interface. After you obtain a pointer to the document, then call QueryInterface for the IPersistFile interface. After you obtain this interface pointer, you can call the save method to save the file to disk.
p Pointer to a BSTR that receives one of the values listed in Possible Values. v BSTR that specifies one of the values listed in Possible Values. Possible Values
yes Default. Scroll bars are turned on. no Scroll bars are turned off. auto Scroll bars are shown when the page content exceeds the client area.
Return Value
Returns S_OK if successful, or an error value otherwise. See Also
CSS Enhancements in Internet Explorer 6 Public Preview
MLang provides two enumeration objects that can be used to retrieve the code pages and locales that are recognized by the system from the MIME database.
To use this functionality to enable end users to invoke their preference:
Make sure the Component Object Library has been initialized. Before you can use any of the functionality provided by MLang, you must first initialize the Component Object Library through a call to CoInitialize. Every call to CoInitialize must be accompanied by a call to CoUninitialize when the application terminates. CoUninitialize ensures that the application does not quit until it has received all of its pending messages.
Obtain a pointer to an IMultiLanguage interface. If no MultiLanguage object exists, this can be accomplished through a call to CoCreateInstance, using CLSID_CMultiLanguage and IID_IMultiLanguage for the first and fourth parameters, respectively. If a MultiLanguage object already exists, this can be accomplished by calling QueryInterface through the current MultiLanguage object interface.
Obtain an interface to an enumerator object through a call to the IMultiLanguage::EnumCodePages or IMultiLanguage::EnumRfc1766 method. If you are enumerating code pages, you need to decide which of the MIMECONTF constants you want to use as the flag for the call. These constants specify the uses of a code page and can be used to tailor the list of code pages returned to suit your needs.
Call the Next method of the enumeration interface you have obtained. This method retrieves an array of MIMECPINFO or RFC1766INFO structures, depending on whether you are enumerating code pages or locales, respectively. You must allocate memory for these arrays by using the task allocator. The following code sample demonstrates how to do this for code pages. It should be noted, however, that there is no function for locales that corresponds to IMultiLanguage::GetNumberOfCodePageInfo.
if(SUCCEEDED)hr)) { // Use the MIMECPINFO structures returned to allow the // user to select his or her own preferences. } Dynamically add the code pages or locales to a menu or list box. The MIMECPINFO and RFC1766INFO structures contain a description of the code page or locale in a wide-character string. The MLang Conversion object can be used to convert these strings to the proper code page for output (in this case, 1252). The following code shows how to add the code pages in an array of MIMECPINFO structures to a dynamically created pop-up menu.
Hide Example
// IMultiLanguage *pMultiLanguage; // pcpInfo - pointer to an array of MIMECPINFO structures. // ccpInfo - number of structures in pcpInfo.
AppendMenu(hsubmenu, MF_POPUP, UINT (hpopup), "&Code Pages"); Remember to reallocate the memory for the arrays, release the interfaces, and uninitialize the Component Object Library before your program terminates. The memory for the arrays must be reallocated by using the task allocator. Although the IEnumCodePage, IEnumRfc1766, and IMLangConvertCharset interfaces are obtained through the IMultiLanguage interface, all must be released individually.
1,java读取.properties配置文件
InputStream in;
try {
in = test.class.getClassLoader().getResourceAsStream("config/ipnetOracle.properties");//配置文件的路径
Properties p = new Properties()
create or replace procedure proc_test01
as
type emp_row is record(
empno emp.empno%type,
ename emp.ename%type,
job emp.job%type,
mgr emp.mgr%type,
hiberdate emp.hiredate%type,
sal emp.sal%t
今天在执行一个脚本时,本来是想在脚本中启动hdfs和hive等程序,可以在执行到service hive-server start等启动服务的命令时会报错,最终解决方法记录一下:
脚本报错如下:
./olap_quick_intall.sh: line 57: service: command not found
./olap_quick_intall.sh: line 59
最近重新安装的电脑,配置了新环境,老是出现:
adb server is out of date. killing...
ADB server didn't ACK
* failed to start daemon *
百度了一下,说是端口被占用,我开个eclipse,然后打开cmd,就提示这个,很烦人。
一个比较彻底的解决办法就是修改
import java.util.HashMap;
public class Title {
public static void main(String[] args){
f();
}
// 二位数组的应用
//12、二维数组中,哪一行或哪一列的连续存放的0的个数最多,是几个0。注意,是“连续”。
public static void f(){