Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - Eleкtro

#10031
Cita de: HdM en 21 Noviembre 2012, 17:29 PM
Cuando abres la app por 1ª vez, ¿cómo está inicializado My.Settings.Valores ?
No se si te refieres a esto, es Int32, con valor "0"

Cita de: HdM en 21 Noviembre 2012, 17:29 PMPodrías crearte un Sub con el código que metes en el FormClosing y ese Sub meterlo en Load llámandolo antes del CargaPropiedades, si My.Settings.Valores no está inicializado.
¿Y como compruebo si está inicializada?
Yo he intentado un:
Código (vbnet) [Seleccionar]
MsgBox(My.Settings.Valores.ToString())
para ver si es "0", pero no se ejecuta el msgbox (ni el resto de código que sigue debajo).
#10032
Cita de: Novlucker en 21 Noviembre 2012, 17:13 PM
¿Solo son controles que fuiste agregando?
si

Cita de: Novlucker en 21 Noviembre 2012, 17:13 PM
Intenta dando botón derecho sobre la solución, hay una opción de "clean solution" (limpiar solución), y luego vuelve a compilar

Ya lo hice Nov, me borra las dll de la carpeta (en realidad me borra todo lo que haya en la carpeta...), y cuando vuelvo a compilar desde la IDE vuelve a agregar todas esas dll a la carpeta, y no me deja ejecutar el .exe sin esas dll  :xD

Quizás es una tontería pero por si tiene algo que ver, estoy en modo "debug", no "release".

saludos
#10033
Cita de: enriquefemo en 21 Noviembre 2012, 17:17 PMAun no me deja, por lo menos me sale que dejo de responder pero sige sin ir.  :-(

Cita de: raul338 en 21 Noviembre 2012, 16:43 PMNo es que no tengan el visual basic, es que no tienen el .net framework..

@enriquefemo
Si no entendiste esa parte dilo, debes instalar en tu PC (y en los otros) la versión adecuada de Framework...
De todas formas si cambias en las propiedades el framework a 2.0 dudo que te siga sin funcionar en winxp/vista/7/8 ...

http://www.microsoft.com/es-es/download/details.aspx?id=30653
#10034
No soy ningún experto pero en las propiedades del programa puedes requerir una versión inferior del framework:



Saludos
#10035


Todas esas dlls controles en realidad mi app no las utiliza, las añadí a mi form para ver lo que hacian y si me podian servir para algún propósito, pero después de eso las eliminé (usando el botón eliminar)

¿Donde debo borrar los rastros que quedan de esas dll's?

¿Hay alguna extensión para VS2012 que haga esto automáticamente por mi?

Saludos
#10036
Cita de: Keyen Night en 21 Noviembre 2012, 16:54 PM
Coloca el código que esta en Form_Load, nunca digas que no puedes hacer algo, aquí todos comenzamos con Hola Mundo, y como tu puedes ver ya has avanzado ¿o no? ;) No te rindas tan fácilmente se necesita mucha perseverancia para terminar un proyecto precisamente por la paciencia que hay que tener para hallar y solucionar los errores.

Gracias.

Pues mejor pongo todo el form (Aún le estoy retocando lo del Drag&Drop):

Código (vbnet) [Seleccionar]
Imports System.Windows.Forms
Imports System.IO

Public Class Form1
    Dim filesystem As Object, ThisDir As Object
    Dim mcheck(0) As CheckBox
    Dim playerargs As String


#Region "Propertys"

    'userSelectedPlayerFilePath
    Public Property userSelectedPlayerFilePath() As String
        Get
            Return playertextbox.Text
        End Get
        Set(value As String)
            playertextbox.Text = value
        End Set
    End Property

    ' userSelectedFolderPath
    Public Property userSelectedFolderPath() As String
        Get
            Return foldertextbox.Text
        End Get
        Set(value As String)
            foldertextbox.Text = value
        End Set
    End Property

#End Region

