1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: Mozilla-sample-code 1.0
5 * Copyright (c) 2002 Netscape Communications Corporation and
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this Mozilla sample software and associated documentation files
10 * (the "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Software, and to permit
13 * persons to whom the Software is furnished to do so, subject to the
14 * following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 * DEALINGS IN THE SOFTWARE.
28 * Roy Yokoyama <yokoyama@netscape.com> (original author)
30 * ***** END LICENSE BLOCK ***** */
34 using System
.Collections
;
35 using System
.ComponentModel
;
36 using System
.Windows
.Forms
;
40 using Mozilla
.Embedding
;
42 namespace MSDotNETCSEmbed
45 /// Summary description for Form1.
47 public class MSDotNETCSEmbedForm
: System
.Windows
.Forms
.Form
50 /// Required designer variable.
52 private System
.ComponentModel
.Container components
= null;
53 private Mozilla
.Embedding
.Gecko gecko1
;
54 private System
.Windows
.Forms
.Button goButton
;
55 private System
.Windows
.Forms
.TextBox urlBar
;
57 public MSDotNETCSEmbedForm()
60 // Required for Windows Form Designer support
62 InitializeComponent();
65 // TODO: Add any constructor code after InitializeComponent call
70 /// Clean up any resources being used.
72 protected override void Dispose( bool disposing
)
76 if (components
!= null)
81 base.Dispose( disposing
);
84 #region Windows Form Designer generated code
86 /// Required method for Designer support - do not modify
87 /// the contents of this method with the code editor.
89 private void InitializeComponent()
91 this.gecko1
= new Mozilla
.Embedding
.Gecko();
92 this.goButton
= new System
.Windows
.Forms
.Button();
93 this.urlBar
= new System
.Windows
.Forms
.TextBox();
98 this.gecko1
.Location
= new System
.Drawing
.Point(0, 40);
99 this.gecko1
.Name
= "gecko1";
100 this.gecko1
.Size
= new System
.Drawing
.Size(664, 392);
101 this.gecko1
.TabIndex
= 0;
105 this.goButton
.Location
= new System
.Drawing
.Point(600, 8);
106 this.goButton
.Name
= "goButton";
107 this.goButton
.Size
= new System
.Drawing
.Size(56, 24);
108 this.goButton
.TabIndex
= 1;
109 this.goButton
.Text
= "Go";
110 this.goButton
.Click
+= new System
.EventHandler(this.goButton_Click
);
114 this.urlBar
.Location
= new System
.Drawing
.Point(8, 10);
115 this.urlBar
.Name
= "urlBar";
116 this.urlBar
.Size
= new System
.Drawing
.Size(576, 20);
117 this.urlBar
.TabIndex
= 2;
118 this.urlBar
.Text
= "";
119 this.urlBar
.KeyPress
+= new System
.Windows
.Forms
.KeyPressEventHandler(this.urlBar_KeyPress
);
121 // MSDotNETCSEmbedForm
123 this.AutoScaleBaseSize
= new System
.Drawing
.Size(5, 13);
124 this.ClientSize
= new System
.Drawing
.Size(664, 429);
125 this.Controls
.AddRange(new System
.Windows
.Forms
.Control
[] {
129 this.Name
= "MSDotNETCSEmbedForm";
130 this.Text
= "MSDotNETCSEmbed [UNSUPPORTED]";
131 this.Resize
+= new System
.EventHandler(this.MSDotNETCSEmbedForm_Resize
);
132 this.Load
+= new System
.EventHandler(this.MSDotNETCSEmbedForm_Load
);
133 this.ResumeLayout(false);
139 /// The main entry point for the application.
144 Application
.Run(new MSDotNETCSEmbedForm());
147 Gecko
.TermEmbedding();
150 private void MSDotNETCSEmbedForm_Load(object sender
, System
.EventArgs e
)
152 urlBar
.Text
= "http://www.mozilla.org";
153 gecko1
.OpenURL(urlBar
.Text
);
154 this.Text
= "MSDotNETCSEmbed [UNSUPPORTED] - " + urlBar
.Text
;
157 private void MSDotNETCSEmbedForm_Resize(object sender
, System
.EventArgs e
)
160 new Size(ClientSize
.Width
,
161 ClientSize
.Height
- gecko1
.Location
.Y
);
164 private void urlBar_KeyPress(object sender
, System
.Windows
.Forms
.KeyPressEventArgs e
)
169 gecko1
.OpenURL(urlBar
.Text
);
175 private void goButton_Click(object sender
, System
.EventArgs e
)
177 gecko1
.OpenURL(urlBar
.Text
);