Re: Retriving a value from a hidden text field (HTML)
From: fernando (FatalError0x4c_at_hotmail.com)
Date: 02/20/04
- Next message: Jeff F: "Re: _com_ptr_t"
- Previous message: Simon Trew: "Re: Class to combine multiple IStreams in one IStream for VC++ 6?"
- In reply to: Mash: "Retriving a value from a hidden text field (HTML)"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 20 Feb 2004 10:26:41 -0300
i think this line
_stprintf(sPort, _T("%s"), (LPCTSTR)pValuePort);
only works if UNICODE is defined, if thats not the case u should do
USES_CONVERSION;
_stprintf(sPort, _T("%s"), OLE2CT(pValuePort));
bye
"Mash" <anonymous@discussions.microsoft.com> escreveu na mensagem
news:153EA1AB-AE90-4881-9B47-3C1C4E64C12F@microsoft.com...
> I am trying to read an html page and retrieve the value of three hidden
input fields sure as:
> <input name=port type=hidden value=1500>
>
> Below is the code I am working with to read in the value (1500) but it is
not working. I think i am missing something.
>
> HRESULT hr;
> TCHAR sPort[25];
> IDispatch* pElemDisp = NULL;
> IHTMLInputHiddenElement* pElem = NULL;
> IHTMLElementCollection *pElemcoll;
>
> // Get the WebBrowser's document object
> CComPtr<IDispatch> pDisp;
> HRESULT hr = m_spWebBrowser2->get_Document(&pDisp);
> if (FAILED(hr)) return false;
>
> CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> spHTML;
> spHTML = pDisp;
>
> _variant_t tagName("input");
> _variant_t tagNamePort("port");
>
> BSTR* pValuePort = NULL;
>
> spHTML->get_forms(&pElemcoll);
>
> hr = pElemColl->tags( tagName, &pElemDisp );
> if ( SUCCEEDED(hr) )
> {
> hr = pElemDisp->QueryInterface( IID_IHTMLInputHiddenElement,
(void**)&pElem );
> if ( SUCCEEDED(hr) )
> {
> hr = pElem->get_value(pValuePort);
> if ( SUCCEEDED(hr) )
> {
> //Set port
> _stprintf(sPort, _T("%s"), (LPCTSTR)pValuePort);
> m_sPort = (int)sPort;
> }
> pElem->Release();
> }
> pElemDisp->Release();
> }
>
> //at this point m_sPort is NULL not 1500 :-(
>
> Thank you for any help you can give.. mash
- Next message: Jeff F: "Re: _com_ptr_t"
- Previous message: Simon Trew: "Re: Class to combine multiple IStreams in one IStream for VC++ 6?"
- In reply to: Mash: "Retriving a value from a hidden text field (HTML)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|