[/code]"> [/code]"> [/code]">
[code]public partial class Main : Form
{
private void btGraph_Click(object sender, EventArgs e)
{
Graph WaveGraph = new Graph("Waveform");
other code placing graphics on the form
}
// need to trap arrow keys.
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Up)
{
MessageBox.Show("Up key pressed");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}
class Graph
{
public Graph(string name)
{
GraphForm = new Form();
GraphForm.Name = name;
GraphForm.KeyPress += new KeyPressEventHandler(OnKeyPress);
GraphForm.KeyPreview = true;
}
// The message box never appears
private void OnKeyPress(object sender, KeyPressEventArgs e)
{
string KeyString = e.KeyChar.ToString();
MessageBox.Show("A key was pressed");
return;
}
}[/code]
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w