マウスボタンの機能の交換

<マウスユーティリティソフトを作ろう>

宣 言

(Private) Declare Function SwapMouseButton& Lib "user32" (ByVal bSwap As Long)

※Privateは必要に応じて削除またはPublicに変更

引 数 説 明

bSwap

Long

マウスの右ボタンと左ボタンの機能を交換する場合はTrue(左利き用)。元に戻す場合はFalse(右利き用)。このAPIはWindowsのすべてのアプリケーションで有効になります。

サ ン プ ル プ ロ グ ラ ム

まず、VisualBasicを起動してプロジェクトを新しく作成してください。そしてフォームにコマンドボタンを2つ張り付けて、次のコードを貼り付けてください。コマンドボタンを押すとマウスの機能を交換したり元に戻したりします。

動作確認:Visual Basic 5.0(Visual Basic 4.0でも問題なく動作するはずです),Windows98

Private Declare Function SwapMouseButton& Lib "user32" (ByVal bSwap As Long)

Private Sub Command1_Click()
SwapMouseButton False 'マウス機能を通常に戻す
End Sub

Private Sub Command2_Click()
SwapMouseButton True 'マウス機能を逆転
End Sub

Private Sub Form_Load()
'コマンドボタンの文字を変更
Command1.Caption = "通常"
Command2.Caption = "逆転"
End Sub

トップに戻る
Visual Basicワンポイントテクニック目次に戻る

Gポイントポイ活 Amazon Yahoo 楽天

無料ホームページ 楽天モバイル[UNLIMITが今なら1円] 海外格安航空券 海外旅行保険が無料!