System.Windows.Forms.Form.ProcessKeyPreview(ref System.Windows.Forms.Message)

Here are the examples of the csharp api class System.Windows.Forms.Form.ProcessKeyPreview(ref System.Windows.Forms.Message) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Example 7

1. Example

View license
protected override bool ProcessKeyPreview(ref Message m)
		{
			if (m.Msg != WM_KEYDOWN && m.Msg != WM_KEYUP && m.Msg != WM_CHAR)
				return false;

			if (m.Msg == WM_CHAR)
			{
				if (m_CustomTabbingEnabled && m_ConsumeTab)
				{
					if (m.WParam == (IntPtr)9)
						return true;
					return false;
				}
			}
			else
			{
				bool key_down = m.Msg == WM_KEYDOWN;
				Keys key = (Keys)m.WParam;
				switch (key)
				{
					case Keys.F1:
						if (key_down)
							ShowHelp();
						return true;
					case Keys.F4:
						if (key_down)
						{
							editTitleExpression.Focus();
							m_BackgroundExpressionCompiler.JumpToErrorLocation();
						}
						return true;
					case Keys.Escape:
						if (key_down)
							Close();
						return true;
					case Keys.Tab:
						if (m_CustomTabbingEnabled)
						{
							if (key_down)
							{
								int code = (int)SendMessage(m.HWnd, WM_GETDLGCODE, m.WParam, IntPtr.Zero);
								m_ConsumeTab = 0 == (code & (DLGC_WANTALLKEYS | DLGC_WANTTAB));
								if (m_ConsumeTab)
								{
									bool forward = GetKeyState(Keys.ShiftKey) >= 0;
									ProcessTabKey(forward);
								}
							}
							return m_ConsumeTab;
						}
						break;
				}
			}

			return base.ProcessKeyPreview(ref m);
		}