如何定制一款12306抢票浏览器――用户界面(四)
ype);
CHECKHR(hr);
hr = GetInputValueHelper(spElem, L"name", stSinglePassenger.cstrName);
CHECKHR(hr);
hr = GetInputValueHelper(spElem, L"cardno", stSinglePassenger.cstrCardNo);
CHECKHR(hr);
hr = GetInputValueHelper(spElem, L"mobileno", stSinglePassenger.cstrMobileNo);
} while (0);
return hr;
}
HRESULT CDeal12306WebPage::GetOptionValueHelper( CComPtr & spElem,
const CString& cstrID, CString& cstrValue )
{
HRESULT hr = E_FAIL;
do {
CComPtr spTd;
hr = GetElementByID(spElem, cstrID, spTd);
CHECKHRPOINTER(hr, spTd);
CComPtr spSel;
hr = GetElementByIndex(spTd, 0, spSel);
CHECKHRPOINTER(hr, spSel);
CComPtr spSelect;
hr = spSel->QueryInterface(IID_IHTMLSelectElement, (LPVOID*)&spSelect);
CHECKHRPOINTER(hr, spSelect);
CComBSTR bstrValue;
hr = spSelect->get_value(&bstrValue);
CHECKHR(hr);
cstrValue = bstrValue;
} while (0);
return hr;
}
HRESULT CDeal12306WebPage::GetInputValueHelper( CComPtr & spElem,
const CString& cstrID, CString & cstrValue )
{
HRESULT hr = E_FAIL;
do {
CComPtr spTd;
hr = GetElementByID(spElem, cstrID, spTd);
CHECKHRPOINTER(hr, spTd);
CComPtr spInput;
hr = GetElementByIndex(spTd, 0, spInput);
CHECKHRPOINTER(hr, spInput);
CComPtr spInputElem;
hr = spInput->QueryInterface(IID_IHTMLInputElement, (LPVOID*)&spInputElem);
CHECKHRPOINTER(hr, spInputElem);
CComBSTR bstrValue;
hr = spInputElem->get_value(&bstrValue);
CHECKHR(hr);
cstrValue = bstrValue;
} while (0);
return hr;
}
HRESULT CDeal12306WebPage::GetTrainNoInSettingPage( CComPtr & spDoc,
CString & cstrValue )
{
HRESULT hr = E_FAIL;
do {
CComPtr spBody;
hr = spDoc->get_body(&spBody);
CHECKHRPOINTER(hr, spBody);
CComPtr spTable;
hr = GetElementByID(spBody, L"trainnotable", spTable);
CHECKHRPOINTER(hr, spTable);
CComPtr spTBody;
hr = GetElementByIndex( spTable, 0, spTBody);
CHECKHRPOINTER(hr, spTBody);
CComPtr spTr;
hr = GetElementByIndex(spTBody, 0, spTr);
CHECKHRPOINTER(hr, spTr);
CComPtr spTd;
hr = GetElementByID(spTr, L"trainno", spTd);
CHECKHRPOINTER(hr, spTd);
CComPtr spInput;
hr = GetElementByIndex(spTd, 0, spInput);
CHECKHRPOINTER(hr, spInput);
CComPtr spInputElem;
hr = spInput->QueryInterface(IID_IHTMLInputElement, (LPVOID*)&spInputElem);
CHECKHRPOINTER(hr, spInputElem);
CComBSTR bstrValue;
hr = spInputElem->get_value(&bstrValue);
CHECKHR(hr);
cstrValue = bstrValue;
} while (0);
return hr;