Use the new Gecko UI control class, and add a URL bar, and a Go button. Not part of the build.

git-svn-id: svn://10.0.0.236/trunk@142890 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jst%netscape.com 2003-05-24 06:55:00 +00:00
parent bbc91e4455
commit 16f181704d
2 changed files with 53 additions and 20 deletions

View File

@ -58,8 +58,9 @@ namespace MSDotNETCSEmbed
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.Container components = null; private System.ComponentModel.Container components = null;
private Mozilla.Embedding.Gecko myGecko = null; private Mozilla.Embedding.Gecko gecko1;
private String myURL = null; private System.Windows.Forms.Button goButton;
private System.Windows.Forms.TextBox urlBar;
public MSDotNETCSEmbedForm() public MSDotNETCSEmbedForm()
{ {
@ -71,7 +72,6 @@ namespace MSDotNETCSEmbed
// //
// TODO: Add any constructor code after InitializeComponent call // TODO: Add any constructor code after InitializeComponent call
// //
myGecko = new Gecko(this);
} }
/// <summary> /// <summary>
@ -96,16 +96,49 @@ namespace MSDotNETCSEmbed
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.gecko1 = new Mozilla.Embedding.Gecko();
this.goButton = new System.Windows.Forms.Button();
this.urlBar = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// gecko1
//
this.gecko1.Location = new System.Drawing.Point(0, 40);
this.gecko1.Name = "gecko1";
this.gecko1.Size = new System.Drawing.Size(664, 392);
this.gecko1.TabIndex = 0;
//
// goButton
//
this.goButton.Location = new System.Drawing.Point(600, 8);
this.goButton.Name = "goButton";
this.goButton.Size = new System.Drawing.Size(56, 24);
this.goButton.TabIndex = 1;
this.goButton.Text = "Go";
this.goButton.Click += new System.EventHandler(this.goButton_Click);
//
// urlBar
//
this.urlBar.Location = new System.Drawing.Point(8, 10);
this.urlBar.Name = "urlBar";
this.urlBar.Size = new System.Drawing.Size(576, 20);
this.urlBar.TabIndex = 2;
this.urlBar.Text = "";
this.urlBar.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.urlBar_KeyPress);
// //
// MSDotNETCSEmbedForm // MSDotNETCSEmbedForm
// //
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(744, 374); this.ClientSize = new System.Drawing.Size(664, 429);
this.Name = "MSDotNETCSEmbed"; this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.urlBar,
this.goButton,
this.gecko1});
this.Name = "MSDotNETCSEmbedForm";
this.Text = "MSDotNETCSEmbed [UNSUPPORTED]"; this.Text = "MSDotNETCSEmbed [UNSUPPORTED]";
this.Resize += new System.EventHandler(this.MSDotNETCSEmbedForm_Resize); this.Resize += new System.EventHandler(this.MSDotNETCSEmbedForm_Resize);
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.MSDotNETCSEmbedForm_KeyPress);
this.Load += new System.EventHandler(this.MSDotNETCSEmbedForm_Load); this.Load += new System.EventHandler(this.MSDotNETCSEmbedForm_Load);
this.ResumeLayout(false);
} }
#endregion #endregion
@ -124,31 +157,31 @@ namespace MSDotNETCSEmbed
private void MSDotNETCSEmbedForm_Load(object sender, System.EventArgs e) private void MSDotNETCSEmbedForm_Load(object sender, System.EventArgs e)
{ {
myURL = "www.mozilla.org"; urlBar.Text = "http://www.mozilla.org";
myGecko.OpenURL(myURL); gecko1.OpenURL(urlBar.Text);
this.Text = "MSDotNETCSEmbed [UNSUPPORTED] - " + myURL; this.Text = "MSDotNETCSEmbed [UNSUPPORTED] - " + urlBar.Text;
myURL = "";
} }
private void MSDotNETCSEmbedForm_Resize(object sender, System.EventArgs e) private void MSDotNETCSEmbedForm_Resize(object sender, System.EventArgs e)
{ {
myGecko.Resize(); gecko1.Size =
new Size(ClientSize.Width,
ClientSize.Height - gecko1.Location.Y);
} }
private void MSDotNETCSEmbedForm_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) private void urlBar_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{ {
switch (e.KeyChar) switch (e.KeyChar)
{ {
case '\r': case '\r':
myGecko.OpenURL(myURL); gecko1.OpenURL(urlBar.Text);
myURL = "";
break; break;
}
}
default: private void goButton_Click(object sender, System.EventArgs e)
myURL += e.KeyChar; {
this.Text = "MSDotNETCSEmbed [UNSUPPORTED] - " + myURL; gecko1.OpenURL(urlBar.Text);
break;
}
} }
} }
} }

View File

@ -97,6 +97,6 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="$this.Name"> <data name="$this.Name">
<value>Form1</value> <value>MSDotNETCSEmbedForm</value>
</data> </data>
</root> </root>