Use C# to access Microsoft Web Browser component programmati
C# 使用微软网页浏览器控件 译文见:http://blog.csdn.net/Felomeng/archive/2007/05/17/1613495.aspx Summary: This walkthrough demonstrates how to use the Microsoft Web browser control and the Microsoft Document Object Model (DOM) to programmat
C#使用微软网页浏览器控件
译文见:http://blog.csdn.net/Felomeng/archive/2007/05/17/1613495.aspx
Summary: This walkthrough demonstrates how to use the Microsoft Web browser control and the Microsoft Document Object Model (DOM) to programmatically access the elements of any Web page. (3 pages)
To access the DOM programmatically, you import both the Web browser component and references to the methods, properties, and events of the DOM into your C# project. You direct the Web browser to a URL by calling its Navigate method, and you must then wait for the documentation complete event. You obtain the document by casting the Web browser Document property to an IHTMLDocument2 interface object. You can query this object for its collections, such as its link or image collections, which are returned as IHTMLElementCollection objects.
In this walkthrough, you will use the Web browser and DOM to obtain and display all anchors found in a Web page.
To access the DOM programmatically
- Create a new Visual C# Windows Application project named DOM.
The form name defaults to Form1.
- In Solution Explorer, right-click the References folder and select Add Reference.
The Add Reference dialog box opens.
- Click on the .NET tab and double-click the component named Microsoft.mshtml.
- Click OK.
References to the methods, events, and properties of the Microsoft DOM are added to the project.
- Open the Toolbox, right-click any tool, and choose Customize Toolbox.
The Customize Toolbox dialog box opens.
- Click on the COM Components tab and check Microsoft Web Browser.
The Web browser control labeled Explorer is added to the Toolbox components.
- Select the Explorer component and click the open form.
A Web browser component named axWebBrowser1 is added to the form.
- Add a TextBox component above the browser component and a ListBox component below it, accepting the default names of textBox1 and listBox1.
- Add a Button component to the right of listBox1. Change the Text property to "Submit," and accept the default name of button1.
The resulting form should look similar to the following screen shot:
- Double-click on button1.
The button1_Click method is added to the project.
- Replace the body of the button1_Click method with the following bold code:
private void button1_Click(object sender, System.EventArgs e) { <code><strong> object Zero = 0;</strong></code> <code><strong> object EmptyString = "";</strong></code> <code><strong> <span>axWebBrowser1</span>.Navigate(textBox1.Text,</strong></code> <code><strong> ref Zero, ref EmptyString, ref EmptyString, ref EmptyString);</strong></code> }
로그인 후 복사 - Return to the form designer, select the browser component, and click the Events icon in the Properties window.
A list of Web browser events appears.
- Double-click the Document Complete event.
The axWebBrowser1_DocumentComplete event handler is added to the project.
- Add the following bold line of code to the beginning of the file Form1.cs:
using System.Data; <strong>using mshtml;</strong>
로그인 후 복사 - Replace the body of the axWebBrowser1_DocumentComplete event handler with the following code:
private void <span>axWebBrowser1</span>_DocumentComplete( object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e) { <code><strong> IHTMLDocument2 HTMLDocument = </strong></code> <code><strong> (IHTMLDocument2) <span>axWebBrowser1</span>.Document;</strong></code> <code><strong> IHTMLElementCollection links = HTMLDocument.links;</strong></code> <code><strong> listBox1.Items.Clear();</strong></code> <code><strong> foreach (HTMLAnchorElementClass el in links)</strong></code> <code><strong> {</strong></code> <code><strong> listBox1.Items.Add(el.outerHTML);</strong></code> <code><strong> }</strong></code> }
로그인 후 복사 - Press F5 to build and run the project.
The Form1 application appears.
- Type a URL—such as www.msn.com—into the text box and click Submit.
The Web page is displayed in the browser, and a list of its anchors appears in the list box, as shown in the following screen shot.
For more information, see the following topics in the MSDN Library:
- Dynamic HTML (http://msdn.microsoft.com/library/en-us/iisref/html/psdk/asp/eadg39v0.asp)
- IHTMLDocument2 interface (http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/document2/document2.asp)

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











1. Windows 11에서 설정을 엽니다. Win+I 단축키나 다른 방법을 사용할 수 있습니다. 2. 앱 섹션으로 이동하여 앱 및 기능을 클릭합니다. 3. 백그라운드에서 실행되는 것을 방지하려는 애플리케이션을 찾으세요. 점 3개 버튼을 클릭하고 고급 옵션을 선택합니다. 4. [백그라운드 애플리케이션 권한] 섹션을 찾아 원하는 값을 선택하세요. 기본적으로 Windows 11은 전원 최적화 모드를 설정합니다. 이를 통해 Windows는 애플리케이션이 백그라운드에서 작동하는 방식을 관리할 수 있습니다. 예를 들어, 배터리를 절약하기 위해 배터리 절약 모드를 활성화하면 시스템은 모든 앱을 자동으로 닫습니다. 5. 애플리케이션이 백그라운드에서 실행되는 것을 방지하려면 [안함]을 선택합니다. 프로그램이 알림을 보내지 않거나 데이터를 업데이트하지 못하는 경우 등을 확인할 수 있습니다.

DeepSeek은 파일을 PDF로 직접 변환 할 수 없습니다. 파일 유형에 따라 공통 문서 (Word, Excel, PowerPoint) : Microsoft Office, LibreOffice 및 기타 소프트웨어를 사용하여 PDF로 내보내십시오. 이미지 : 이미지 뷰어 또는 이미지 처리 소프트웨어를 사용하여 PDF로 저장하십시오. 웹 페이지 : 브라우저의 "PDF로 인쇄"기능 또는 전용 웹 페이지에서 PDF 도구를 사용하십시오. 드문 형식 : 오른쪽 변환기를 찾아 PDF로 변환하십시오. 올바른 도구를 선택하고 실제 상황에 따라 계획을 개발하는 것이 중요합니다.

Java의 DAO(Data Access Object)는 애플리케이션 코드와 지속성 계층을 분리하는 데 사용되며 다음과 같은 장점이 있습니다. 분리: 애플리케이션 로직에서 독립되어 수정이 쉽습니다. 캡슐화: 데이터베이스 액세스 세부 정보를 숨기고 데이터베이스와의 상호 작용을 단순화합니다. 확장성: 새로운 데이터베이스 또는 지속성 기술을 지원하기 위해 쉽게 확장할 수 있습니다. DAO를 사용하면 애플리케이션은 데이터베이스 세부 정보를 직접 처리하지 않고도 엔터티 생성, 읽기, 업데이트 및 삭제와 같은 데이터베이스 작업을 수행하는 메서드를 호출할 수 있습니다.

앱을 사용하려고 할 때 "카메라 및 마이크에 대한 접근을 허용할 수 없습니다"라는 메시지가 표시됩니까? 일반적으로 필요에 따라 특정 사람에게 카메라 및 마이크 권한을 부여합니다. 단, 권한을 거부할 경우 카메라와 마이크가 작동하지 않으며 대신 이런 오류 메시지가 표시됩니다. 이 문제를 해결하는 것은 매우 기본적이며 1~2분 안에 완료할 수 있습니다. 수정 1 – 카메라, 마이크 권한 제공 설정에서 직접 필요한 카메라 및 마이크 권한을 제공할 수 있습니다. 1단계 - 설정 탭으로 이동합니다. 2단계 – 개인 정보 보호 및 보안 패널을 엽니다. 3단계 - 거기에서 "카메라" 권한을 켭니다. 4단계 - 내부에서 휴대폰 카메라에 대한 권한을 요청한 앱 목록을 찾을 수 있습니다. 5단계 - 지정된 앱의 "카메라"를 엽니다.

Java에서 "필드"는 데이터나 상태를 저장하는 데 사용되는 클래스나 인터페이스의 데이터 멤버입니다. 필드의 속성에는 유형(Java 데이터 유형일 수 있음), 액세스 권한, 정적(인스턴스가 아닌 클래스에 속함), 최종(불변) 및 임시(직렬화되지 않음)가 포함됩니다. 필드는 객체 데이터 저장, 객체 상태 유지 등 클래스나 인터페이스의 상태 정보를 저장하는 데 사용됩니다.

Java 리플렉션 메커니즘을 사용하면 프로그램은 소스 코드를 수정하지 않고도 클래스의 동작을 동적으로 수정할 수 있습니다. Class 객체를 통해 클래스를 조작하면 newInstance()를 통해 인스턴스를 생성하고, 프라이빗 필드 값을 수정하고, 프라이빗 메서드를 호출하는 등의 작업을 수행할 수 있습니다. 그러나 리플렉션은 예상치 못한 동작 및 보안 문제를 일으킬 수 있고 성능 오버헤드가 있으므로 주의해서 사용해야 합니다.

Vue에서 iframe 교차 도메인 문제를 해결하는 방법: CORS: 백엔드 서버에서 CORS 지원을 활성화하고 XMLHttpRequest를 사용하거나 API를 가져와 Vue에서 CORS 요청을 보냅니다. JSONP: 백엔드 서버의 JSONP 엔드포인트를 사용하여 Vue에서 JSONP 스크립트를 동적으로 로드합니다. 프록시 서버: 요청을 전달하도록 프록시 서버를 설정하고, Vue에서 타사 라이브러리(예: axios)를 사용하여 요청을 보내고, 프록시 서버 URL을 설정합니다.

Java 함수 개발 시 일반적인 예외 유형 및 해당 복구 방법 Java 함수를 개발하는 동안 다양한 예외가 발생할 수 있으며 이는 함수의 올바른 실행에 영향을 미칩니다. 다음은 일반적인 예외 유형과 해당 복구 방법입니다. 1. NullPointerException 설명: 초기화되지 않은 개체에 액세스할 때 발생합니다. 수정 사항: 개체를 사용하기 전에 개체가 null이 아닌지 확인하세요. 샘플 코드: try{Stringname=null;System.out.println(name.length());}catch(NullPointerExceptione){
