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
[52602] 감사합니다.
방태윤 [nabty] 1958 읽음    2008-03-07 14:35
오!  감사합니다....잘 되는군요...^^

덕분에 하나 해결했습니다.

힌트주신 안영제님도 감사합니다.



장성호 님이 쓰신 글 :
: 감사합니다.
:
: 밑에 안영제님께서 가르쳐주신 참조자료를 보고 힌트를 얻어 해결했습니다.
:
: 이렇게..
: void __fastcall TForm1::Button3Click(TObject *Sender)
: {
:      HRESULT hr;
:
:     IViewObject *ViewObject;
:     hr=CppWebBrowser1->Document->QueryInterface(IID_IViewObject,(void **)&ViewObject);
:    // hr=CppWebBrowser1->DefaultDispatch->QueryInterface(IID_IViewObject,(void **)&ViewObject);
:     //Document 나 DefaultDispatch  둘다 됩니다.
:
:      if (SUCCEEDED(hr))
:      {
:         TRect rc=Rect(0,0,CppWebBrowser1->Width, CppWebBrowser1->Height);
:         Image1->Picture->Bitmap->Width=CppWebBrowser1->Width ;
:         Image1->Picture->Bitmap->Height=CppWebBrowser1->Height;
:         OleCheck(ViewObject->Draw(DVASPECT_CONTENT, 1, NULL, NULL, Form1->Handle, Image1->Picture->Bitmap->Canvas->Handle,(const _RECTL *)&rc, NULL,NULL, 0));
:         Image1->Repaint();
:      }
: }
:
: 그런데 여기서 정말 알고싶은게 하나더 있습니다.
: WebBrowser가  *.ppt 나 *.xls ,  *.pdf등의 문서를 열어볼때..
: 해당문서 프로그램이떠서 WebBroswer안에서 보이는경우에
: WebBroswer가 OLEContainer처럼 동작하는데...
: 이때  word나 Excel 등의 화면을 캡쳐하는 방법을 알고싶습니다.
:
: 비슷한 방법으로 가능할것 같은데....
:
: WebBrowser안에 올라온 OLE오브젝트의 IViewObject  인테페이스만 알수있으면 될것 같은데...
: 무슨방법 없을가요?
:
:
:
:
: 방태윤 님이 쓰신 글 :
: : 아래는 제가 사용하던 소스입니다.하지만 제대로 안되네요..
: :
: : 잌스플로워 6.0 일때는 대부분 사이트는 잘 되는데 어떤 사이스는 잘 안되고 그랬읍니다.
: :
: : 근데 잌스플로워 7.0 깔고는 그나마 안되네요...ㅋ
: :
: : 참고 하시고...실력이 출중하시니...잘 되게 만드셔서 팁란에 좀 올려주시면 감사할께요....^^ 
: :
: : 그럼..
: : 
: :
: :
: : Panel 하나 올리고 그 안에 TCppWebBrowser 넣고 Panel 의 visible=false 로 놓고 쓰던겁니다.ㅋ
: :
: : #include "mshtml.h"
: :
: : //---------------------------------------------------------------------------
: : const IID IID_IHTMLElementRender = {0x3050F669, 0x98B5, 0x11Cf, {0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B}};
: : //---------------------------------------------------------------------------
: :
: : void capture_web_page(AnsiString url_str,Graphics::TBitmap*bmp)
: : {
: :   TCppWebBrowser*w=Form20->CppWebBrowser1;
: :
: :   wchar_t strFilename[MAX_PATH];
: :
: :   MultiByteToWideChar(CP_ACP,0,url_str.c_str(),-1,strFilename,MAX_PATH);
: :   w->Navigate(strFilename);
: :
: :   int tick=::GetTickCount();
: :
: :   //load 가 끝나기를 기다림..
: :   while(w->ReadyState!=Shdocvw_tlb::READYSTATE_COMPLETE){
: :     Application->ProcessMessages();
: :     if(::GetTickCount()-tick>1000*30){
: :       return;
: :     }
: :   }
: :
: :   HRESULT hr;
: :
: :   IHTMLDocument2*pDocument=0;
: :   IDispatch*pDispatch=0;
: :   pDispatch=w->Document;
: :
: :   hr=pDispatch->QueryInterface(IID_IHTMLDocument2,(void**)&pDocument);
: :   if(FAILED(hr))return;
: :   IHTMLElement*pElement=0;
: :   hr=pDocument->get_body(&pElement);
: :   if(FAILED(hr))return;
: :
: :   IHTMLStyle*pStyle=0;
: :   hr=pElement->get_style(&pStyle);
: :   if(FAILED(hr))return;
: :   hr=pStyle->put_border(L"none");
: :   if(FAILED(hr))return;
: :
: :   IHTMLBodyElement*pBodyElement=0;
: :   hr=pElement->QueryInterface(IID_IHTMLBodyElement,(void**)&pBodyElement);
: :   if(FAILED(hr))return;
: :   hr=pBodyElement->put_scroll(L"no");
: :   if(FAILED(hr))return;
: :
: :   IHTMLElement2*pElement2=0;
: :   hr=pElement->QueryInterface(IID_IHTMLElement2,(void**)&pElement2);
: :   if(FAILED(hr))return;
: :
: :   long width;
: :   long height;
: :
: :   hr=pElement2->get_scrollHeight(&height);
: :   if(FAILED(hr))return;
: :   hr=pElement2->get_scrollWidth(&width);
: :   if(FAILED(hr))return;
: :
: :   w->Width=width;
: :   w->Height=height;
: :
: :   IHTMLElementRender*pRender=0;
: :   hr=pElement->QueryInterface(IID_IHTMLElementRender,(void**)&pRender);
: :   if(FAILED(hr))return;
: :
: :   bmp->Width=width;
: :   bmp->Height=height;
: :
: :   pRender->DrawToDC(bmp->Canvas->Handle);
: :
: :   pDocument->Release();
: :   pDispatch->Release();
: :   pElement->Release();
: :   pStyle->Release();
: :   pBodyElement->Release();
: :   pElement2->Release();
: :   pRender->Release();
: :
: :   pDocument=0;
: :   pDispatch=0;
: :   pElement=0;
: :   pStyle=0;
: :   pBodyElement=0;
: :   pElement2=0;
: :   pRender=0;
: : }
: : //---------------------------------------------------------------------------
: : void __fastcall TForm20::Button1Click(TObject *Sender)
: : {
: :   Graphics::TBitmap*p=new Graphics::TBitmap();
: :   capture_web_page("http://www.borlandforum.com",p);
: :   Canvas->Draw(0,0,p);
: :   delete p;
: : }
: : //---------------------------------------------------------------------------
: :
: :
: :
: :
: :
: : 장성호 님이 쓰신 글 :
: : : WebBroswer 이미지를 그대로 TImage에 draw하려고 합니다.
: : :
: : : Delphi에서 TWebBroswer 나 TEmbeddedWB 로는 잘 되던데..
: : : C++Builder에서 TCppWebBrowser로는 잘 안되네요
: : :
: : :
: : :
: : : //델파이 소스
: : : procedure GenerateBitmapfromBrowser2(browser: iWebBrowser2; srcHeight: integer; srcWidth: integer; Image: TImage);
: : : var
: : :   sourceDrawRect : TRect;
: : :   aViewObject   : IViewObject;
: : : begin
: : :   try
: : :
: : :       aViewObject := browser as IViewObject;
: : :
: : :       if aViewObject=nil then
: : :         Exit;
: : :
: : :       Image.Picture.Bitmap.Width:=srcWidth;
: : :       Image.Picture.Bitmap.Height:=srcHeight;
: : :       sourceDrawRect := Rect(0, 0, srcWidth, srcHeight);
: : :
: : :       OleCheck(aViewObject.Draw(DVASPECT_CONTENT, 1, nil, nil,
: : :                                Form1.Handle,
: : :                                Image.Picture.Bitmap.Canvas.Handle,
: : :                                @sourceDrawRect, nil, nil, 0));
: : :
: : :   except
: : :     // error handler code
: : :   end; { try }
: : : end;
: : :
: : : procedure TForm1.CopyBroswerImage();
: : : begin
: : :
: : :     GenerateBitmapfromBrowser2(EmbeddedWB1.ControlInterface,EmbeddedWB1.Height, EmbeddedWB1.Width,Image1);
: : :     Image1.Repaint;
: : :
: : : end;
: : : //----------------------------------------------------------
: : : //C++Builder소스
: : :
: : : void __fastcall GenerateBitmapfromBrowser2(IWebBrowser2 *browser, int  srcHeight,int  srcWidth,TImage *Image)
: : : {
: : :
: : :     IViewObject *ViewObject=(IViewObject *)browser;
: : :     TRect rc=Rect(0,0,srcWidth, srcHeight);
: : :
: : :     if(ViewObject==NULL)return;
: : :
: : :     Image->Picture->Bitmap->Width=srcWidth;
: : :     Image->Picture->Bitmap->Height=srcHeight;
: : :     OleCheck(ViewObject->Draw(DVASPECT_CONTENT, 1, NULL, NULL, Form1->Handle, Image->Picture->Bitmap->Canvas->Handle,(const _RECTL *)&rc, NULL,NULL, 0));
: : : }
: : :
: : :
: : : void __fastcall TForm1::Button3Click(TObject *Sender)
: : : {
: : :     GenerateBitmapfromBrowser2(CppWebBrowser1->ControlInterface,CppWebBrowser1->Height, CppWebBrowser1->Width,Image1);
: : :     Image1->Repaint();
: : : }
: : : //---------------------------------------------------------------------------
: : :
: : :
: : : 두소스의 차이를 보면...
: : :
: : : EmbeddedWB나 TWebBroswer의   ControlInterface 는 IWebBrowser2  인데
: : : TCppWebBrowser 의 ControlInterface 는 IWebBrowser2  가 아닌 IWebBrowser2 Disp 이네요
: : :
: : : COM에 대해서  잘 몰라서..
: : :
: : : TCppWebBrowser 에서는 IWebBrowser2  를 어떻게 가져오죠?

+ -

관련 글 리스트
52582 CppWebBrowser 에서 IWebBrowser2 는? 장성호 2609 2008/03/06
52586     Re:CppWebBrowser 에서 IWebBrowser2 는? 방태윤 2863 2008/03/07
52591         Re:Re:CppWebBrowser 에서 IWebBrowser2 는? 장성호 4155 2008/03/07
52602             감사합니다. 방태윤 1958 2008/03/07
52584     Re:CppWebBrowser 에서 IWebBrowser2 는? civilian 2351 2008/03/06
52585         Re:Re:CppWebBrowser 에서 IWebBrowser2 는? 장성호 1418 2008/03/06
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.