#Region "Load / Close"

    ' Form load
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Try

            Me.Text = My.Settings.APPName & " - By Elektro H@cker"

            If Not My.Computer.FileSystem.DirectoryExists(My.Settings.folderpath) Then
                foldertextbox.Text = "Selext a folder..."
                Me.Size = New System.Drawing.Size(362, 228)
                Panel1.Size = New System.Drawing.Size(0, 0)
                My.Settings.folderpath = Nothing
                My.Settings.Save()
            Else
                foldertextbox.Text = My.Settings.folderpath
            End If

            If Not My.Computer.FileSystem.FileExists(My.Settings.playerpath) Then
                playertextbox.Text = "Selext a music player..."
                My.Settings.playerpath = Nothing
                My.Settings.Save()
            Else
                playertextbox.Text = My.Settings.playerpath
            End If

            updatecheckboxes()
            CargarPropiedades()
        Catch

        End Try

    End Sub

    ' Form close
    Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Dim mCheckados(0) As Int32
        Dim Cuantos As Int32 = 0
        Dim empty = Nothing

        For Each c As CheckBox In Panel1.Controls
            empty = "no"
        Next
        If Not empty = "no" Then
            My.Settings.Valores = Nothing
        Else
            For i As Int32 = 0 To mcheck.Length - 1
                If mcheck(i).Checked = True Then
                    Cuantos += 1
                    Array.Resize(mCheckados, Cuantos)
                    mCheckados(Cuantos - 1) = i + 1
                End If
            Next
            My.Settings.Valores = mCheckados
        End If

        My.Settings.Save()
    End Sub

#End Region


#Region "Save / Get settings"

    ' Generate propertys
    Public Sub GenerarPropiedades()
        Dim CheckedN As String = Nothing
        For i As Int32 = 0 To mcheck.Length - 1
            If mcheck(i).Checked = True Then
                CheckedN &= i + 1
            End If
        Next
        My.Settings.Save()
    End Sub

    ' load propertys
    Private Sub CargarPropiedades()
        Dim ListaCheckados As Int32() = My.Settings.Valores
        For i As Int32 = 0 To mcheck.Length - 1
            For Each indiceCheckado As Int32 In ListaCheckados
                mcheck(indiceCheckado - 1).Checked = True
            Next
        Next
    End Sub

#End Region


