戻る

マウスの左右のボタンの機能を入れ替える方法(API関数SwapMouseButtonの使用例)
動作環境 Windows95/98/2000 開発環境 Visual Basic 6.0 (+SP5)
説明 API関数SwapMouseButtonを使用して、マウスのマウスの左右のボタンの機能を入れ替えます。
用意するもの:標準フォーム(Form1)、コマンドボタン(Command1,Command2)


'変数の明示的な宣言を強制します
Option Explicit

'API関数SwapMouseButtonの利用を宣言します
Private Declare Function SwapMouseButton Lib "user32" (ByVal bSwap As Long) As Long
'引 数:左右のボタンの機能を交換する場合は、True
'    左右のボタンの機能を元に戻す場合は、False
'戻り値:(関数の実行以前に)ボタンの機能が交換されていた場合は、0
'    (関数の実行以前に)ボタンの機能が交換されていなかった場合は、0以外

Private Sub Command1_Click()

Dim ret As Long
'マウスの左右のボタンの機能を入れ替えます
ret = SwapMouseButton(True)

End Sub

Private Sub Command2_Click()

Dim ret As Long
'入れ替えた左右のボタンの機能を元に戻します
ret = SwapMouseButton(False)

End Sub

Private Sub Form_Load()

Command1.Caption = "入れ替える"
Command2.Caption = "元に戻す"

End Sub