Board index » cppbuilder » Clicking an HTMLInputButton with C++Builder
Mitch McInelly
![]() CBuilder Developer |
Clicking an HTMLInputButton with C++Builder2005-02-26 04:47:10 AM cppbuilder63 I am writing an app that prefills applications on the web with information stored in my software. I now understand that I must use the Microsoft DOM to achieve my goals. Now I am trying to get my app to click a submit button on a form after I have prefilled the data. The HTML for the button looks like... <TD align=right vAlign=top><input type=image alt=Submit height=17 src="images/button_submit.gif" width=42 onClick="submitForm();"></TD> And my code looks like this (with apologies to Remy): void __fastcall TMain::PushButton(void) { TComInterface<IHTMLDocument2>Doc; Browser->Document->QueryInterface(IID_IHTMLDocument2,(LPVOID*)&Doc); if( Doc ) { TComInterface<IHTMLElementCollection>All; Doc->get_all(&All); if( All ) { long count = 0; All->get_length(&count); for(long x = 0; x < count; ++x) { TVariant item = x; TVariant index = 0; TComInterface<IDispatch>Disp; All->item(item, index, &Disp); if( Disp ) { TComInterface<IHTMLInputButtonElement>ButtonInput; // I've also tried HTMLButtonElement here.. Disp->QueryInterface(IID_IHTMLInputButtonElement,(LPVOID*)&ButtonInput); if( ButtonInput ) {ShowMessage("Button Found"); // Code goes here to make sure Button is of type Submit TComInterface<IHTMLElement>Element; Disp->QueryInterface(IID_IHTMLElement,(LPVOID*)&Element); // HTMLInputButtonElement has no click() method so I have to revert // back to HTMLElement??? if(Element) {Element->click();} } } } } } } For some reason the button is never found (the ShowMessage never fires). Am I using the wrong element? Thanks for looking. Mitch McInelly |