From: pbruyant on
Hello experts,
I am using MS VC 6.0. I've developped a small dialog-based app in
which I display some HTML contents in a CWebBrowser2 object. The HTML
document contains a <form></form> block from which I can get the
user's input using <input>, <textarea> and other tags. Getting the
user's inputs works using get
My problem is I can't set any attribute of any tag using setAttribute
().
For example,

HRESULT CMyApp::SetHtmlInputTextTag(IHTMLElement *pElement)
{
HRESULT hr=S_FALSE;
IHTMLInputElement *pInput=NULL;
BSTR bstrtemp=L"myValue";

hr=pElement->QueryInterface(IID_IHTMLInputElement,(void**)&pInput);
if (!FAILED(hr) && pInput != NULL)
{
hr=pInput->put_value(bstrtemp);
pInput->Release();
}
return hr;
}

has no effect.
I've been trying to figure out the problem for hours, and any help
would be greatly appreciated.
TIA,
Phil

From: David Ching on
<pbruyant(a)yahoo.com> wrote in message
news:a2274836-ebb9-4036-a26c-afe7a64d1a38(a)o36g2000yqh.googlegroups.com...
> Hello experts,
> I am using MS VC 6.0. I've developped a small dialog-based app in
> which I display some HTML contents in a CWebBrowser2 object. The HTML
> document contains a <form></form> block from which I can get the
> user's input using <input>, <textarea> and other tags. Getting the
> user's inputs works using get
> My problem is I can't set any attribute of any tag using setAttribute
> ().
> For example,
>
> HRESULT CMyApp::SetHtmlInputTextTag(IHTMLElement *pElement)
> {
> HRESULT hr=S_FALSE;
> IHTMLInputElement *pInput=NULL;
> BSTR bstrtemp=L"myValue";
>
> hr=pElement->QueryInterface(IID_IHTMLInputElement,(void**)&pInput);
> if (!FAILED(hr) && pInput != NULL)
> {
> hr=pInput->put_value(bstrtemp);
> pInput->Release();
> }
> return hr;
> }
>
> has no effect.



I create a text range and use that to set the Input value:

CComQIPtr<IHTMLInputElement> pInputElem(pHtmlElement);
if ( pInputElem )
{
// Fill Field Value
CComPtr<IHTMLTxtRange> pTxtRange;
pInputElem->createTextRange (&pTxtRange);
if ( pTxtRange )
{
_bstr_t bstrNewText (L"myValue");
pTxtRange->put_text(bstrNewText);
}
}


-- David

From: pbruyant on
On 8 fév, 22:39, "David Ching" <d...(a)remove-this.dcsoft.com> wrote:
> <pbruy...(a)yahoo.com> wrote in message
>
> news:a2274836-ebb9-4036-a26c-afe7a64d1a38(a)o36g2000yqh.googlegroups.com...
>
>
>
> > Hello experts,
> >  I am using MS VC 6.0. I've developped a small dialog-based app in
> > which I display some HTML contents in a CWebBrowser2 object. The HTML
> > document contains a <form></form> block from which I can get the
> > user's input using <input>, <textarea> and other tags. Getting the
> > user's inputs works using get
> > My problem is I can't set any attribute of any tag using setAttribute
> > ().
> > For example,
>
> > HRESULT CMyApp::SetHtmlInputTextTag(IHTMLElement *pElement)
> >  {
> >  HRESULT hr=S_FALSE;
> >  IHTMLInputElement *pInput=NULL;
> >  BSTR bstrtemp=L"myValue";
>
> >  hr=pElement->QueryInterface(IID_IHTMLInputElement,(void**)&pInput);
> >  if (!FAILED(hr) && pInput != NULL)
> >    {
> >    hr=pInput->put_value(bstrtemp);
> >    pInput->Release();
> >    }
> >  return hr;
> >  }
>
> > has no effect.
>
> I create a text range and use that to set the Input value:
>
>        CComQIPtr<IHTMLInputElement> pInputElem(pHtmlElement);
>        if ( pInputElem )
>        {
>         // Fill Field Value
>         CComPtr<IHTMLTxtRange> pTxtRange;
>         pInputElem->createTextRange (&pTxtRange);
>         if ( pTxtRange )
>         {
>          _bstr_t bstrNewText (L"myValue");
>          pTxtRange->put_text(bstrNewText);
>         }
>        }
>
> -- David

Thank you for the reply David.