CDHtmlDialog 基本使用
- 跳转
Navigate("res://tt.exe/#138");
138是html的资源号
- 输入框的Get,set
HRESULT CTTDlg::OnButtonCancel(IHTMLElement* pElement)
{
BSTR p;
pElement->get_id(&p);
CString szText;
HRESULT hr = NULL;
IHTMLElement* psrcElement;
VARIANT value;
hr = GetElement("kw", &psrcElement );
if( SUCCEEDED( hr ))
{
psrcElement->getAttribute( L"value", 0, &value );
szText = value.bstrVal;
}
AfxMessageBox((CString)p +szText);
hr = GetElement( "Text1", &psrcElement );
if( SUCCEEDED( hr ))
{
szText+="456";
value.bstrVal=szText.AllocSysString();
psrcElement->setAttribute( L"value",value );
}
return S_OK;
}
- 超链接
<a href="res://tt.exe/#138" ></a>
- 图片显示
<img src="res:/JPG/#137" width="20%" height="20%" >
- 获得控件的坐标
IHTMLElement* but; HRESULT rs= GetElement("ButtonOK",&but); //控件跟随 if (SUCCEEDED(rs)) { long top,l,h,w; but->get_offsetTop(&top); but->get_offsetLeft(&l); but->get_offsetHeight(&h); but->get_offsetWidth(&w); IHTMLElement* hContainer=NULL; long value=0; rs=but->get_offsetParent(&hContainer); //其真实坐标应该是所有的父结点的坐标的叠加,所以有以下循环 while ( hContainer ) { hContainer->get_offsetLeft(&value); l += value; hContainer->get_offsetTop(&value); top += value; hContainer->get_offsetParent(&hContainer); } CRect rect(l,top,w+l,top+h); GetDlgItem(IDC_STATIC_P)->MoveWindow(rect); }