It's just a function name, so it shouldn't matter.
Here's the full code:
using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
using System.Net.Sock ets;
using System.IO;
using System.Text.Reg ularExpressions ;
using System.Web;
using System.Net;
using Routrek.SSHC;
using Routrek.SSHCV2;
namespace ComicViewer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
this.KeyUp += new KeyEventHandler (this.ActiveFor m_KeyUp);
}
void ActiveForm_KeyU p(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Left)
MessageBox.Show ("Left arrow key");
else if (e.KeyData == Keys.Right)
MessageBox.Show ("Right arrow key");
}
DateTime curdate = new DateTime(1978, 06, 19);
DateTime begindate;
int totaldays = 0;
private void Form1_Load(obje ct sender, EventArgs e)
{
loadImage(curda te);
setDate();
// Populate progressbar
TimeSpan numdays = DateTime.Now - curdate;
totaldays = numdays.Days;
begindate = curdate;
progressBar1.Ma ximum = numdays.Days;
progressBar1.Mi nimum = 0;
setProgressBar( );
}
public void setDate()
{
textBox1.Text = curdate.Year.To String();
textBox2.Text = curdate.Month.T oString();
textBox3.Text = curdate.Day.ToS tring();
}
public void setProgressBar( )
{
TimeSpan span = curdate - begindate;
progressBar1.Va lue = span.Days;
toolTip1.SetToo lTip(progressBa r1, "Comic " + span.Days +
"/" + totaldays);
}
public string formatDate(Date Time time)
{
string year = curdate.Year.To String();
year = year.Substring( year.Length - 2);
string month = curdate.Month.T oString().PadLe ft(2, '0');
string day = curdate.Day.ToS tring().PadLeft (2, '0');
return year + month + day;
}
public void loadImage(DateT ime time)
{
try
{
HttpWebRequest req =
(HttpWebRequest )HttpWebRequest .Create("http://192.168.1.12/garfield/garfield_coll/ga"
+ formatDate(time ) + ".gif");
HttpWebResponse res = (HttpWebRespons e)req.GetRespon se();
pictureBox1.Ima ge =
Image.FromStrea m(res.GetRespon seStream());
}
catch (Exception e)
{
button1_Click(n ew object(), new EventArgs());
}
}
private void button2_Click(o bject sender, EventArgs e)
{
curdate = curdate.AddDays (1);
progressBar1.Va lue += 1;
loadImage(curda te);
setDate();
setProgressBar( );
}
private void button1_Click(o bject sender, EventArgs e)
{
curdate = curdate.AddDays (-1);
progressBar1.Va lue -= 1;
loadImage(curda te);
setDate();
setProgressBar( );
}
private void button3_Click(o bject sender, EventArgs e)
{
curdate = DateTime.Parse( textBox1.Text + "/" +
textBox2.Text + "/" + textBox3.Text);
loadImage(curda te);
setDate();
setProgressBar( );
}
private void button4_Click(o bject sender, EventArgs e)
{
using (showLink frm = new showLink())
{
frm.textBox1.Te xt =
"http://images.ucomics. com/comics/ga/" + curdate.Year + "/ga" +
formatDate(curd ate) + ".gif";
frm.textBox1.Up date();
frm.ShowDialog( );
}
}
}
}
Gugale at Lincoln wrote:
Have you renamed the form to ActiveForm? Can you post the entire code?
SG
"Ben" <el*****@gmail. comwrote in message
news:ek******** ******@TK2MSFTN GP06.phx.gbl...
>Gugale at Lincoln wrote:
>>Use KeyData I tried following code and it works.
SG
public partial class Form2 : Form
{
public Form2()
{
InitializeCom ponent();
this.KeyUp += new System.Windows. Forms.KeyEventH andler(this.For m2_KeyUp);
}
private void Form2_KeyUp(obj ect sender, KeyEventArgs e)
{
Console.Write Line(e.KeyData == Keys.Left);
}
}
"Ben" <el*****@gmail. comwrote in message
news:OU****** ********@TK2MSF TNGP06.phx.gbl. ..
Gugale at Lincoln wrote:
May be the event is not reaching the form? Do you get the same problem
when you have an empty form without any child controls?
>
SG
>
"Ben" <el*****@gmail. comwrote in message
news:ud**** **********@TK2M SFTNGP06.phx.gb l...
>Hello,
>>
>I'm trying to catch the pressing of the left and right arrow keys
>through the KeyUp event, like so:
>>
>public Form1()
> {
> InitializeCompo nent();
> Form1.ActiveFor m.KeyUp += new
>KeyEventHa ndler(ActiveFor m_KeyUp);
> }
>>
>void ActiveForm_KeyU p(object sender, KeyEventArgs e)
> {
> if (e.KeyCode == Keys.Left)
> MessageBox.Show ("Left arrow key");
> else if(e.KeyCode == Keys.Right)
> MessageBox.Show ("Right arrow key");
> }
>>
>Yet the event is never called when I press a button. I tried putting
>the event binding in the form load, but that didn't work either.
>>
>Any ideas?
>>
>Thanks,
>Ben
That doesn't work either. I created a whole new project with just an
empty form using about the same code and no luck.
I just tried that, like so:
public Form1()
{
InitializeCompo nent();
this.KeyUp += new KeyEventHandler (this.ActiveFor m_KeyUp);
}
void ActiveForm_KeyU p(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Left)
MessageBox.Show ("Left arrow key");
else if (e.KeyData == Keys.Right)
MessageBox.Show ("Right arrow key");
}
But still no luck.
Odd.