|
근데 필요한 헤더파일이 없는거 같은데요.
헤더도 올려주시면 감사하겠습니다.
그리고, 답변해주셔서 감사합니다.
유영인 [Chris] 님이 쓰신 글 :
: 원래는 HTML Direct Link를 위한 소스이지만, 아래쯤에 gongnim님이 원하시는 부분이 있는것 같아보이네요.
:
:
: #include "SHDocVw_OCX.h"
:
: class webBrowser
: {
: IHTMLDocument2Ptr docPtr;
:
: TCppWebBrowser *wb;
:
: bool complete;
:
: public:
: __fastcall webBrowser( TCppWebBrowser *p );
:
: void __fastcall DocComplete( LPDISPATCH lpDisp, TVariant *URL );
: void __fastcall Navigate( BSTR url ) { wb->Navigate( url ); }
: void __fastcall BeforeNavigate() { docPtr.Reset(); }
: bool __fastcall isComplete() { return complete; }
:
: IHTMLElementPtr __fastcall
: GetHTMLElement( IHTMLFormElementPtr const &formElements, LPCSTR
: );
: IHTMLInputElementPtr __fastcall
: GetInputElement( IHTMLFormElementPtr const &formElements,
: LPCSTR );
: IHTMLSelectElementPtr __fastcall
: GetSelectElement( IHTMLFormElementPtr const &formElements,
: LPCSTR );
: IHTMLTextAreaElementPtr __fastcall
: GetTextElement( IHTMLFormElementPtr const &formElements, LPCSTR
: );
: IHTMLFormElementPtr __fastcall GetFormElement();
: HTMLInputFileElementPtr __fastcall
: GetFileElement( IHTMLFormElementPtr const &formElements, LPCSTR
: );
: };
:
:
: // file wbProxy.cpp
: #include <vcl.h>
: #include "mshtml_tlb.h"
: #pragma hdrstop
:
: #include "wbProxy.h"
:
: __fastcall webBrowser::webBrowser( TCppWebBrowser *p ) : wb( p ),
: complete( false )
: {
: }
:
:
: void __fastcall webBrowser::DocComplete( LPDISPATCH lpDisp, TVariant
: *URL )
: {
: IUnknownPtr unkDisp = IWebBrowser2Ptr( wb->ControlInterface, true );
: IUnknownPtr unkDoc = lpDisp;// wb->Document;
: if ( unkDisp == true && (IUnknown*)unkDisp == unkDoc ) {// entire
: document finished
: complete = true;
: IDispatchPtr disp( wb->ControlInterface->get_Document(), false );
: docPtr = disp;
: } else
: complete = false;
: }
:
:
: IHTMLElementPtr __fastcall
: webBrowser::GetHTMLElement( IHTMLFormElementPtr const &formElements,
: LPCSTR name )
: {
: if ( formElements ) {
: // get the item from the collection
: IDispatchPtr disp;
: formElements->item( name, TNoParam(), &disp );
: if ( disp ) {
: // get the input element
: IHTMLElementPtr inputElem = disp;
: return inputElem;
: }
: }
: return IHTMLElementPtr();
: }
:
: IHTMLInputElementPtr __fastcall
: webBrowser::GetInputElement( IHTMLFormElementPtr const &formElements,
: LPCSTR name )
: {
: if ( formElements ) {
: // get the item from the collection
: IDispatchPtr disp;
: formElements->item( name, TNoParam(), &disp );
: if ( disp ) {
: // get the input element
: IHTMLInputElementPtr inputElem = disp;
: return inputElem;
: }
: }
: return IHTMLInputElementPtr();
: }
:
: IHTMLSelectElementPtr __fastcall
: webBrowser::GetSelectElement( IHTMLFormElementPtr const
: &formElements, LPCSTR name )
: {
: if ( formElements ) {
: // get the item from the collection
: IDispatchPtr disp;
: formElements->item( name, TNoParam(), &disp );
: if ( disp ) {
: // get the input element
: IHTMLSelectElementPtr inputElem = disp;
: return inputElem;
: }
: }
: return IHTMLSelectElementPtr();
: }
:
: IHTMLTextAreaElementPtr __fastcall
: webBrowser::GetTextElement( IHTMLFormElementPtr const &formElements,
: LPCSTR name )
: {
: if ( formElements ) {
: // get the item from the collection
: IDispatchPtr disp;
: formElements->item( name, TNoParam(), &disp );
: if ( disp ) {
: // get the input element
: IHTMLTextAreaElementPtr inputElem = disp;
: return inputElem;
: }
: }
: return IHTMLTextAreaElementPtr();
: }
:
: HTMLInputFileElementPtr __fastcall
: webBrowser::GetFileElement( IHTMLFormElementPtr const &formElements,
: LPCSTR name )
: {
: if ( formElements ) {
: // get the item from the collection
: IDispatchPtr disp;
: formElements->item( name, TNoParam(), &disp );
: if ( disp ) {
: // get the input element
: HTMLInputFileElementPtr inputElem = disp;
: return inputElem;
: }
: }
: return HTMLInputFileElementPtr();
: }
:
: IHTMLFormElementPtr __fastcall webBrowser::GetFormElement()
: {
: // get the forms collection
: if ( docPtr ) {
: IHTMLElementCollectionPtr elemColl = docPtr->get_forms();
: if ( elemColl ) {
: // get the first form in the collection
: IDispatchPtr formColl;
: elemColl->item( TNoParam(), 0, &formColl );
: if ( formColl ) {
: // get the collection of all input elements
: IHTMLFormElementPtr formElements = formColl;
: return formElements;
: }
: }
: }
: return IHTMLFormElementPtr();
: }
:
: // here is a function that is the event handler
: void __fastcall TRobot::browserDocumentComplete(TObject *Sender,
: LPDISPATCH pDisp, TVariant *URL)
: {
: // can touch the document ?
: wb.DocComplete( pDisp, URL );
: if ( wb.isComplete() ) {
: StartBtn->Enabled= true;
:
: for ( int i = 0; i < Speed->Position; i++ ) {
: Application->ProcessMessages();
: Sleep( 500 );
: }
: switch ( curPage ) {
: case none:
: curPage = frontPage;
: SubmitFrontPage();
: break;
: case frontPage:
: curPage = toPage;
: SubmitToPage();
: break;
: case toPage:
: curPage = coverPage;
: SubmitCoverPage();
: break;
: case coverPage:
: curPage = docsPage;
: SubmitDocsPage();
: break;
: case docsPage:
: curPage = submitPage;
: SubmitSubmitPage();
: break;
: case submitPage:
: curPage = none;
: Rewind();
: break;
: }
: }
: }
:
: void __fastcall TRobot::SubmitToPage()
: {
: try {
: // obtain and set "f_tofaxnum"
: IHTMLFormElementPtr formElement = wb.GetFormElement();
:
: if ( formElement ) {
: IHTMLInputElementPtr element = wb.GetInputElement( formElement,
: "f_tofaxnum" );
: if ( element ) {
: element->set_value( WideString( faxNo->Text ) );
: }
: element = wb.GetInputElement( formElement, "f_toname" );
: if ( element ) {
: element->set_value( WideString( "Robot" ) );
: }
: element = wb.GetInputElement( formElement, "f_tocompany" );
: if ( element ) {
: element->set_value( WideString( "Robot Company" ) );
: }
: IHTMLSelectElementPtr selEl = wb.GetSelectElement( formElement,
: "f_quality" );
: if ( selEl ) {
: selEl->set_selectedIndex( 1 );
: }
: formElement->submit();
: }
: }
: catch( ... ) {
: ShowMessage( "Error. Please, restart" );
: }
: }
:
:
: gongnim 님이 쓰신 글 :
: : Programming Internet Explorer 5 책이 절판이 되버려서 책을 살수가 없네요. TT
: : 그래서, 패패루님께 or 다른 님들께 요청합니다.
: : 어떻게 하면 Explorer의 엘리먼트를 구할 수 있는지, 참고자료나 샘플이 있으면 구해주세요.
: : 혼자서 맨땅에 헤딩할려니 답답하군요.
: : 그럼이만....
: :
: : --- Change World ---
|