VB.NET COde in C++ umsetzen



  • Hallo,

    ich bin neu hier und habe leider keine Ahnung von C++.
    Ich hoffe, das ich mit eure Hilfe ein kleines VB.NET Code in C++ umsetzen kann.

    Gerne würde ich das ganze in MFC also mit einer Oberfläche machen wollen genau wie in VN.NET.
    Der Code in VB.NET schaut so aus:

     Public Class Form1
    
        Dim YMcom As New YMoperation
    
        Protected Overrides Sub WndProc(ByRef m As Message) ' Muss im Hauptfenster bleiben damit wird in Echtzeit festgestellt ob USB steckt oder nicht
    
            Try
                ' The OnDeviceChange routine processes WM_DEVICECHANGE messages.
                If m.Msg = YMcom.Get_WM_DEVICECHANGE() Then
    
                    Label1.Text = YMcom.OnDeviceChangeMain(m).ToString
                    Checkbox1.Checked = False : CheckBox2.Checked = False : CheckBox3.Checked = False : CheckBox4.Checked = False
                    RadioButton1.Checked = False : RadioButton2.Checked = False : RadioButton3.Checked = False : RadioButton4.Checked = False
                    YMcom.ExchangeInPutReports(AddressOf UpdateDeviceResult)
                End If
    
                ' Let the base form process the message.
                MyBase.WndProc(m)
    
            Catch ex As Exception
                MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
    
        End Sub
        Protected Overrides Sub Finalize()
            MyBase.Finalize()
        End Sub
        Private Sub Checkbox1_Click(sender As Object, e As EventArgs) Handles Checkbox1.Click, CheckBox2.Click, CheckBox3.Click, CheckBox4.Click
            YMcom.SEND_COMMAND_TO_DEVICE(Checkbox1.CheckState, CheckBox2.CheckState, CheckBox3.CheckState, CheckBox4.CheckState)
        End Sub
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Checkbox1.Checked = True
            CheckBox2.Checked = True
            CheckBox3.Checked = True
            CheckBox4.Checked = True
    
            YMcom.SEND_COMMAND_TO_DEVICE(Checkbox1.CheckState, CheckBox2.CheckState, CheckBox3.CheckState, CheckBox4.CheckState)
        End Sub
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            Checkbox1.Checked = False
            CheckBox2.Checked = False
            CheckBox3.Checked = False
            CheckBox4.Checked = False
           
            YMcom.SEND_COMMAND_TO_DEVICE(Checkbox1.CheckState, CheckBox2.CheckState, CheckBox3.CheckState, CheckBox4.CheckState)
        End Sub
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
           
            YMcom.SetValues(Me)
    
            Label1.Text = YMcom.FindTheHidMain()
    
            Dim ReadStarted As Boolean = YMcom.ExchangeInPutReports(AddressOf UpdateDeviceResult)
    
            
        End Sub
        Private Sub UpdateDeviceResult(ByVal inputReportBuffer() As Byte)
    
            Invoke(Sub() Checkbox1.CheckState = CType(inputReportBuffer(1), CheckState))
            Invoke(Sub() RadioButton1.Checked = CBool(inputReportBuffer(1)))
    
            Invoke(Sub() CheckBox2.CheckState = CType(inputReportBuffer(2), CheckState))
            Invoke(Sub() RadioButton2.Checked = CBool(inputReportBuffer(2)))
    
            Invoke(Sub() CheckBox3.CheckState = CType(inputReportBuffer(3), CheckState))
            Invoke(Sub() RadioButton3.Checked = CBool(inputReportBuffer(3)))
    
            Invoke(Sub() CheckBox4.CheckState = CType(inputReportBuffer(4), CheckState))
            Invoke(Sub() RadioButton4.Checked = CBool(inputReportBuffer(4)))
    
        End Sub
    
        Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
            YMcom.Infos()
        End Sub
        Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
            Checkbox1.Checked = False : CheckBox2.Checked = False : CheckBox3.Checked = False : CheckBox4.Checked = False
            Dim ReadStarted As Boolean = YMcom.ExchangeInPutReports(AddressOf UpdateDeviceResult)
        End Sub
    
       
        Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
            End
        End Sub
    End Class
    
    
    

    Wer würde mich dabei unterstützen?

    danke im Voraus



  • Das ist doch pures WinAPI Zeugs.
    Inkl. Subclassing etc.

    Ich gehe mal davon aus, dass du NICHT gesucht hast.
    Meine Google Suche ergab sofort x-Beispiel Codes in MFC und C++

    Hier ein Kandidat:
    https://www.codeproject.com/Articles/14500/Detecting-Hardware-Insertion-and-or-Removal