按键 !!!! [英] keypress !!!!
问题描述
如何在按任意键的同时循环播放此按钮?它无法在UI窗口中运行!!! VS 2017 C ++
How to break this while loop with any key is press ? it is not working in UI window form !!! VS 2017 C++
while(1)
{
&NBSP;&NBSP;&NBSP; if(kbhit()) // #include< conio.h>
&NBSP;&NBSP;&NBSP; {
&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP; MessageBox :: Show(" Key is pressed"),"Key is pressed",MessageBoxButtons :: OK,MessageBoxIcon :: Information);
&NBSP;&NBSP;&NBSP; }
$
&NBSP;}&NBSP;&NBSP;&NBSP;
while (1)
{
if (kbhit()) // #include<conio.h>
{
MessageBox::Show("Key is pressed"),"Key is pressed",MessageBoxButtons::OK,MessageBoxIcon::Information);
}
}
推荐答案
在UI应用程序中,您不使用kbhit ,scanf,...用于键盘输入。在UI应用程序中,您使用Windows消息队列。
In UI applications you do not use kbhit, scanf, ... for keyboard inputs. In UI applications you use the windows message queue.
我建议您查找Windows窗体的教程(看起来可能是Windows窗体),以了解它背后的概念。
I recommend you look for a tutorial for windows forms (looks like it may be windows forms) to understand the concepts behind it.
一般提示,我不推荐托管C ++应用程序。我建议使用C#,因为当前的Visual Studio版本不支持表单构建器和构建UI应用程序的所有舒适功能。
A general hint, I would not recommend managed C++ applications. I'd recommend C# because the current Visual Studio versions does not support the form builder and all the comfort features for building UI applications.
这篇关于按键 !!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!