Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

WPF WebBrowser 컨트롤에서 SHDocVw.IWebBrowser2 인터페이스를 구하는 방법 및 순수 WPF 웹 브라우저 컨트롤 소개

예전에 올라온 질문 중에 답변만 하고 코드를 제공하지 않은 적이 있는데요.

WPF WebBrowser control의 자식 창이 close 되기 전 Navgate 재호출 문제
; https://www.sysnet.pe.kr/3/0/1187

WPF에서 제공되는 WebBrowser의 경우 추상화를 너무 높게 하다 보니 고유의 IWebBrowser2 인터페이스가 가진 기능을 모두 제공하지 않고 있습니다. 하지만 단지 내부적으로 감춰놓은 것일 뿐 WebBrowser 컨트롤 자체가 완전히 새로운 것은 아니기 때문에 다음과 같이 기존 WinForm에서 얻을 수 있었던 IWebBrowser2 인터페이스를 Reflection을 이용해 그대로 가져올 수 있습니다.

<Window x:Class="WebBrowserResourceExceptionTest.BrowserWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Height="500" Width="600">
    <Grid x:Name="xRootGrid">
        <WebBrowser x:Name="xWebBrowser" />
    </Grid>
</Window>


using System.Reflection;
using System.Windows;

namespace WebBrowserResourceExceptionTest
{
    public partial class BrowserWindow : Window
    {
        public BrowserWindow()
        {
            InitializeComponent();
        }

        public bool IsBusy
        {
            get
            {
                PropertyInfo propInfo = this.xWebBrowser.GetType().GetProperty("AxIWebBrowser2",
                     System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                object objValue = propInfo.GetValue(this.xWebBrowser);

                SHDocVw.IWebBrowser2 webBrowser = objValue as SHDocVw.IWebBrowser2;

                return webBrowser.Busy;
            }
        }
    }
}

참고로, SHDocVw.IWebBrowser2 인터페이스는 참조 추가 대화상자에서 COM 객체인 "Microsoft Internet Controls"를 추가해야 합니다.

wpf_webbrowser_interface_1.png

그나저나, 나중에 시간 나면 C/C++에 준하는 사용자 정의를 한번 해봐야겠군요. ^^

WebBrowser Customization (Part 2)
; https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa770042(v=vs.85)




이제나 저제나 기다렸던 마이크로소프트의 순수 WPF WebBrowser 컨트롤이 여전히 안 나오는 지금 상황에 그나마 기쁜 소식이 하나 있습니다. 기다리다 지친 외부 프로그래머들이 chromium을 이용해 순수 WPF 웹 브라우저 컨트롤을 오픈소스로 직접 만들어 공개를 했습니다. (2009년도 소식이군요. ^^)

A Real WPF WebBrowser
; http://chriscavanagh.wordpress.com/2009/08/25/a-real-wpf-webbrowser/

WPF Chromium WebBrowser control
; http://wpfchromium.codeplex.com/ 

위의 글에도 나오지만, (ActiveX를 사용하는 것이 아닌) 완전하게 WPF 컨트롤로 구현된 것이기 때문에 다음과 같은 효과들이 가능하다고 합니다. ^^

wpf_webbrowser_interface_2.png
wpf_webbrowser_interface_3.png
wpf_webbrowser_interface_4.png




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 7/17/2021]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 121  122  123  124  125  126  127  128  [129]  130  131  132  133  134  135  ...
NoWriterDateCnt.TitleFile(s)
2921정성태5/9/201535056개발 환경 구성: 266. 인텔에서 구현한 최대 절전 모드 기능 - Intel® Rapid Start Technology
2920정성태5/9/201525864오류 유형: 290. 디스크 관리자의 파티션 축소 시, There is not enough space available on the disk(s) to complete this operation.
2919정성태5/9/201525921오류 유형: 289. Error: this template attempted to load component assembly 'NuGet.VisualStudio.Interop, ...'
2918정성태5/9/201545009Windows: 111. 복구(Recovery) 파티션 삭제하는 방법 [3]
2917정성태5/9/201535361오류 유형: 288. .NET Framework 4.6이 설치된 경우 "Intel® Rapid Storage Technology (Intel® RST) RAID Driver"가 설치 안 되는 문제 [5]
2916정성태5/9/201536609오류 유형: 287. 레지스트리 권한 오류 - Cannot edit [Registry key name]: Error writing the value's new contents.
2915정성태5/9/201536487개발 환경 구성: 265. TrustedInstaller 권한으로 프로그램 실행시키는 방법 [11]
2914정성태5/9/201533570DDK: 7. 정식 인증서가 있는 경우 Device Driver 서명하는 방법 [2]
2913정성태4/30/201530692.NET Framework: 511. Build 2015 행사에서 소개된 (맥/리눅스/윈도우 용 무료) Visual Studio Code 개발 도구 [8]
2912정성태4/29/201526180오류 유형: 286. VirtualBox에 Windows 8/2012 설치 시 "Error Code: 0x000000C4" 오류 발생
2911정성태4/29/201524771오류 유형: 285. Visual Studio 2015를 제거한 경우 Microsoft.VisualStudio.Web.PageInspector.Loader 어셈블리를 못 찾는 문제 [2]
2910정성태4/29/201528603오류 유형: 284. System.TypeLoadException: Could not load type 'System.Reflection.AssemblySignatureKeyAttribute' from assembly [1]
2909정성태4/29/201524637오류 유형: 283. WCF 연결 오류 - Expected record type 'PreambleAck'
2908정성태4/29/201532642오류 유형: 282. 원격에서 SQL 서버는 연결되지만, SQL Express는 연결되지 않는 경우
2907정성태4/29/201523294.NET Framework: 510. 제네릭(Generic) 인자에 대한 메타데이터 등록 확인
2906정성태4/28/201525495오류 유형: 281. DebugView로 인한 System.Diagnostics.Trace.WriteLine 멈춤(Hang) 현상
2905정성태4/27/201526487오류 유형: 280. HttpResponse.Headers.Add에서 "System.PlatformNotSupportedException: This operation requires IIS integrated pipeline mode." 예외 발생
2904정성태4/27/201530712DDK: 6. ZwTerminateProcess로 프로세스를 종료하는 Device Driver 프로그램 [2]파일 다운로드1
2903정성태4/20/201524808Windows: 110. (무료) 마이크로소프트 온라인 강좌 소개 - Azure에서 제공하는 계정 관리 서비스
2902정성태4/16/201531181Windows: 109. (무료) 마이크로소프트 온라인 강좌 소개 - Active Directory 이해
2901정성태4/15/201527758Windows: 108. (무료) 마이크로소프트 온라인 강좌 소개 - Windows Server 2012 R2 주요 기술 (Hyper-V 관점)
2900정성태3/24/201526463오류 유형: 279. robocopy 오류 - The file cannot be accessed by the system [4]
2899정성태3/24/201534416개발 환경 구성: 264. Visual Studio 2013 솔루션을 2015로 마이그레이션
2898정성태3/24/201525397개발 환경 구성: 263. SharePoint 2013을 Windows Server 2012 R2에 설치
2897정성태3/18/201523502오류 유형: 278. LoadLibrary("...") failed - Invalid access to memory location.
2896정성태3/18/201523260VC++: 90. Visual Studio 2013에서 Visual Basic 6용 ATL Control 제작
... 121  122  123  124  125  126  127  128  [129]  130  131  132  133  134  135  ...