窗体不响应键盘事件。窗体中我已经有了一个button控件,而且我把KeyPreview设置为True。
private:System::Voidon_keypress(System::Object^sender,System::Windows::Forms::KeyPres...
private: System::Void on_keypress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
if(e->KeyChar==safe_cast<wchar_t>(System::Windows::Forms::Keys::Up))
DIRECTION=1;
else if(e->KeyChar==safe_cast<wchar_t>(System::Windows::Forms::Keys::Down))
DIRECTION=1;
else if(e->KeyChar==safe_cast<wchar_t>(System::Windows::Forms::Keys::Left))
DIRECTION=1;
else if(e->KeyChar==safe_cast<wchar_t>(System::Windows::Forms::Keys::Right))
DIRECTION=1;
}
(我在函数中使用了sleep函数,不知有没有影响) 展开
if(e->KeyChar==safe_cast<wchar_t>(System::Windows::Forms::Keys::Up))
DIRECTION=1;
else if(e->KeyChar==safe_cast<wchar_t>(System::Windows::Forms::Keys::Down))
DIRECTION=1;
else if(e->KeyChar==safe_cast<wchar_t>(System::Windows::Forms::Keys::Left))
DIRECTION=1;
else if(e->KeyChar==safe_cast<wchar_t>(System::Windows::Forms::Keys::Right))
DIRECTION=1;
}
(我在函数中使用了sleep函数,不知有没有影响) 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询