수안이의 컴퓨터 연구실

  • Mainpage
  • About Me
  • Tags
  • Metapage
  • Notice
  • Location
  • Keywords
  • Guestbook
  • Admin
  • Write an Article
  • Total | 1695055
  • Today | 800
  • Yesterday | 606

1 Articles, Search for '웹 브라우저'

  1. 2007/01/23 인터넷 웹 브라우저를 만들어보자.
Programming/C#2007/01/23 14:28

인터넷 웹 브라우저를 만들어보자.

[인터넷 웹 브라우저를 만들어보자.]


여기서 설명할 내용은 닷넷 COM구성요소에서 제공하는

컨트롤을 이용하여 웹브라우저를 띄워 보는것이다.


그럼 먼저 새프로젝트를 열고 윈도우즈 응용프로그램을 선택하여보자.

사용자 삽입 이미지


먼저 윈도우폼 프로젝트를 하나 새로 만든다. 그리고 왼쪽 도구상자의 메뉴에서 도구 추가삭제를 선택한다.

그러면 아래 쪽에 Microsoft 웹브라우저라는 컨트롤이 있을것이다. 이 컨트롤을 선택한다.

선택을 하였으면 폼을 디자인 하여 보자.


사용자 삽입 이미지


단순히 텍스트 박스 하나와 웹브라우저 두개를 집어 넣었다.

그럼 이제 KeyPress이벤트로 일어나는 이벤트를 이용하여 웹브라우저를 작동시켜 보겠다.


먼저 텍스트에 주소를 쓰고 Enter를 누르게 되는 타임을 보도록하겠다.

사용자 삽입 이미지


먼저 텍스트 박스에서 KeyPress라는 이벤트를 만든다. 그리고 코드를 살펴보자.

private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)

              {

                      char keyChr = e.KeyChar;//13 = 엔터값입니다.                                      

                      if(keyChr == 13)                     

                      {

                                     Run();                

                      }

              }


키가 눌러지는 순간 누른 Key값의 Value를 체크하게 되고, Run()함수를 부르게 되는것이다.

이제 Run함수를 살펴보기로 하자.


public void Run()

              {

                      // 인자로들어가야 하는 객체들을 초기화합니다.

                      System.Object nullObject = 0;

                      string str = "";

                      System.Object nullObjStr = str;

                     

                      // 커서입니다.

                      Cursor.Current = Cursors.WaitCursor;


                      //  첫번째 인자에 URL을 넣어주면 된다는 것만 기억합시다.

                      axWebBrowser1.Navigate(

                             textBox1.Text, ref nullObject, ref nullObjStr, ref nullObjStr, ref nullObjStr);

                     

                      Cursor.Current = Cursors.Default;

              }



설명을 따로 하지 않아도 Run함수의 주석을 보고 충분히 이해할수 있을것이다.


전체소스


using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;


namespace Explorer

{

   /// <summary>

   /// Form1에 대한 요약 설명입니다.

   /// </summary>

   public class Form1 : System.Windows.Forms.Form

   {

       private System.Windows.Forms.TextBox textBox1;

       private AxSHDocVw.AxWebBrowser axWebBrowser1;

       /// <summary>

       /// 필수 디자이너 변수입니다.

       /// </summary>

       private System.ComponentModel.Container components = null;


       public Form1()

       {

           //

           // Windows Form 디자이너 지원에 필요합니다.

           //

           InitializeComponent();


           //

           // TODO: InitializeComponent를 호출한 다음 생성자 코드를 추가합니다.

           //

       }


       /// <summary>

       /// 사용 중인 모든 리소스를 정리합니다.

       /// </summary>

       protected override void Dispose( bool disposing )

       {

           if( disposing )

           {

               if (components != null)

               {

                   components.Dispose();

               }

           }

           base.Dispose( disposing );

       }


       #region Windows Form 디자이너에서 생성한 코드

       /// <summary>

       /// 디자이너 지원에 필요한 메서드입니다.

       /// 이 메서드의 내용을 코드 편집기로 수정하지 마십시오.

       /// </summary>

       private void InitializeComponent()

       {

           System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));

           this.textBox1 = new System.Windows.Forms.TextBox();

           this.axWebBrowser1 = new AxSHDocVw.AxWebBrowser();

