Sapphire Buttons Utility可以幫助應用程序確認用戶是否按下了一個按鈕。根據所按的按鈕,您可以執行一個指定的功能,或者是顯示一個指定的屏幕。它還能幫助您的用戶避免由于誤按了一個系統應用程序的按鈕而關掉原來的應用程序。
Sapphire Buttons Utility allows your application to identify if a button was pressed by the user. Based on what was pressed, you can perform a specific function or display a specific screen. It also helps your users aviod closing applications by accidentally pressing the button for one of the system applications.
Sapphire Buttons Utility具有以下功能,能夠很方便的讀取按鈕狀態:
- 檢查按了哪個按鈕
- 取得按鈕的名字
- 啟用和禁用系統按鈕
實例代碼 該操作是如此簡單的,您只需在您的程序中聲明相應的DLL函數,然后在您需要的地方調用即可。下列示例展示了在VB.NET里一個簡單的定時器是如何跟蹤哪個按鈕被按下的。
Private Sub tmrButtons_Tick(ByVal sender As System.Object, _ByVal e As System.EventArgs) Handles tmrButtons.Tick
Dim lButton As Integer
Dim lKey1 As Integer
Dim lKey2 As Integer
lButton = sButtons(1234567890, lKey1, lKey2)
If lButton = 0 Then
lblButton.Text = ""
Else
If lKey2 = 0 Then
lblButton.Text = ButtonName(lKey1)
Else
lblButton.Text = ButtonName(lKey1) & " (" & ButtonName(lKey2) & ")"
End If
End If
End Sub
The Sapphire Buttons Utility makes reading the button status easy with the following functionality:
- Check what button is pressed
- Retrieve the button name
- Enable and disable system buttons
Sample Code
Implementation couldn’t be easier, simply declare the DLL function as a function within your application and call it as though you wrote it yourself. Here’s a sample demo to show how a simple timer can keep track of what button was pressed within VB.NET.
Private Sub tmrButtons_Tick(ByVal sender As System.Object, _ByVal e As System.EventArgs) Handles tmrButtons.Tick
Dim lButton As Integer
Dim lKey1 As Integer
Dim lKey2 As Integer
lButton = sButtons(1234567890, lKey1, lKey2)
If lButton = 0 Then
lblButton.Text = ""
Else
If lKey2 = 0 Then
lblButton.Text = ButtonName(lKey1)
Else
lblButton.Text = ButtonName(lKey1) & " (" & ButtonName(lKey2) & ")"
End If
End If
End Sub