Click here to Skip to main content
15,881,719 members
Home / Discussions / WPF
   

WPF

 
QuestionMove Rectangle with TranslateTransform Pin
Kenneth Haugland4-Feb-15 2:36
mvaKenneth Haugland4-Feb-15 2:36 
AnswerRe: Move Rectangle with TranslateTransform Pin
Kenneth Haugland4-Feb-15 2:59
mvaKenneth Haugland4-Feb-15 2:59 
QuestionA Calendar day to drag and drop Pin
Zorig. A.1-Feb-15 1:45
Zorig. A.1-Feb-15 1:45 
AnswerRe: A Calendar day to drag and drop Pin
Mycroft Holmes1-Feb-15 11:53
professionalMycroft Holmes1-Feb-15 11:53 
QuestionUpdate text of one textbox to multiple textbox using XAML Pin
Ashfaque Hussain26-Jan-15 23:17
Ashfaque Hussain26-Jan-15 23:17 
AnswerRe: Update text of one textbox to multiple textbox using XAML Pin
Richard Deeming27-Jan-15 1:40
mveRichard Deeming27-Jan-15 1:40 
GeneralRe: Update text of one textbox to multiple textbox using XAML Pin
Ashfaque Hussain27-Jan-15 8:13
Ashfaque Hussain27-Jan-15 8:13 
QuestionTrouble setting cooperative level [SharpDX] Pin
Jayme6523-Jan-15 6:00
Jayme6523-Jan-15 6:00 
Hi,
I'm using SharpDX for DirectInput joystick management...and I can't resolve the problem I get while setting cooperative level
VB
Imports SharpDX
Imports SharpDX.DirectInput
Imports System.Windows.Interop

Class MainWindow
    Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
        MainForJoystick()
    End Sub
    '
    Private Shared Sub MainForJoystick()
        ' Initialize DirectInput
        Dim directInput As New DirectInput

        ' Find a Joystick Guid
        Dim joystickGuid = Guid.Empty

        For Each deviceInstance As DeviceInstance In directInput.GetDevices(DeviceType.Gamepad, DeviceEnumerationFlags.AllDevices)
            joystickGuid = deviceInstance.InstanceGuid
        Next

        ' If Gamepad not found, look for a Joystick
        If joystickGuid = Guid.Empty Then
            For Each deviceInstance As DeviceInstance In directInput.GetDevices(DeviceType.Joystick, DeviceEnumerationFlags.AllDevices)
                joystickGuid = deviceInstance.InstanceGuid
            Next
        End If

        ' If Joystick not found, throws an error
        If joystickGuid = Guid.Empty Then
            Debug.Print("No joystick/Gamepad found.")
        End If

        ' Instantiate the joystick
        Dim hwnd As IntPtr = New WindowInteropHelper(Application.Current.MainWindow).EnsureHandle()
        Dim joystick = New Joystick(directInput, joystickGuid)
        joystick.SetCooperativeLevel(hwnd, CooperativeLevel.Foreground)
        Debug.Print("Found Joystick/Gamepad with GUID: {0}", joystickGuid)

        ' Set BufferSize in order to use buffered data.
        joystick.Properties.BufferSize = 128

        ' Acquire the joystick
        joystick.Acquire()

        ' Poll events from joystick
        While True
            joystick.Poll()
            Dim datas = joystick.GetBufferedData()
            For Each state As JoystickUpdate In datas
                Debug.Print(state.ToString)
                ' Example detecting 'Up' button
                If state.Offset = 60 Then
                    If state.Value = 128 Then
                        Debug.Print("Up button pressed")
                    End If
                End If
            Next
        End While
    End Sub
End Class


The problem comes from here:
joystick.SetCooperativeLevel(hwnd, CooperativeLevel.Foreground)

SharpDX.SharpDXException was unhandled
HResult=-2147024809
Message=HRESULT: [0x80070057], Module: [SharpDX.DirectInput], ApiCode: [DIERR_INVALIDPARAM/InvalidParam], Message: Incorrect parameter.

Please would you please help me understand what I'm doing wrong? I've been searching for days to resolve this!!

Many thanks!

modified 23-Jan-15 12:18pm.

QuestionCode only working with break points Pin
Dominick Marciano9-Jan-15 19:14
professionalDominick Marciano9-Jan-15 19:14 
AnswerRe: Code only working with break points Pin
SledgeHammer019-Jan-15 19:15
SledgeHammer019-Jan-15 19:15 
AnswerRe: Code only working with break points Pin
Afzaal Ahmad Zeeshan9-Jan-15 20:29
professionalAfzaal Ahmad Zeeshan9-Jan-15 20:29 
QuestionAnybody using DwmExtendFrameIntoClientArea? Pin
SledgeHammer019-Jan-15 11:59
SledgeHammer019-Jan-15 11:59 
AnswerRe: Anybody using DwmExtendFrameIntoClientArea? Pin
Richard Deeming12-Jan-15 2:31
mveRichard Deeming12-Jan-15 2:31 
GeneralRe: Anybody using DwmExtendFrameIntoClientArea? Pin
SledgeHammer0112-Jan-15 4:52
SledgeHammer0112-Jan-15 4:52 
QuestionWhere to go to learn wpf? Pin
MrGlass35-Jan-15 8:44
MrGlass35-Jan-15 8:44 
AnswerRe: Where to go to learn wpf? Pin
SledgeHammer015-Jan-15 9:59
SledgeHammer015-Jan-15 9:59 
AnswerRe: Where to go to learn wpf? Pin
Mycroft Holmes5-Jan-15 12:11
professionalMycroft Holmes5-Jan-15 12:11 
GeneralRe: Where to go to learn wpf? Pin
SledgeHammer015-Jan-15 12:58
SledgeHammer015-Jan-15 12:58 
GeneralRe: Where to go to learn wpf? Pin
Mycroft Holmes5-Jan-15 13:21
professionalMycroft Holmes5-Jan-15 13:21 
AnswerRe: Where to go to learn wpf? Pin
Richard MacCutchan5-Jan-15 22:43
mveRichard MacCutchan5-Jan-15 22:43 
AnswerRe: Where to go to learn wpf? Pin
Vimalsoft(Pty) Ltd12-Jan-15 20:56
professionalVimalsoft(Pty) Ltd12-Jan-15 20:56 
AnswerRe: Where to go to learn wpf? Pin
Subramanyam Shankar17-Mar-15 1:04
professionalSubramanyam Shankar17-Mar-15 1:04 
QuestionMultithreaded Windows with Data Binding Pin
Dominick Marciano5-Jan-15 8:30
professionalDominick Marciano5-Jan-15 8:30 
AnswerRe: Multithreaded Windows with Data Binding Pin
Afzaal Ahmad Zeeshan9-Jan-15 8:41
professionalAfzaal Ahmad Zeeshan9-Jan-15 8:41 
AnswerRe: Multithreaded Windows with Data Binding Pin
SledgeHammer0111-Jan-15 8:37
SledgeHammer0111-Jan-15 8:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.