           ((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).BeginInit();

           this.SuspendLayout();

           //

           // textBox1

           //

           this.textBox1.Location = new System.Drawing.Point(8, 16);

           this.textBox1.Name = "textBox1";

           this.textBox1.Size = new System.Drawing.Size(600, 21);

           this.textBox1.TabIndex = 0;

           this.textBox1.Text = "http://www.hoonsbara.com";

           this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);

           //

           // axWebBrowser1

           //

           this.axWebBrowser1.Enabled = true;

           this.axWebBrowser1.Location = new System.Drawing.Point(8, 48);

           this.axWebBrowser1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWebBrowser1.OcxState")));

           this.axWebBrowser1.Size = new System.Drawing.Size(600, 384);

           this.axWebBrowser1.TabIndex = 2;

           //

           // Form1

           //

           this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);

           this.ClientSize = new System.Drawing.Size(616, 437);

           this.Controls.Add(this.axWebBrowser1);

           this.Controls.Add(this.textBox1);

           this.Name = "Form1";

           this.Text = "Explorer";

           ((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).EndInit();

           this.ResumeLayout(false);


       }

       #endregion


       /// <summary>

       /// 해당 응용 프로그램의 주 진입점입니다.

       /// </summary>

       [STAThread]

       static void Main()

       {

           Application.Run(new Form1());

       }



       public void Run()

       {

           // 인자로들어가야 하는 객체들을 초기화합니다.

           System.Object nullObject = 0;

           string str = "";

           System.Object nullObjStr = str;

           

           // 커서입니다.

           Cursor.Current = Cursors.WaitCursor;


           //  첫번째 인자에 URL을 넣어주면 된다는 것만 기억합시다.

           axWebBrowser1.Navigate(

               textBox1.Text, ref nullObject, ref nullObjStr, ref nullObjStr, ref nullObjStr);

           

           Cursor.Current = Cursors.Default;


       }

       private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)

       {

           char keyChr = e.KeyChar;//13 = 엔터값입니다.                        

           if(keyChr == 13)            

           {

                   Run();          

           }

       }

   }

}

 


작성자 : HOONS(박경훈)
이메일 : tajopkh@hanmail.net
홈페이지 : http://www.hoonsbara.com

"C#" 카테고리의 다른 글
  • 움직이는 Text 그래픽을 만들어보자. (0)2007/01/25
  • Low-Level 키보드 입력 후킹 (0)2007/01/25
  • 인터넷 웹 브라우저를 만들어보자. (0)2007/01/23
  • 프로퍼티 그리드 컨트롤을 다루어 보자. (0)2007/01/23
  • 윈도우 종료/재부팅 (0)2006/11/24
2007/01/23 14:28 2007/01/23 14:28
Posted by webdizen
Tags 웹 브라우저
No Trackback No Comment

Trackback URL : http://www.webdizen.net/blog/trackback/2593

Leave your greetings.

[로그인][오픈아이디란?]

«Prev  1  Next»

RSS HanRSS
Blog Image
webdizen
이곳은 컴퓨터에 대해 연구하고, 공유하고, 소통하기 위한 연구실입니다. 개인적으로는 OLAP, Data Mining, Semantic Web, Data Modeling에 대해서 연구하고 있습니다.

Categories

전체 (3009)
Webdizen (141)
Life (6)
Diary (16)
Blog (9)
IDEA (2)
Travel (10)
Book (16)
Photo (7)
Movie (8)
Music (14)
Leisure Sports (10)
Funny (6)
Hardware (121)
Software (120)
Windows (5)
Unix & Linux (120)
Installation (5)
Kernel (10)
System (34)
Develop (22)
X-Window (0)
Applicaton (31)
Security (4)
Framework (2)
Hadoop (2)
Programming (804)
Algorithm & Data Structure (1)
Assembly (38)
UNIX/Linux C (95)
C++ (128)
STL (4)
Java (38)
Win32 API (92)
ATL/COM (44)
MFC (151)
.NET (26)
WCF/WPF (4)
C# (28)
Network Programming (17)
Database Programming (12)
OpenGL / DirectX (13)
Multimedia Programming (0)
Game Programming (21)
Parallel Distributed Progra... (0)
Reverse Engineering (0)
Debugging (9)
Python (1)
Ruby (1)
Ruby on Rails (1)
QT (4)
GTK (0)
JSP (0)
PHP (6)
ASP.NET (6)
ASP (2)
Development (28)
Useful Library (2)
Data Modeling (0)
Database (105)
Oracle (4)
MSSQL (41)
MySQL (2)
Data Warehouse (2)
Data Mining (4)
Network (66)
Web (79)
DHTML (4)
XHTML (1)
Javascript (1)
CSS (1)
AJAX (9)
XML (11)
Flex (1)
Silverlight (3)
Security (91)
DoS (1)
Kernel (10)
Scanning (3)
Sniffing (0)
Spoofing (4)
Overflow (28)
Web (11)
Shell (10)
Format String (14)
Window (2)
Embedded (70)
Multimedia (27)
Mobile (14)
Graphic (24)
Management (633)
Knowledge (581)
Hadoop (0)

