A. 如何:区分单击和双击
例如,单击通常选择一个项,而双击编辑所选的项。然而,Windows 窗体单击事件并不能轻松适用于下面这种特定方案,即单击和双击执行的操作不兼容的方案,这是因为连接到 Click 或MouseClick 事件的操作是在连接到 DoubleClick 或MouseDoubleClick 事件的操作之前执行的。此主题阐释此问题的两种解决办法。一种方法是处理双击事件,然后回滚处理单击事件中执行操作。在极少数情况下,您可能需要通过处理 MouseDown 事件,并通过使用 SystemInformation 类的DoubleClickTime 和DoubleClickSize 属性来模拟单击和双击行为。您可以测量两次单击间的时间,如果第二次单击与第一次单击的间隔时间小于 DoubleClickTime 的值,且该单击在 DoubleClickSize 定义的矩形内发生,则执行双击操作;否则,执行单击操作。回滚单击操作确保您正在处理的控件具有标准的双击行为。如果不具有标准双击行为,请用 SetStyle 方法启用控件。然后处理双击事件,并回滚单击操作及双击操作。下面的代码示例阐释如何创建启用双击行为的自定义按钮,及如何在双击事件处理代码中回滚单击操作。C#VBusing System; using System.ComponentModel; using System.Drawing; using System.Text; using System.Windows.Forms; namespace MouseRollBackSingleClick { publicclass Form1 : Form { private DoubleClickButton button1; private FormBorderStyle initialStyle; public Form1() { initialStyle = this.FormBorderStyle; this.ClientSize = new System.Drawing.Size(292, 266); button1 = new DoubleClickButton(); button1.Location = new Point (40,40); button1.Click += new EventHandler(button1_Click); button1.AutoSize = true; this.AllowDrop = true; button1.Text = "Click or Double Click"; button1.DoubleClick += new EventHandler(button1_DoubleClick); this.Controls.Add(button1); } // Handle the double click event.void button1_DoubleClick(object sender, EventArgs e) { // Change the border style back to the initial style.this.FormBorderStyle = initialStyle; MessageBox.Show("Rolled back single click change."); } // Handle the click event.void button1_Click(object sender, EventArgs e) { this.FormBorderStyle = FormBorderStyle.FixedToolWindow; } [STAThread] staticvoid Main() { Application.EnableVisualStyles(); Application.Run(new Form1()); } } publicclass DoubleClickButton : Button { public DoubleClickButton() : base() { // Set the style so a double click event occurs. SetStyle(ControlStyles.StandardClick | ControlStyles.StandardDoubleClick, true); } } } 在MouseDown 事件中区分单击和双击处理MouseDown 事件并确定单击位置和两次单击间的时间间隔,方法是使用适当的 SystemInformation 属性和 Timer 组件。根据发生的是单击还是双击,执行适当的操作。下面的代码示例阐释这是如何实现的。C#C++VBusing System; using System.Drawing; using System.Windows.Forms; namespace SingleVersusDoubleClick { class Form1 : Form { private Rectangle hitTestRectangle = new Rectangle(); private Rectangle doubleClickRectangle = new Rectangle(); private TextBox textBox1 = new TextBox(); private Timer doubleClickTimer = new Timer(); private ProgressBar doubleClickBar = new ProgressBar(); private Label label1 = new Label(); private Label label2 = new Label(); privatebool isFirstClick = true; privatebool isDoubleClick = false; privateint milliseconds = 0; [STAThread] publicstaticvoid Main() { Application.EnableVisualStyles(); Application.Run(new Form1()); } public Form1() { label1.Location = new Point(30, 5); label1.Size = new Size(100, 15); label1.Text = "Hit test rectangle:"; label2.Location = new Point(30, 70); label2.Size = new Size(100, 15); label2.Text = "Double click timer:"; hitTestRectangle.Location = new Point(30, 20); hitTestRectangle.Size = new Size(100, 40); doubleClickTimer.Interval = 100; doubleClickTimer.Tick += new EventHandler(doubleClickTimer_Tick); doubleClickBar.Location = new Point(30, 85); doubleClickBar.Minimum = 0; doubleClickBar.Maximum = SystemInformation.DoubleClickTime; textBox1.Location = new Point(30, 120); textBox1.Size = new Size(200, 100); textBox1.AutoSize = false; textBox1.Multiline = true; this.Paint += new PaintEventHandler(Form1_Paint); this.MouseDown += new MouseEventHandler(Form1_MouseDown); this.Controls.AddRange(new Control[] { doubleClickBar, textBox1, label1, label2 }); } // Detect a valid single click or double click.void Form1_MouseDown(object sender, MouseEventArgs e) { // Verify that the mouse click is in the main hit// test rectangle.if (!hitTestRectangle.Contains(e.Location)) { return; } // This is the first mouse click.if (isFirstClick) { isFirstClick = false; // Determine the location and size of the double click // rectangle area to draw around the cursor point. doubleClickRectangle = new Rectangle( e.X - (SystemInformation.DoubleClickSize.Width / 2), e.Y - (SystemInformation.DoubleClickSize.Height / 2), SystemInformation.DoubleClickSize.Width, SystemInformation.DoubleClickSize.Height); Invalidate(); // Start the double click timer. doubleClickTimer.Start(); } // This is the second mouse click.else { // Verify that the mouse click is within the double click// rectangle and is within the system-defined double // click period.if (doubleClickRectangle.Contains(e.Location) && milliseconds < SystemInformation.DoubleClickTime) { isDoubleClick = true; } } } void doubleClickTimer_Tick(object sender, EventArgs e) { milliseconds += 100; doubleClickBar.Increment(100); // The timer has reached the double click time limit.if (milliseconds >= SystemInformation.DoubleClickTime) { doubleClickTimer.Stop(); if (isDoubleClick) { textBox1.AppendText("Perform double click action"); textBox1.AppendText(Environment.NewLine); } else { textBox1.AppendText("Perform single click action"); textBox1.AppendText(Environment.NewLine); } // Allow the MouseDown event handler to process clicks again. isFirstClick = true; isDoubleClick = false; milliseconds = 0; doubleClickBar.Value = 0; } } // Paint the hit test and double click rectangles.void Form1_Paint(object sender, PaintEventArgs e) { // Draw the border of the main hit test rectangle. e.Graphics.DrawRectangle(Pens.Black, hitTestRectangle); // Fill in the double click rectangle. e.Graphics.FillRectangle(Brushes.Blue, doubleClickRectangle); } } } 请参见其他资源Windows 窗体应用程序中的鼠标输入
B. 单击和双击分别在哪些情况下使用为什么会分单击和双击
单击 选定
双击 执行
也可以改为单击,但这样不好
之所以要有单双击是因为如果不小心一点到鼠标,那它就会执行被点中的程序,如果不小心点了多次,那后果……
双击也要有个速度,如果同于同一个图标间断点击,不管点多少下它还是处于选中的状态而不会执行,这样就安全多了
C. 双击执行exe文件和在命令行下用 start执行有什么不同
你那个EXE执行文件是游戏补丁吧?你的游戏装在哪里,你就把他复制过去,然后照他说的双击PATCH就好啦!
D. 关于C语言中使用system()函数的问题 & 命令行实行exe和双击执行exe的问题
你学了MFC就会明白, 双击exe文件, 实际上是系统用cmd.exe去运行你双击的exe, 运行完后, cmd.exe会自动退出, 但是你自己手动打开了cmd.exe, 它不会自动关闭, 必须你手动来关闭.
E. Windows中双击程序图标和用cmd命令行运行程序是不是原理上第二种更快一点
是的, 操作系统一般有三种接口,所谓接口就是操作界面,类似房子的门,电视机的开机。
1、是GUI窗口,就是你说的双击桌面。
2、是控制台窗口,就是你的cmd命令行。
3、就是API接口,这个是给程序员的。。
你可以修改注册表,把shell程序修改为cmd,这样开机的时候就是cmd窗口。。这种性能差异,主要还是在于系统本身。。因为windows的GUI界面,是完全独立的一个模块。。所以其效率不如控制台,但是在桌面系统中 是很强大的,不像LINUX那样 只是一个应用程序。。
F. python文件双击运行与命令行运行的有什么区别
Linux系统里面,在命令行下面执行下面命令.
chmod +x test.py
这样test.py脚本就有了"可执行"的属性,在GUI里面就能双击运行了.
windows系统里面,如果你已经安装了python,那么直接双击,脚本是会运行的.不过有可能你直接看不到结果.
G. Windows 系统中鼠标单击和双击的区别是什么
鼠标左键通常有单击和双击这两种基本操作,单击的功能一般是对某一个项目的选择,而双击则是表示执行或运行鼠标指针所指向的对象。
通常情况下,双击就是运行或启动在桌面上或资源管理器中显示的某个程序或快捷方式,或者是打开或进入某个文件或文件夹。 而开始菜单和任务栏上的图标及按钮,都是应该通过单击操作来进行选择的。 对于程序窗口中的菜单和工具栏按钮,也同样都是只需单击即可。
而对于现在接触最多的网络应用,则基本不会涉及到双击操作。一般情况下,网页上的所有链接和功能都是单击操作,如果双击就很容易会点击到另外的项目或链接而被跳转到错误的页面或内容。
H. 在其它程序里用WinExec调用可执行文件和直接双击运行该可执行文件有什么区别
程序认为自己的运行环境,也就是路径不同.
你说的不是很清楚,再描述清楚些
I. ubuntu12.04双击执行shell与在终端执行shell的区别
权限问题,直接双击权限仅是其文件夹内部,而终端执行则是全系统的权限,可以检索变量。查找JDK什么的