#Region "Checkboxes"

    ' Checkbox drawing
    Public Sub updatecheckboxes()
        ' delete the old checkboxes
        Panel1.Controls.Clear()
        ' create the new checkboxes
        Dim filesystem = CreateObject("Scripting.FileSystemObject")
        Dim ThisDir = filesystem.GetFolder(My.Settings.folderpath)
        Dim i As Int32 = 0
        Dim pos As Int32 = 10
        For Each folder In ThisDir.Subfolders
            Array.Resize(mcheck, i + 1)
            mcheck(i) = New CheckBox
            With mcheck(i)
                .AutoSize = True
                .Location = New Point(10, pos)
                .Name = "CheckBox" & i + 1
                .Text = folder.Name
            End With
            Me.Panel1.Controls.Add(mcheck(i))
            AddHandler mcheck(i).CheckedChanged, AddressOf LlamadaCheckBox
            i += 1
            pos += 20
        Next

    End Sub

    ' Checkbox events
    Public Sub LlamadaCheckBox(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim filesystem = CreateObject("Scripting.FileSystemObject")
        Dim ThisDir = filesystem.GetFolder(My.Settings.folderpath)
        Dim CheckboxN As CheckBox = CType(sender, CheckBox)
        If CheckboxN.Checked = True Then
            playerargs = playerargs & " " & ControlChars.Quote & Path.Combine(ThisDir.Path, CheckboxN.Text.ToString()) & ControlChars.Quote
        Else
            playerargs = Replace(playerargs, " " & ControlChars.Quote & Path.Combine(ThisDir.Path, CheckboxN.Text.ToString()) & ControlChars.Quote, "")
        End If
    End Sub

#End Region


#Region "Buttons"

    ' Folder button
    Public Sub C1Button3_Click(sender As Object, e As EventArgs) Handles folderbutton.Click
        Dim folderselected As New System.Windows.Forms.FolderBrowserDialog
        Dim Resultado As DialogResult
        folderselected.RootFolder = Environment.SpecialFolder.Desktop
        Resultado = folderselected.ShowDialog
        If Resultado.ToString() = "OK" Then
            userSelectedFolderPath = folderselected.SelectedPath
            My.Settings.folderpath = folderselected.SelectedPath
            My.Settings.Save()
            playerargs = Nothing
            Me.Size = New System.Drawing.Size(362, 540)
            Panel1.Size = New System.Drawing.Size(322, 296)
            updatecheckboxes()
        End If
    End Sub

    ' Player button
    Public Sub C1Button1_Click(sender As Object, e As EventArgs) Handles playerbutton.Click
        Dim playerselected As New OpenFileDialog()
        playerselected.InitialDirectory = Environ("programfiles")
        playerselected.Title = "Select your favorite music player"
        playerselected.Filter = "Music players|bsplayer.exe;mpc.exe;mpc-hc.exe;mpc-hc64.exe;umplayer.exe;vlc.exe;winamp.exe;wmp.exe"
        PlayerDialog.FilterIndex = 1
        Dim selection As System.Windows.Forms.DialogResult = playerselected.ShowDialog()
        If selection = DialogResult.OK Then
            userSelectedPlayerFilePath = playerselected.FileName
            My.Settings.playerpath = playerselected.FileName
            My.Settings.Save()
        End If
    End Sub

    ' Play button
    Public Sub C1Button2_Click(sender As Object, e As EventArgs) Handles playbutton.Click
        If Not playerargs = Nothing Then
            Process.Start(userSelectedPlayerFilePath, playerargs)
            If autoclose.Checked = True Then
                Me.Close()
            End If
        Else
            MessageBox.Show("You must select at least one folder...", My.Settings.APPName)
        End If
    End Sub

    ' Select  ALL checkboxes
    Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles selectall.CheckedChanged
        If selectall.Checked = False Then
            For Each ctrl In Panel1.Controls
                ctrl.Checked = False
            Next
            selectall.Text = "Select all"
        Else
            For Each ctrl In Panel1.Controls
                ctrl.Checked = True
            Next
            selectall.Text = "Unselect all"
        End If
    End Sub

#End Region


#Region "Drag & Drop"




    Private Sub Panel1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel1.DragDrop
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            Dim Objetos As String() = e.Data.GetData(DataFormats.FileDrop)
            Panel1.Text = Objetos(0)
            userSelectedFolderPath = Objetos(0)
            My.Settings.folderpath = Objetos(0)
            My.Settings.Save()
            playerargs = Nothing
            updatecheckboxes()
        End If
    End Sub

    Private Sub Panel1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel1.DragEnter
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            e.Effect = DragDropEffects.All
        End If
    End Sub

   Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles foldertextbox.DragDrop
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            Dim Objetos As String() = e.Data.GetData(DataFormats.FileDrop)

            Dim attributes = Objetos(0)
            If ((attributes And FileAttributes.Directory) = FileAttributes.Directory) Then
                MsgBox("es un dir")
            Else
                MsgBox("no es un dir")
            End If

            foldertextbox.Text = Objetos(0)
            userSelectedFolderPath = Objetos(0)
            My.Settings.folderpath = Objetos(0)
            My.Settings.Save()
            playerargs = Nothing
            updatecheckboxes()
        End If
    End Sub

    Private Sub TextBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles foldertextbox.DragEnter
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            e.Effect = DragDropEffects.All
        End If
    End Sub

#End Region


End Class
#10037
Cita de: DonVidela en 21 Noviembre 2012, 16:47 PM
Es mala practica no controlar los errores, debes manejar todas las excepciones, validar absolutamente todo.

Tienes toda la razón, es mala práctica, pero pienso que para solventar ese tipo de cosas hay que tener mejor dominio del lenguaje, del que tengo yo.

Un saludo!
#10038
Cita de: Keyen Night en 21 Noviembre 2012, 16:31 PM
Esa ventana es aviso de una excepción no controlada, si lees da mucha información acerca de donde y como se dio el error, tienes que revisar el código en el lugar donde te dice que lo hubo, buscando valores inválidos, variables no inicializadas, divisiones por 0, desbordamientos y ese tipo de cosas.

Gracias, pero entonces no se puede desactivar ese tipo de avisos desde el "app.config" o en algún sitio?


EDITO: Te agradezco mucho los datos que me has dado pero no me apetece nada buscar " divisiones por 0, desbordamientos" porque nos e hacerlo, y la app funciona perfectamente aunque el debugger me diga que no.

Lo he arreglado de una manera más fácil, añadiendo una excepción en el form load.  :xD

Un saludo
#10039
Cuando compilo la app y la ejecuto me sale esto:



Pero cuando ejecuto la app desde el IDE no me sale ningún error (Bueno, menos en la consola, me sale una excepción en rojo) pero el programa funciona perfectamente apesar de esa excepción...

¿Hay alguna manera de evitar que salga esa ventana sin tener que investigar dentro del código del form?
#10040
No he podido hacer la comparación entre directorio y archivo, ¿Que estoy haciendo mal?


Código (vbnet) [Seleccionar]
   Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles foldertextbox.DragDrop
       If e.Data.GetDataPresent(DataFormats.FileDrop) Then
           Dim Objetos As String() = e.Data.GetData(DataFormats.FileDrop)

           Dim attributes = Objetos(0)
           If ((attributes And FileAttributes.Directory) = FileAttributes.Directory) Then
               MsgBox("es un dir")
           Else
               MsgBox("no es un dir")
           End If


CitarConversion from string "C:\Users\Administrador\Desktop\W" to type 'Long' is not valid.