Thread View: borland.public.cppbuilder.internet.web
7 messages
7 total messages
Started by Amidala
Sat, 09 Dec 2006 16:58
submit cppwebbrowser
Author: Amidala
Date: Sat, 09 Dec 2006 16:58
Date: Sat, 09 Dec 2006 16:58
24 lines
1604 bytes
1604 bytes
hi,
i am looking for a possibility to submit a form in cppwebbrowser. in the
newsgroups i found some delphi code i tried to convert to c++:
CppWebBrowser1->OleObject->Document->All->Item("Form1")->Submit;
CppWebBrowser1->OleObject->Document->all->item(OleVariant("Form1"))->Submit();
CppWebBrowser1->OleObject->Document->Forms->Item(0)->Submit();
None of these exmaples works. I always get these errors:
[C++ Fehler] Unit1.cpp(123): E2288 Zeiger auf Struktur auf linker Seite
von -> oder von ->* erforderlich
Means
[C++ Fehler] Unit1.cpp(123): E2288 Pointer to structure on the left site
of -> or of ->* needed
I have no idea how to solve this problem. can anybody help me?
Amidala
Re: submit cppwebbrowser
Author: Michael Harris
Date: Sat, 09 Dec 2006 18:19
Date: Sat, 09 Dec 2006 18:19
107 lines
4394 bytes
4394 bytes
Amidala
Remy posted the follwing some time ago
void __fastcall TMain::SubmitForm(void)
{
TComInterface<IHTMLDocument2> Doc;
Browser->Document->QueryInterface(IID_IHTMLDocument2,
(LPVOID*)&Doc);
if( Doc )
{
TComInterface<IHTMLElementCollection> Forms;
Doc->get_forms(&Forms);
if( Forms )
{
long count = 0;
Forms->get_length(&count);
for(long x = 0; x < count; ++x)
{
TVariant item = x;
TVariant index = 0;
TComInterface<IDispatch> Disp;
Forms->item(item, index, &Disp);
if( Disp )
{
TComInterface<IHTMLFormElement> Form;
Disp->QueryInterface(IID_IHTMLFormElement,
(LPVOID*)&Form);
if( Form )
{
ShowMessage("Form Found");
Form->submit();
break;
}
}
}
}
}
void __fastcall TMain::SubmitForm(void)
{
TComInterface<IHTMLDocument2> Doc;
Browser->Document->QueryInterface(IID_IHTMLDocument2,
(LPVOID*)&Doc);
if( Doc )
{
TComInterface<IHTMLElementCollection> Forms;
Doc->get_forms(&Forms);
if( Forms )
{
long count = 0;
Forms->get_length(&count);
for(long x = 0; x < count; ++x)
{
TVariant item = x;
TVariant index = 0;
TComInterface<IDispatch> Disp;
Forms->item(item, index, &Disp);
if( Disp )
{
TComInterface<IHTMLFormElement> Form;
Disp->QueryInterface(IID_IHTMLFormElement,
(LPVOID*)&Form);
if( Form )
{
ShowMessage("Form Found");
Form->submit();
break;
}
}
}
}
}
.
--
Michael
"Amidala" <no-spam@tiffie.net> wrote in message
news:457aeae7@newsgroups.borland.com...
> hi,
>
> i am looking for a possibility to submit a form in cppwebbrowser. in the
> newsgroups i found some delphi code i tried to convert to c++:
>
> CppWebBrowser1->OleObject->Document->All->Item("Form1")->Submit;
>
> CppWebBrowser1->OleObject->Document->all->item(OleVariant("Form1"))->Submit();
>
> CppWebBrowser1->OleObject->Document->Forms->Item(0)->Submit();
>
> None of these exmaples works. I always get these errors:
>
> [C++ Fehler] Unit1.cpp(123): E2288 Zeiger auf Struktur auf linker Seite
> von -> oder von ->* erforderlich
>
> Means
>
> [C++ Fehler] Unit1.cpp(123): E2288 Pointer to structure on the left site
> of -> or of ->* needed
>
> I have no idea how to solve this problem. can anybody help me?
>
> Amidala
>
Re: submit cppwebbrowser
Author: Amidala
Date: Sat, 09 Dec 2006 20:03
Date: Sat, 09 Dec 2006 20:03
140 lines
5288 bytes
5288 bytes
Hi Michael,
thanks for your answer. i tried this code, but in my case it didn't work.
i have an application with one cppwebbrowser and two buttons.
in my first step i load the website with the cppwebbrowser
void __fastcall TForm1::Button1Click(TObject *Sender)
{
CppWebBrowser1->Navigate(WideString("http://portal.commerzbank.de/cocoon/retail/News/News.aspx"));
}
when the site has loaded i type in that field on the left top "CZ4420"
Then i press button2 with remys code, you gave me.
the site reloads, but nothing else happens. when i klick that form by
myself, there appears another site with the information i looked for.
why is that? is there no way to let this submit work the same as a mouse
klick?
amidala
"Michael Harris" <techonos-NO-SPAM-@attbi.com> schrieb im Newsbeitrag
news:457afe08@newsgroups.borland.com...
> Amidala
>
> Remy posted the follwing some time ago
>
> void __fastcall TMain::SubmitForm(void)
> {
> TComInterface<IHTMLDocument2> Doc;
> Browser->Document->QueryInterface(IID_IHTMLDocument2,
> (LPVOID*)&Doc);
> if( Doc )
> {
> TComInterface<IHTMLElementCollection> Forms;
> Doc->get_forms(&Forms);
> if( Forms )
> {
> long count = 0;
> Forms->get_length(&count);
>
> for(long x = 0; x < count; ++x)
> {
> TVariant item = x;
> TVariant index = 0;
> TComInterface<IDispatch> Disp;
>
> Forms->item(item, index, &Disp);
> if( Disp )
> {
> TComInterface<IHTMLFormElement> Form;
> Disp->QueryInterface(IID_IHTMLFormElement,
> (LPVOID*)&Form);
> if( Form )
> {
> ShowMessage("Form Found");
> Form->submit();
> break;
> }
> }
> }
> }
> }
> void __fastcall TMain::SubmitForm(void)
> {
> TComInterface<IHTMLDocument2> Doc;
> Browser->Document->QueryInterface(IID_IHTMLDocument2,
>
> (LPVOID*)&Doc);
> if( Doc )
> {
> TComInterface<IHTMLElementCollection> Forms;
> Doc->get_forms(&Forms);
> if( Forms )
> {
> long count = 0;
> Forms->get_length(&count);
>
> for(long x = 0; x < count; ++x)
> {
> TVariant item = x;
> TVariant index = 0;
> TComInterface<IDispatch> Disp;
>
> Forms->item(item, index, &Disp);
> if( Disp )
> {
> TComInterface<IHTMLFormElement> Form;
> Disp->QueryInterface(IID_IHTMLFormElement,
> (LPVOID*)&Form);
> if( Form )
> {
> ShowMessage("Form Found");
> Form->submit();
> break;
> }
> }
> }
> }
> }
> .
> --
> Michael
>
> "Amidala" <no-spam@tiffie.net> wrote in message
> news:457aeae7@newsgroups.borland.com...
>> hi,
>>
>> i am looking for a possibility to submit a form in cppwebbrowser. in the
>> newsgroups i found some delphi code i tried to convert to c++:
>>
>> CppWebBrowser1->OleObject->Document->All->Item("Form1")->Submit;
>>
>> CppWebBrowser1->OleObject->Document->all->item(OleVariant("Form1"))->Submit();
>>
>> CppWebBrowser1->OleObject->Document->Forms->Item(0)->Submit();
>>
>> None of these exmaples works. I always get these errors:
>>
>> [C++ Fehler] Unit1.cpp(123): E2288 Zeiger auf Struktur auf linker Seite
>> von -> oder von ->* erforderlich
>>
>> Means
>>
>> [C++ Fehler] Unit1.cpp(123): E2288 Pointer to structure on the left site
>> of -> or of ->* needed
>>
>> I have no idea how to solve this problem. can anybody help me?
>>
>> Amidala
>>
>
>
Re: submit cppwebbrowser
Author: Michael Harris
Date: Sat, 09 Dec 2006 20:12
Date: Sat, 09 Dec 2006 20:12
21 lines
1535 bytes
1535 bytes
"Amidala" <no-spam@tiffie.net> wrote in message news:457b1654@newsgroups.borland.com... > Hi Michael, >> the site reloads, but nothing else happens. when i klick that form by > myself, there appears another site with the information i looked for. > > why is that? is there no way to let this submit work the same as a mouse > klick? > > amidala > It may be somethin to do with Form::Submit and clicking the submit button do two seperate things. try enum-ing the element collection until you get the correct button. -- Michael
Re: submit cppwebbrowser
Author: Remy Lebeau (TeamB)
Date: Sun, 10 Dec 2006 06:09
Date: Sun, 10 Dec 2006 06:09
29 lines
2006 bytes
2006 bytes
"Amidala" <no-spam@tiffie.net> wrote in message news:457b1654@newsgroups.borland.com... > i tried this code, but in my case it didn't work. Why not? Please be more specific. The code I posted earlier works just fine to submit forms. I applied it to this situation and it still worked fine. So you are probably just not using it properly. > the site reloads If you pay attention to what that website is actually doing, you have to agree to a separate Disclaimer form before you can reach the actual information page. The same thing happens when you navigate to that website using a normal web browser.. > when i klick that form by myself, there appears another site with the information i looked for. Worked fine for me after I agreed to the disclaimer. > is there no way to let this submit work the same as a mouse klick? That is exactly what the IHTMLFormElement::submit() method does. You are just not submitting enough forms to actually reach the page you are wanting. Gambit
Re: submit cppwebbrowser
Author: Amidala
Date: Sun, 10 Dec 2006 09:54
Date: Sun, 10 Dec 2006 09:54
87 lines
3622 bytes
3622 bytes
hi remy,
could you give me one example how to use it properly?
i tried myself now with this here, but i had no success.
IHTMLDocument2 *HTMLDocument = NULL;
if(SUCCEEDED(CppWebBrowser1->Document->QueryInterface(IID_IHTMLDocument2,
(LPVOID*)&HTMLDocument)))
{
IHTMLElementCollection *HTMLForms = NULL;
if(SUCCEEDED(HTMLDocument->get_forms(&HTMLForms)) && HTMLForms)
{
// form name
TVariant vName = "Form1";
TVariant vIndex = 0;
IDispatch *pDisp = NULL;
if(SUCCEEDED(HTMLForms->item(vName, vIndex, &pDisp)) && pDisp)
{
IHTMLElement *pElement = NULL;
// submit image name
TVariant vName2;
VariantInit(&vName2);
vName2.vt = VT_BSTR;
vName2.bstrVal =
WideString("LeftContainer:FormQuickSearch:btnSubmit").Detach();
TVariant vIndex2 = 0;
if(SUCCEEDED(HTMLForms->item(vName2, vIndex2, &pDisp)))
{
pDisp->QueryInterface(IID_IHTMLElement, &pElement);
pDisp->Release();
}
if(pElement)
{
pElement->click();
pElement->Release();
}
pElement->Release();
}
}
}
amidala
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> schrieb im Newsbeitrag
news:457ba45e$1@newsgroups.borland.com...
>
> "Amidala" <no-spam@tiffie.net> wrote in message
> news:457b1654@newsgroups.borland.com...
>
>> i tried this code, but in my case it didn't work.
>
> Why not? Please be more specific. The code I posted earlier works just
> fine to submit forms. I applied it to this situation and it still worked
> fine. So you are probably just not using it properly.
>
>> the site reloads
>
> If you pay attention to what that website is actually doing, you have to
> agree to a separate Disclaimer form before you can reach the actual
> information page. The same thing happens when you navigate to that
> website
> using a normal web browser..
>
>> when i klick that form by myself, there appears another site with the
> information i looked for.
>
> Worked fine for me after I agreed to the disclaimer.
>
>> is there no way to let this submit work the same as a mouse klick?
>
> That is exactly what the IHTMLFormElement::submit() method does. You are
> just not submitting enough forms to actually reach the page you are
> wanting.
>
>
> Gambit
>
>
Re: submit cppwebbrowser
Author: Remy Lebeau (TeamB)
Date: Sun, 10 Dec 2006 22:35
Date: Sun, 10 Dec 2006 22:35
49 lines
2600 bytes
2600 bytes
"Amidala" <no-spam@tiffie.net> wrote in message
news:457bd937@newsgroups.borland.com...
> could you give me one example how to use it properly?
See further below.
> I tried myself now with this here, but i had no success.
That is because there is a bug in the HTML that is screwing up the browser's
DOM interfaces. The image that you are trying to reach is not a direct
child of the form that you want to submit. There is a hidden text element
in the form that is not closed properly in the HTML, so the image ends up
being a child of that text element instead of the form. Your code is not
taking that into account, which is why it is not working for you.
Rather than going through the form at all, an easier way to reach the image
would be to use the document's "all" collection instead. Then you can reach
the image directly regardless of where it is located in the HTML. For
example.
TComInterface<IHTMLDocument2> Doc;
CppWebBrowser1->Document->QueryInterface(IID_IHTMLDocument2,
(LPVOID*)&Doc);
if( Doc )
{
TComInterface<IHTMLElementCollection> All;
Doc->get_all(&All);
if( All )
{
TVariant item(L"LeftContainer:FormQuickSearch:btnSubmit",
false);
TVariant index = 0;
TComInterface<IDispatch> Disp;
All->item(item, index, &Disp);
TComInterface<IHTMLElement> Img;
if( Disp )
Disp->QueryInterface(IID_IHTMLElement, (LPVOID*)&Img);
if( Img )
Img->click();
}
}
Gambit
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads