0

is there any other way besides

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == Keys.B)
            {
                MessageBox.Show("Enter pressed!");
                String fileName = @"C:/Windows/Media/tada.wav";
                PlaySound(fileName, 0, 1);
                return true;
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }

that to capture key presses i want to beable to capture more than one. for example in my app if you press O the cd tray opens. i want to be aable to press C and it close but for some reason when i try to put that code in there again it gives me an error

any on ideas on code that ould let me do this would be helpful

thankyou

tayspen

Edited by Dani: Fixed formatting

2
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by tayspen
0

Hope this helps

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
		{ 
			bool result = false;
			switch (keyData)
			{
				case(Keys.B):
					MessageBox.Show("Enter pressed!");
					String fileName = @"C:/Windows/Media/tada.wav";
					PlaySound(fileName, 0, 1);
					result = true;
					break;
				case(Keys.O):
					//code to open cd tray here
					result = true;
					break;
				case(Keys.C):
					//code to close cd tray here
					result = true;
					break;
			}
			return result;		}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.