欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#實現(xiàn)鼠標左右鍵切換效果

 更新時間:2022年12月21日 10:02:55   作者:芝麻粒兒  
這篇文章主要為大家詳細介紹了如何利用C#實現(xiàn)鼠標左右鍵切換功能,文中的示例代碼講解詳細,對我們學習C#有一定的幫助,感興趣的小伙伴可以跟隨小編一起了解一下

實踐過程

效果

代碼

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SwapMouseButton")]
    public extern static int SwapMouseButton(int bSwap);

    private void button1_Click(object sender, EventArgs e)
    {
        SwapMouseButton(1);
    }

    private void button2_Click(object sender, EventArgs e)
    {
        SwapMouseButton(0);
    }
}
partial class Form1
{
    /// <summary>
    /// 必需的設計器變量。
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// 清理所有正在使用的資源。
    /// </summary>
    /// <param name="disposing">如果應釋放托管資源,為 true;否則為 false。</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region Windows 窗體設計器生成的代碼

    /// <summary>
    /// 設計器支持所需的方法 - 不要
    /// 使用代碼編輯器修改此方法的內(nèi)容。
    /// </summary>
    private void InitializeComponent()
    {
        this.button1 = new System.Windows.Forms.Button();
        this.button2 = new System.Windows.Forms.Button();
        this.SuspendLayout();
        // 
        // button1
        // 
        this.button1.Location = new System.Drawing.Point(34, 52);
        this.button1.Name = "button1";
        this.button1.Size = new System.Drawing.Size(75, 23);
        this.button1.TabIndex = 0;
        this.button1.Text = "左鍵";
        this.button1.UseVisualStyleBackColor = true;
        this.button1.Click += new System.EventHandler(this.button1_Click);
        // 
        // button2
        // 
        this.button2.Location = new System.Drawing.Point(136, 52);
        this.button2.Name = "button2";
        this.button2.Size = new System.Drawing.Size(75, 23);
        this.button2.TabIndex = 1;
        this.button2.Text = "右鍵";
        this.button2.UseVisualStyleBackColor = true;
        this.button2.Click += new System.EventHandler(this.button2_Click);
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(247, 100);
        this.Controls.Add(this.button2);
        this.Controls.Add(this.button1);
        this.Name = "Form1";
        this.Text = "左右鍵的切換";
        this.ResumeLayout(false);

    }

    #endregion

    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.Button button2;
}

到此這篇關于C#實現(xiàn)鼠標左右鍵切換效果的文章就介紹到這了,更多相關C#鼠標左右鍵切換內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • C#列表List<T>、HashSet和只讀集合介紹

    C#列表List<T>、HashSet和只讀集合介紹

    這篇文章介紹了C#中的列表List<T>、HashSet和只讀集合,文中通過示例代碼介紹的非常詳細。對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-05-05
  • c# Async streams的使用解析

    c# Async streams的使用解析

    這篇文章主要介紹了c# Async streams的使用解析,幫助大家更好的理解和學習使用c#,感興趣的朋友可以了解下
    2021-04-04
  • C# Winform實現(xiàn)石頭剪刀布游戲

    C# Winform實現(xiàn)石頭剪刀布游戲

    這篇文章主要為大家詳細介紹了Winform實現(xiàn)石頭剪刀布游戲,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-01-01
  • C#中重載相等(==)運算符示例

    C#中重載相等(==)運算符示例

    這篇文章主要介紹了C#中重載相等(==)運算符示例,運算符重載一直是一個很詭異事情,本文通過實例探討由運算符重載引出的一個問題,需要的朋友可以參考下
    2015-06-06
  • C#多線程基礎知識匯總

    C#多線程基礎知識匯總

    這篇文章主要介紹了C#多線程基礎知識的相關資料,文中示例代碼非常詳細,幫助大家更好的理解和學習,感興趣的朋友可以了解下
    2020-07-07
  • 利用C#實現(xiàn)獲取當前設備硬件信息

    利用C#實現(xiàn)獲取當前設備硬件信息

    這篇文章主要為大家詳細介紹了如何利用C#實現(xiàn)獲取當前設備硬件信息的功能,文中的示例代碼講解詳細,感興趣的小伙伴可以跟隨小編一起了解一下
    2023-03-03
  • C#實現(xiàn)圖片切割的方法

    C#實現(xiàn)圖片切割的方法

    這篇文章主要介紹了C#實現(xiàn)圖片切割的方法,涉及C#使用Graphics實現(xiàn)圖片屬性的相關設置、保存等操作技巧,需要的朋友可以參考下
    2017-06-06
  • C#基礎:Dispose()、Close()、Finalize()的區(qū)別詳解

    C#基礎:Dispose()、Close()、Finalize()的區(qū)別詳解

    本篇文章是對c#中的Dispose()、Close()、Finalize()的區(qū)別進行了詳細的分析介紹,需要的朋友參考下
    2013-05-05
  • C#實現(xiàn)自定義打印文字和圖片的示例代碼

    C#實現(xiàn)自定義打印文字和圖片的示例代碼

    本文主要介紹了C#實現(xiàn)自定義打印文字和圖片的示例代碼,C#中打印其實就是自己繪圖+調(diào)用系統(tǒng)打印函數(shù),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2022-04-04
  • FtpHelper實現(xiàn)ftp服務器文件讀寫操作(C#)

    FtpHelper實現(xiàn)ftp服務器文件讀寫操作(C#)

    這篇文章主要為大家詳細介紹了FtpHelper實現(xiàn)ftp服務器文件讀寫操作,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-03-03

最新評論