简体   繁体   English

如何在Borland和VC ++中使用标准C ++创建和处理事件?

[英]How to create and handle events in standard C++ in both Borland and VC++?

Googling didn't provide me any good resource. 谷歌搜索没有给我任何好的资源。

How to create and handle events in standard C++ in both Borland and VC++? 如何在Borland和VC ++中使用标准C ++创建和处理事件? Not in Win32SDK. 不在Win32SDK中。

For example, handling key-press events in standard C++ console applications. 例如,处理标准C ++控制台应用程序中的按键事件。

Please give me some example to get started with. 请给我一些开始的例子。

Also, please provide me with web-links that discuss about events in standard C++ in detail? 另外,请为我提供网络链接,详细讨论标准C ++中的事件?

Moreover, if it is not possible to handle events in standard C++, explain why. 此外,如果无法处理标准C ++中的事件,请解释原因。

I found this link that doesn't explain the code at all. 我发现这个链接根本不解释代码。

You simply can't do this in standard C++ (there are operating systems that don't event know the concept of a console or terminal), so you need to rely on some operating system API. 您根本无法在标准C ++中执行此操作(有些事件的操作系统不知道控制台或终端的概念),因此您需要依赖某些操作系统API。

On Windows, you could use GetNumberOfConsoleInputEvents and ReadConsoleInput . 在Windows上,您可以使用GetNumberOfConsoleInputEventsReadConsoleInput You don't need a special compiler to use these. 您不需要特殊的编译器来使用它们。 There's also good tutorials with examples out there. 还有很好的教程 ,里面有例子。

If you want to be independent of the operating system, you can use a library like curses that abstract from the different underlying mechanisms. 如果您想独立于操作系统,可以使用从不同底层机制中抽象出来的curses之类的库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM