开发者

.Net Compact Framework - add vibration to the button click event

I am wondering if anyone could provide me with a hint for adding vibration to a button's click event. I have been looking around but only found similar examples using the window registry - however I would prefer avoid toching the registry if possible.

Anyone who could provide me with some sample-code to achieve this (C# or VB.Net)?

Thank you.

UPDATE: The code provided by jball works like a charm. I called the code as follows in order to achieve 开发者_如何学Ca short vibration:

Private Sub btnMute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _  
handles btnMute.Click
            SetVibrate(1)
            Thread.Sleep(50) 'how long should the vibration last
            SetVibrate(0)
end sub

Works really great!


It's accessed through the LED API. From here:

On most devices the vibration is set to LED device 1.

Here's the sample code from the same source.

Private Structure NLED_SETTINGS_INFO
    Public LedNum As Integer
    Public OffOnBlink As Integer
    Public TotalCycleTime As Integer
    Public OnTime As Integer
    Public OffTime As Integer
    Public MetaCycleOn As Integer
    Public MetaCycleOff As Integer
End Structure

<DllImport("Coredll")> _
Private Shared Function NLedSetDevice(ByVal deviceId As Integer, ByRef info 
                                            As NLED_SETTINGS_INFO) As Boolean
End Function

Private Shared Sub SetVibrate(ByVal state As Boolean)
    Dim info As New NLED_SETTINGS_INFO()
    info.LedNum = 1
    info.OffOnBlink = If(state, 1, 0)
    NLedSetDevice(1, info)
End Sub
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