Notice

  • 메타 블로그 사이트에 등록
  • 새해 맞이 블로그의 변화
  • 블로그 명칭 변경
  • 도메인(www.webdizen.net) 구...
  • TEXTCUBE 1.6.1로 업그레이드...

Tags

  • COM
  • XML Web Service
  • Data Mart
  • 확장 update
  • 김지원
  • 버퍼 오버런
  • 윈도우 모바일 7.0
  • 리디렉션
  • Office
  • Templates
  • Button
  • 썬라이즈 페파민트
  • 비즈니스 모델
  • multi tasking
  • 빌 게이츠
  • 패키지
  • Error Code
  • C
  • 백업
  • 점유율

Recent Articles

  • 트위터(Twitter)의 시작!.
  • 청년 리더의 조건.
  • 애플의 타블렛 PC - 아이패드....
  • 미래의 인터페이스 - 육감 기....
  • 기초발성법 동영상 강좌.

Recent Comments

  • 경청... 너무나 중요한데.......
    webdizen 14:59
  • 학교 과제물중 쓰레드에 대하....
    장진혁 03/17
  • 관리자만 볼 수 있는 댓글입....
    비밀방문자 03/12
  • 상대방의 이야기를 열심히 경....
    DoNuts 03/03
  • 좋은글 잘 보고 갑니다..
    Und_hacker 01/08

Recent Trackbacks

  • printf,scanf를 이용한 형식....
    yundream의 프로그래밍 이야기 03/10
  • 파일 열기/저장하기 CFileDialog.
    은마군의 나태블록 2009
  • World IT Show 2008.
    상우 :: Oranzie's BLOG 2008
  • cvs서버 설치하기.
    3인3색 2008
  • 속속 공개되는 Google Chart....
    PHP와 Web 2.0 2007

Archive

  • 2010/02 (1)
  • 2010/01 (6)
  • 2009/12 (5)
  • 2009/09 (3)
  • 2009/08 (1)

Calendar

«   2010/03   »
일 월 화 수 목 금 토
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

Bookmarks

    • Administration
      • IIS.NET
      • NTFAQ
      • OS의 모든 것
      • 리눅스포털
    • Database
      • SQL Server Central
      • SQL Team
    • Development
      • .NET Heaven
      • ASP Alliance
      • ASP.NET 2.0
      • Bullog.net
      • C# Corner
      • C++ (C PlusPlus.com)
      • C++ Reference
      • CodeGuru
      • CodePlex
      • DebugLab
      • Dev Articles
      • Devpia
      • DotNet Junkies
      • DotNet Zone
      • Driver Online
      • GOSU.NET
      • HOONS 닷넷
      • Joinc 팀블로그
      • KOSR
      • MSDN Home Page
      • OSR Online
      • Sky.ph - 개발자 커뮤니...
      • TAEYO.NET
      • The Code Project
      • WindowsClient.net
      • 김상욱의 개발자 Side
      • 조인시 위키
    • Human Networks
      • belief21c's e-space
      • I think I can
      • Invisible Rover's Blog :D
      • Polarux - Linuxing
      • Rodman®
      • 까만 나비
      • 나를 가꾸는 시간.
      • 단녕
      • 상우 :: Oranzie's BLOG
    • Information Technology
      • Microsoft TechNet
      • 지디넷코리아 - 글로벌...
    • Security
      • FoundStone
      • milw0rm
      • NewOrder
      • OpenRCE
      • Phrack.org
      • Reverse Engineering b1...
      • Reverse Engineering Team
      • RootKit
      • SecurityFocus
      • SecurityXploded by Nag...
      • Wow Hacker
      • Zone-H
Textcube
Louice Studio Inc.
Powered by Textcube. Original designed by Tistory.