導航:首頁 > 程序命令 > 命令執行和雙擊有什麼區別

命令執行和雙擊有什麼區別

發布時間:2022-06-19 07:57:03

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什麼的

閱讀全文

與命令執行和雙擊有什麼區別相關的資料

熱點內容
杭州雲伺服器銷售 瀏覽:533
pdf密碼移除 瀏覽:147
雲迅智創FIL伺服器 瀏覽:939
中間件pdf 瀏覽:276
輸入伺服器上的ip地址怎麼辦啊 瀏覽:295
app道客巴巴如何登錄 瀏覽:87
初中物理課本pdf 瀏覽:339
原神安裝包解壓失敗 瀏覽:347
分期車有不需要解壓的嗎 瀏覽:763
程序員高效軟體 瀏覽:468
十年後程序員的工資還會這么高嗎 瀏覽:404
用氣球解壓玩具教程 瀏覽:327
命令與征服3漢化補丁 瀏覽:941
kali解壓口令 瀏覽:647
單片機數組超出范圍 瀏覽:977
2g的pdf 瀏覽:215
把內存變成文件夾 瀏覽:521
加密大貨幣 瀏覽:380
編程機器人怎麼玩 瀏覽:747
蘋果公司有程序員嗎 瀏覽:272