简体   繁体   English

如何确定鼠标左键是否被单击-Visual C#

[英]How to determine of the left mouse button was clicked-visual c#

I'm writing a program in Visual Studio 2012, and I want to check to see if the left mouse button was clicked during a loop. 我正在Visual Studio 2012中编写一个程序,我想检查一下在循环中是否单击了鼠标左键。 For example, 例如,

boolean click1=false;
while (!click1)
{
    // if the left mouse button is clicked, change click1 to true
}

How can I check if the button was pressed? 如何检查按钮是否被按下?

Do you use WinForms or WPF? 您使用WinForms还是WPF? I think you need some Threading there. 我认为您需要在其中添加一些线程。

Anyway you should have a look on Backgroundworker class. 无论如何,您应该看看Backgroundworker类。

http://www.codeproject.com/Articles/99143/BackgroundWorker-Class-Sample-for-Beginners http://www.codeproject.com/Articles/99143/BackgroundWorker-Class-Sample-for-Beginners

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

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