C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[17576] Re:Re:Explorer의 엘리먼트 구하기
gongnim [gongnim] 1714 읽음    2002-04-15 11:32
근데 필요한 헤더파일이 없는거 같은데요.
헤더도 올려주시면 감사하겠습니다.
그리고, 답변해주셔서 감사합니다.

유영인 [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 ---

+ -

관련 글 리스트
17566 Explorer의 엘리먼트 구하기 gongnim 852 2002/04/15
17572     Re:Explorer의 엘리먼트 구하기 유영인 [Chris] 1538 2002/04/15
17576         Re:Re:Explorer의 엘리먼트 구하기 gongnim 1714 2002/04/15
17577             Re:Re:Re:Explorer의 엘리먼트 구하기 유영인 [Chris] 1366 2002/04/15
17590                 Re:Re:Re:Re:Explorer의 엘리먼트 구하기 gongnim 1194 2002/04/15
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.