elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Como proteger una cartera - billetera de Bitcoin


  Mostrar Mensajes
Páginas: 1 ... 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 [893] 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 ... 1236
8921  Programación / .NET (C#, VB.NET, ASP) / Re: [C#] Ocultar varios groupbox en: 4 Junio 2013, 21:57 pm
Te lo he hecho en VBNET, no es nada dificil convertirlo a C#:

Código
  1.    Public Sub Disable_Groupboxes(ByVal Container As ControlCollection, ByVal Visible As Boolean)
  2.        For Each Control As Control In Container
  3.            If TypeOf Control Is GroupBox Then Control.Visible = Visible
  4.        Next
  5.    End Sub

Código
  1. Disable_Groupboxes(Me.Controls, False)

http://converter.telerik.com/

Saludos!
8922  Programación / Programación General / Re: Duda sobre lenguajes en: 4 Junio 2013, 21:42 pm
No sé si me entiendes... no quiero que el lenguaje acepte que cada uno organice el código como le salga de las narices (cosa que Python no hace, sólo daba un ejemplo)

Ahora lo entiendo mejor, creia que solo estaba relacionado con los espacios de los comentarios,
pues VB.NET no permite escribir nada con espacios (ningún keyword), si escribes espacios demás te lo organiza automáticamente, séa lo que séa, menos cadenas de strings cerradas con comillas dobles (obvio) xD.

Pruébalo!

Un saludo.
8923  Programación / Programación General / Re: Duda sobre lenguajes en: 4 Junio 2013, 21:25 pm
No entiendo la lógica de la pregunta.

Python:
Código
  1. print "Hola" # Perfectamente valido...

Los lenguajes permiten líneas de comentario, ya sea encima del bloque, debajo, o al final de una línea,
De hecho unos buenos comentarios es lo que perfecciona la organización del código en si mismo.

De verdad, yo no lo véo lógica a la pregunta, o a lo mejor es que he entendido mal...

...pero desde luego si yo supiera C# hasta cierto punto, ni loco me cambiaria por un lenguaje de scripting, aunque séa Python, de hecho el que menos sería Python porque es demasiado restrictivo y para escribir códigos cortos a lo "pseudo" o para escribir 4 tonterías para probar una cosa pequeña te puedes tirar varios minutos corrigiendo ya que hay que escribirlo todo sin imperfecciones, al más mínimo detalle, sin poder equivocarse en el margen de ni un solo espacio! ...Python será organizado, pero desde luego no lo considero productivo, a la larga hace perder el tiempo.

Saludos!
8924  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 4 Junio 2013, 20:41 pm
Taskbar Hide-Show

Oculta o desoculta la barra de tareas de Windows.

Código
  1. #Region " Taskbar Hide-Show "
  2.  
  3. ' [ Taskbar Hide-Show]
  4. '
  5. ' Examples :
  6. '
  7. ' Taskbar.Hide()
  8. ' Taskbar.Show()
  9.  
  10. #End Region
  11.  
  12. ' Taskbar.vb
  13. #Region " Taskbar Class "
  14.  
  15. ''' <summary>
  16. ''' Helper class for hiding/showing the taskbar and startmenu on
  17. ''' Windows XP and Vista.
  18. ''' </summary>
  19. Public Class Taskbar
  20.  
  21.    <System.Runtime.InteropServices.DllImport("user32.dll")> _
  22.    Private Shared Function GetWindowText(hWnd As IntPtr, text As System.Text.StringBuilder, count As Integer) As Integer
  23.    End Function
  24.    <System.Runtime.InteropServices.DllImport("user32.dll", CharSet:=System.Runtime.InteropServices.CharSet.Auto)> _
  25.    Private Shared Function EnumThreadWindows(threadId As Integer, pfnEnum As EnumThreadProc, lParam As IntPtr) As Boolean
  26.    End Function
  27.    <System.Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True)> _
  28.    Private Shared Function FindWindow(lpClassName As String, lpWindowName As String) As System.IntPtr
  29.    End Function
  30.    <System.Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True)> _
  31.    Private Shared Function FindWindowEx(parentHandle As IntPtr, childAfter As IntPtr, className As String, windowTitle As String) As IntPtr
  32.    End Function
  33.    <System.Runtime.InteropServices.DllImport("user32.dll")> _
  34.    Private Shared Function FindWindowEx(parentHwnd As IntPtr, childAfterHwnd As IntPtr, className As IntPtr, windowText As String) As IntPtr
  35.    End Function
  36.    <System.Runtime.InteropServices.DllImport("user32.dll")> _
  37.    Private Shared Function ShowWindow(hwnd As IntPtr, nCmdShow As Integer) As Integer
  38.    End Function
  39.    <System.Runtime.InteropServices.DllImport("user32.dll")> _
  40.    Private Shared Function GetWindowThreadProcessId(hwnd As IntPtr, lpdwProcessId As Integer) As UInteger
  41.    End Function
  42.  
  43.    Private Const SW_HIDE As Integer = 0
  44.    Private Const SW_SHOW As Integer = 5
  45.  
  46.    Private Const VistaStartMenuCaption As String = "Start"
  47.    Private Shared vistaStartMenuWnd As IntPtr = IntPtr.Zero
  48.    Private Delegate Function EnumThreadProc(hwnd As IntPtr, lParam As IntPtr) As Boolean
  49.  
  50.    ''' <summary>
  51.    ''' Show the taskbar.
  52.    ''' </summary>
  53.    Public Shared Sub Show()
  54.        SetVisibility(True)
  55.    End Sub
  56.  
  57.    ''' <summary>
  58.    ''' Hide the taskbar.
  59.    ''' </summary>
  60.    Public Shared Sub Hide()
  61.        SetVisibility(False)
  62.    End Sub
  63.  
  64.    ''' <summary>
  65.    ''' Sets the visibility of the taskbar.
  66.    ''' </summary>
  67.    Private Shared WriteOnly Property Visible() As Boolean
  68.        Set(value As Boolean)
  69.            SetVisibility(value)
  70.        End Set
  71.    End Property
  72.  
  73.    ''' <summary>
  74.    ''' Hide or show the Windows taskbar and startmenu.
  75.    ''' </summary>
  76.    ''' <param name="show">true to show, false to hide</param>
  77.    Private Shared Sub SetVisibility(show As Boolean)
  78.        ' get taskbar window
  79.        Dim taskBarWnd As IntPtr = FindWindow("Shell_TrayWnd", Nothing)
  80.  
  81.        ' Try the Windows XP TaskBar:
  82.        Dim startWnd As IntPtr = FindWindowEx(taskBarWnd, IntPtr.Zero, "Button", "Start")
  83.  
  84.        If startWnd = IntPtr.Zero Then
  85.            ' Try an alternate way of Windows XP TaskBar:
  86.            startWnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, CType(&HC017, IntPtr), "Start")
  87.        End If
  88.  
  89.        If startWnd = IntPtr.Zero Then
  90.            ' Try the Windows Vista/7 TaskBar:
  91.            startWnd = FindWindow("Button", Nothing)
  92.  
  93.            If startWnd = IntPtr.Zero Then
  94.                ' Try an alternate way of Windows Vista/7 TaskBar:
  95.                startWnd = GetVistaStartMenuWnd(taskBarWnd)
  96.            End If
  97.        End If
  98.  
  99.        ShowWindow(taskBarWnd, If(show, SW_SHOW, SW_HIDE))
  100.        ShowWindow(startWnd, If(show, SW_SHOW, SW_HIDE))
  101.  
  102.    End Sub
  103.  
  104.    ''' <summary>
  105.    ''' Returns the window handle of the Vista start menu orb.
  106.    ''' </summary>
  107.    ''' <param name="taskBarWnd">windo handle of taskbar</param>
  108.    ''' <returns>window handle of start menu</returns>
  109.    Private Shared Function GetVistaStartMenuWnd(taskBarWnd As IntPtr) As IntPtr
  110.        ' get process that owns the taskbar window
  111.        Dim procId As Integer
  112.        GetWindowThreadProcessId(taskBarWnd, procId)
  113.  
  114.        Dim p As Process = Process.GetProcessById(procId)
  115.        If p IsNot Nothing Then
  116.            ' enumerate all threads of that process...
  117.            For Each t As ProcessThread In p.Threads
  118.                EnumThreadWindows(t.Id, AddressOf MyEnumThreadWindowsProc, IntPtr.Zero)
  119.            Next
  120.        End If
  121.        Return vistaStartMenuWnd
  122.    End Function
  123.  
  124.    ''' <summary>
  125.    ''' Callback method that is called from 'EnumThreadWindows' in 'GetVistaStartMenuWnd'.
  126.    ''' </summary>
  127.    ''' <param name="hWnd">window handle</param>
  128.    ''' <param name="lParam">parameter</param>
  129.    ''' <returns>true to continue enumeration, false to stop it</returns>
  130.    Private Shared Function MyEnumThreadWindowsProc(hWnd As IntPtr, lParam As IntPtr) As Boolean
  131.        Dim buffer As New System.Text.StringBuilder(256)
  132.        If GetWindowText(hWnd, buffer, buffer.Capacity) > 0 Then
  133.            Console.WriteLine(buffer)
  134.            If buffer.ToString() = VistaStartMenuCaption Then
  135.                vistaStartMenuWnd = hWnd
  136.                Return False
  137.            End If
  138.        End If
  139.        Return True
  140.    End Function
  141.  
  142. End Class
  143.  
  144. #End Region
8925  Programación / .NET (C#, VB.NET, ASP) / Re: Ayuda para traducir una función anónima de C# a VBNET en: 4 Junio 2013, 20:13 pm
Bueno, aquí les dejo el código convertido a vbnet, ya lo conseguí:

Código
  1. Imports System
  2. Imports System.Text
  3. Imports System.Runtime.InteropServices
  4. Imports System.Diagnostics
  5.  
  6. Namespace TaskbarHide
  7.    ''' <summary>
  8.    ''' Helper class for hiding/showing the taskbar and startmenu on
  9.    ''' Windows XP and Vista.
  10.    ''' </summary>
  11.    Public NotInheritable Class Taskbar
  12.        Private Sub New()
  13.        End Sub
  14.        <DllImport("user32.dll")> _
  15.        Private Shared Function GetWindowText(hWnd As IntPtr, text As StringBuilder, count As Integer) As Integer
  16.        End Function
  17.        <DllImport("user32.dll", CharSet:=CharSet.Auto)> _
  18.        Private Shared Function EnumThreadWindows(threadId As Integer, pfnEnum As EnumThreadProc, lParam As IntPtr) As Boolean
  19.        End Function
  20.        <DllImport("user32.dll", SetLastError:=True)> _
  21.        Private Shared Function FindWindow(lpClassName As String, lpWindowName As String) As System.IntPtr
  22.        End Function
  23.        <DllImport("user32.dll", SetLastError:=True)> _
  24.        Private Shared Function FindWindowEx(parentHandle As IntPtr, childAfter As IntPtr, className As String, windowTitle As String) As IntPtr
  25.        End Function
  26.        <DllImport("user32.dll")> _
  27.        Private Shared Function FindWindowEx(parentHwnd As IntPtr, childAfterHwnd As IntPtr, className As IntPtr, windowText As String) As IntPtr
  28.        End Function
  29.        <DllImport("user32.dll")> _
  30.        Private Shared Function ShowWindow(hwnd As IntPtr, nCmdShow As Integer) As Integer
  31.        End Function
  32.        <DllImport("user32.dll")> _
  33.        Private Shared Function GetWindowThreadProcessId(hwnd As IntPtr, lpdwProcessId As Integer) As UInteger
  34.        End Function
  35.  
  36.        Private Const SW_HIDE As Integer = 0
  37.        Private Const SW_SHOW As Integer = 5
  38.  
  39.        Private Const VistaStartMenuCaption As String = "Start"
  40.        Private Shared vistaStartMenuWnd As IntPtr = IntPtr.Zero
  41.        Private Delegate Function EnumThreadProc(hwnd As IntPtr, lParam As IntPtr) As Boolean
  42.  
  43.        ''' <summary>
  44.        ''' Show the taskbar.
  45.        ''' </summary>
  46.        Public Shared Sub Show()
  47.            SetVisibility(True)
  48.        End Sub
  49.  
  50.        ''' <summary>
  51.        ''' Hide the taskbar.
  52.        ''' </summary>
  53.        Public Shared Sub Hide()
  54.            SetVisibility(False)
  55.        End Sub
  56.  
  57.        ''' <summary>
  58.        ''' Sets the visibility of the taskbar.
  59.        ''' </summary>
  60.        Public Shared WriteOnly Property Visible() As Boolean
  61.            Set(value As Boolean)
  62.                SetVisibility(value)
  63.            End Set
  64.        End Property
  65.  
  66.        ''' <summary>
  67.        ''' Hide or show the Windows taskbar and startmenu.
  68.        ''' </summary>
  69.        ''' <param name="show">true to show, false to hide</param>
  70.        Private Shared Sub SetVisibility(show As Boolean)
  71.            ' get taskbar window
  72.            Dim taskBarWnd As IntPtr = FindWindow("Shell_TrayWnd", Nothing)
  73.  
  74.            ' try it the WinXP way first...
  75.            Dim startWnd As IntPtr = FindWindowEx(taskBarWnd, IntPtr.Zero, "Button", "Start")
  76.  
  77.            If startWnd = IntPtr.Zero Then
  78.                ' try an alternate way, as mentioned on CodeProject by Earl Waylon Flinn
  79.                startWnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, CType(&HC017, IntPtr), "Start")
  80.            End If
  81.  
  82.            If startWnd = IntPtr.Zero Then
  83.                ' ok, let's try the Vista easy way...
  84.                startWnd = FindWindow("Button", Nothing)
  85.  
  86.                If startWnd = IntPtr.Zero Then
  87.                    ' no chance, we need to to it the hard way...
  88.                    startWnd = GetVistaStartMenuWnd(taskBarWnd)
  89.                End If
  90.            End If
  91.  
  92.            ShowWindow(taskBarWnd, If(show, SW_SHOW, SW_HIDE))
  93.            ShowWindow(startWnd, If(show, SW_SHOW, SW_HIDE))
  94.        End Sub
  95.  
  96.        ''' <summary>
  97.        ''' Returns the window handle of the Vista start menu orb.
  98.        ''' </summary>
  99.        ''' <param name="taskBarWnd">windo handle of taskbar</param>
  100.        ''' <returns>window handle of start menu</returns>
  101.        Private Shared Function GetVistaStartMenuWnd(taskBarWnd As IntPtr) As IntPtr
  102.            ' get process that owns the taskbar window
  103.            Dim procId As Integer
  104.            GetWindowThreadProcessId(taskBarWnd, procId)
  105.  
  106.            Dim p As Process = Process.GetProcessById(procId)
  107.            If p IsNot Nothing Then
  108.                ' enumerate all threads of that process...
  109.                For Each t As ProcessThread In p.Threads
  110.                    EnumThreadWindows(t.Id, AddressOf MyEnumThreadWindowsProc, IntPtr.Zero)
  111.                Next
  112.            End If
  113.            Return vistaStartMenuWnd
  114.        End Function
  115.  
  116.        ''' <summary>
  117.        ''' Callback method that is called from 'EnumThreadWindows' in 'GetVistaStartMenuWnd'.
  118.        ''' </summary>
  119.        ''' <param name="hWnd">window handle</param>
  120.        ''' <param name="lParam">parameter</param>
  121.        ''' <returns>true to continue enumeration, false to stop it</returns>
  122.        Private Shared Function MyEnumThreadWindowsProc(hWnd As IntPtr, lParam As IntPtr) As Boolean
  123.            Dim buffer As New StringBuilder(256)
  124.            If GetWindowText(hWnd, buffer, buffer.Capacity) > 0 Then
  125.                Console.WriteLine(buffer)
  126.                If buffer.ToString() = VistaStartMenuCaption Then
  127.                    vistaStartMenuWnd = hWnd
  128.                    Return False
  129.                End If
  130.            End If
  131.            Return True
  132.        End Function
  133.    End Class
  134. End Namespace
8926  Programación / .NET (C#, VB.NET, ASP) / Ayuda para traducir una función anónima de C# a VBNET en: 4 Junio 2013, 19:19 pm
Hola

No puedo hallar la manera de traducir esta línea de código por mi mismo, espero que puedan ayudarme.

El problema es en este For, que se usa la función anónima "MyEnumThreadWindowsProc" como un argumento, sin pasarle argumentos a dicha función, y esto no sé traducirlo a VBNET.

Código
  1. foreach (ProcessThread t in p.Threads)
  2. {
  3.  EnumThreadWindows(t.Id, MyEnumThreadWindowsProc, IntPtr.Zero);
  4. }

Los traductores no saben traducirlo corréctamente, y obtengo este reusltado:

Código
  1. For Each t As ProcessThread In p.Threads
  2.  EnumThreadWindows(t.Id, MyEnumThreadWindowsProc, IntPtr.Zero)
  3. Next

Según una persona me ha comentado hace poco, esto podría ser una solución:
Código
  1.   For Each t As ProcessThread In p.Threads
  2.  Dim returnMyEnumThreadWindowsProc As Object
  3.  returnMyEnumThreadWindowsProc = MyEnumThreadWindowsProc ( ... )
  4.  EnumThreadWindows(t.Id, returnMyEnumThreadWindowsProc , IntPtr.Zero)
  5. Next

...Pero aún así sigo con el problema de no saber que parámetros enviarle a "MyEnumThreadWindowsProc " en esa última modificación.



Aquí tienen la class de C#:
Código
  1. using System;
  2. using System.Text;
  3. using System.Runtime.InteropServices;
  4. using System.Diagnostics;
  5.  
  6. namespace TaskbarHide
  7. {
  8.    /// <summary>
  9.    /// Helper class for hiding/showing the taskbar and startmenu on
  10.    /// Windows XP and Vista.
  11.    /// </summary>
  12.    public static class Taskbar
  13.    {
  14.        [DllImport("user32.dll")]
  15.        private static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
  16.        [DllImport("user32.dll", CharSet = CharSet.Auto)]
  17.        private static extern bool EnumThreadWindows(int threadId, EnumThreadProc pfnEnum, IntPtr lParam);
  18.        [DllImport("user32.dll", SetLastError = true)]
  19.        private static extern System.IntPtr FindWindow(string lpClassName, string lpWindowName);
  20.        [DllImport("user32.dll", SetLastError = true)]
  21.        private static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className,  string windowTitle);
  22.        [DllImport("user32.dll")]
  23.        private static extern IntPtr FindWindowEx(IntPtr parentHwnd, IntPtr childAfterHwnd, IntPtr className, string windowText);
  24.        [DllImport("user32.dll")]
  25.        private static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
  26.        [DllImport("user32.dll")]
  27.        private static extern uint GetWindowThreadProcessId(IntPtr hwnd, out int lpdwProcessId);
  28.  
  29.        private const int SW_HIDE = 0;
  30.        private const int SW_SHOW = 5;
  31.  
  32.        private const string VistaStartMenuCaption = "Start";
  33.        private static IntPtr vistaStartMenuWnd = IntPtr.Zero;
  34.        private delegate bool EnumThreadProc(IntPtr hwnd, IntPtr lParam);
  35.  
  36.        /// <summary>
  37.        /// Show the taskbar.
  38.        /// </summary>
  39.        public static void Show()
  40.        {
  41.            SetVisibility(true);
  42.        }
  43.  
  44.        /// <summary>
  45.        /// Hide the taskbar.
  46.        /// </summary>
  47.        public static void Hide()
  48.        {
  49.            SetVisibility(false);
  50.        }
  51.  
  52.        /// <summary>
  53.        /// Sets the visibility of the taskbar.
  54.        /// </summary>
  55.        public static bool Visible
  56.        {
  57.            set { SetVisibility(value); }
  58.        }
  59.  
  60.        /// <summary>
  61.        /// Hide or show the Windows taskbar and startmenu.
  62.        /// </summary>
  63.        /// <param name="show">true to show, false to hide</param>
  64.        private static void SetVisibility(bool show)
  65.        {
  66.            // get taskbar window
  67.            IntPtr taskBarWnd = FindWindow("Shell_TrayWnd", null);
  68.  
  69.            // try it the WinXP way first...
  70.            IntPtr startWnd = FindWindowEx(taskBarWnd, IntPtr.Zero, "Button", "Start");
  71.  
  72.            if (startWnd == IntPtr.Zero)
  73.            {
  74.                // try an alternate way, as mentioned on CodeProject by Earl Waylon Flinn
  75.                startWnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, (IntPtr)0xC017, "Start");
  76.            }
  77.  
  78.            if (startWnd == IntPtr.Zero)
  79.            {
  80.                // ok, let's try the Vista easy way...
  81.                startWnd = FindWindow("Button", null);
  82.  
  83.                if (startWnd == IntPtr.Zero)
  84.                {
  85.                    // no chance, we need to to it the hard way...
  86.                    startWnd = GetVistaStartMenuWnd(taskBarWnd);
  87.                }
  88.            }
  89.  
  90.            ShowWindow(taskBarWnd, show ? SW_SHOW : SW_HIDE);
  91.            ShowWindow(startWnd, show ? SW_SHOW : SW_HIDE);
  92.        }
  93.  
  94.        /// <summary>
  95.        /// Returns the window handle of the Vista start menu orb.
  96.        /// </summary>
  97.        /// <param name="taskBarWnd">windo handle of taskbar</param>
  98.        /// <returns>window handle of start menu</returns>
  99.        private static IntPtr GetVistaStartMenuWnd(IntPtr taskBarWnd)
  100.        {
  101.            // get process that owns the taskbar window
  102.            int procId;
  103.            GetWindowThreadProcessId(taskBarWnd, out procId);
  104.  
  105.            Process p = Process.GetProcessById(procId);
  106.            if (p != null)
  107.            {
  108.                // enumerate all threads of that process...
  109.                foreach (ProcessThread t in p.Threads)
  110.                {
  111.                    EnumThreadWindows(t.Id, MyEnumThreadWindowsProc, IntPtr.Zero);
  112.                }
  113.            }
  114.            return vistaStartMenuWnd;
  115.        }
  116.  
  117.        /// <summary>
  118.        /// Callback method that is called from 'EnumThreadWindows' in 'GetVistaStartMenuWnd'.
  119.        /// </summary>
  120.        /// <param name="hWnd">window handle</param>
  121.        /// <param name="lParam">parameter</param>
  122.        /// <returns>true to continue enumeration, false to stop it</returns>
  123.        private static bool MyEnumThreadWindowsProc(IntPtr hWnd, IntPtr lParam)
  124.        {
  125.            StringBuilder buffer = new StringBuilder(256);
  126.            if (GetWindowText(hWnd, buffer, buffer.Capacity) > 0)
  127.            {
  128.                Console.WriteLine(buffer);
  129.                if (buffer.ToString() == VistaStartMenuCaption)
  130.                {
  131.                    vistaStartMenuWnd = hWnd;
  132.                    return false;
  133.                }
  134.            }
  135.            return true;
  136.        }
  137.    }
  138. }



Y aquí la class "traducida":

Código
  1. '
  2. ' * Copyright (c) 2008..11 by Simon Baer
  3. ' *
  4. ' *  You may use this code for whatever you want.
  5. '
  6.  
  7.  
  8. Imports System
  9. Imports System.Text
  10. Imports System.Runtime.InteropServices
  11. Imports System.Diagnostics
  12.  
  13. Namespace TaskbarHide
  14.    ''' <summary>
  15.    ''' Helper class for hiding/showing the taskbar and startmenu on
  16.    ''' Windows XP and Vista.
  17.    ''' </summary>
  18.    Public NotInheritable Class Taskbar
  19.        Private Sub New()
  20.        End Sub
  21.        <DllImport("user32.dll")> _
  22.        Private Shared Function GetWindowText(hWnd As IntPtr, text As StringBuilder, count As Integer) As Integer
  23.        End Function
  24.        <DllImport("user32.dll", CharSet := CharSet.Auto)> _
  25.        Private Shared Function EnumThreadWindows(threadId As Integer, pfnEnum As EnumThreadProc, lParam As IntPtr) As Boolean
  26.        End Function
  27.        <DllImport("user32.dll", SetLastError := True)> _
  28.        Private Shared Function FindWindow(lpClassName As String, lpWindowName As String) As System.IntPtr
  29.        End Function
  30.        <DllImport("user32.dll", SetLastError := True)> _
  31.        Private Shared Function FindWindowEx(parentHandle As IntPtr, childAfter As IntPtr, className As String, windowTitle As String) As IntPtr
  32.        End Function
  33.        <DllImport("user32.dll")> _
  34.        Private Shared Function FindWindowEx(parentHwnd As IntPtr, childAfterHwnd As IntPtr, className As IntPtr, windowText As String) As IntPtr
  35.        End Function
  36.        <DllImport("user32.dll")> _
  37.        Private Shared Function ShowWindow(hwnd As IntPtr, nCmdShow As Integer) As Integer
  38.        End Function
  39.        <DllImport("user32.dll")> _
  40.        Private Shared Function GetWindowThreadProcessId(hwnd As IntPtr, lpdwProcessId As Integer) As UInteger
  41.        End Function
  42.  
  43.        Private Const SW_HIDE As Integer = 0
  44.        Private Const SW_SHOW As Integer = 5
  45.  
  46.        Private Const VistaStartMenuCaption As String = "Start"
  47.        Private Shared vistaStartMenuWnd As IntPtr = IntPtr.Zero
  48.        Private Delegate Function EnumThreadProc(hwnd As IntPtr, lParam As IntPtr) As Boolean
  49.  
  50.        ''' <summary>
  51.        ''' Show the taskbar.
  52.        ''' </summary>
  53.        Public Shared Sub Show()
  54.            SetVisibility(True)
  55.        End Sub
  56.  
  57.        ''' <summary>
  58.        ''' Hide the taskbar.
  59.        ''' </summary>
  60.        Public Shared Sub Hide()
  61.            SetVisibility(False)
  62.        End Sub
  63.  
  64.        ''' <summary>
  65.        ''' Sets the visibility of the taskbar.
  66.        ''' </summary>
  67.        Public Shared WriteOnly Property Visible() As Boolean
  68.            Set
  69.                SetVisibility(value)
  70.            End Set
  71.        End Property
  72.  
  73.        ''' <summary>
  74.        ''' Hide or show the Windows taskbar and startmenu.
  75.        ''' </summary>
  76.        ''' <param name="show">true to show, false to hide</param>
  77.        Private Shared Sub SetVisibility(show As Boolean)
  78.            ' get taskbar window
  79.            Dim taskBarWnd As IntPtr = FindWindow("Shell_TrayWnd", Nothing)
  80.  
  81.            ' try it the WinXP way first...
  82.            Dim startWnd As IntPtr = FindWindowEx(taskBarWnd, IntPtr.Zero, "Button", "Start")
  83.  
  84.            If startWnd = IntPtr.Zero Then
  85.                ' try an alternate way, as mentioned on CodeProject by Earl Waylon Flinn
  86.                startWnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, DirectCast(&Hc017, IntPtr), "Start")
  87.            End If
  88.  
  89.            If startWnd = IntPtr.Zero Then
  90.                ' ok, let's try the Vista easy way...
  91.                startWnd = FindWindow("Button", Nothing)
  92.  
  93.                If startWnd = IntPtr.Zero Then
  94.                    ' no chance, we need to to it the hard way...
  95.                    startWnd = GetVistaStartMenuWnd(taskBarWnd)
  96.                End If
  97.            End If
  98.  
  99.            ShowWindow(taskBarWnd, If(show, SW_SHOW, SW_HIDE))
  100.            ShowWindow(startWnd, If(show, SW_SHOW, SW_HIDE))
  101.        End Sub
  102.  
  103.        ''' <summary>
  104.        ''' Returns the window handle of the Vista start menu orb.
  105.        ''' </summary>
  106.        ''' <param name="taskBarWnd">windo handle of taskbar</param>
  107.        ''' <returns>window handle of start menu</returns>
  108.        Private Shared Function GetVistaStartMenuWnd(taskBarWnd As IntPtr) As IntPtr
  109.            ' get process that owns the taskbar window
  110.            Dim procId As Integer
  111.            GetWindowThreadProcessId(taskBarWnd, procId)
  112.  
  113.            Dim p As Process = Process.GetProcessById(procId)
  114.            If p IsNot Nothing Then
  115.                ' enumerate all threads of that process...
  116.                For Each t As ProcessThread In p.Threads
  117.                    EnumThreadWindows(t.Id, MyEnumThreadWindowsProc, IntPtr.Zero)
  118.                Next
  119.            End If
  120.            Return vistaStartMenuWnd
  121.        End Function
  122.  
  123.        ''' <summary>
  124.        ''' Callback method that is called from 'EnumThreadWindows' in 'GetVistaStartMenuWnd'.
  125.        ''' </summary>
  126.        ''' <param name="hWnd">window handle</param>
  127.        ''' <param name="lParam">parameter</param>
  128.        ''' <returns>true to continue enumeration, false to stop it</returns>
  129.        Private Shared Function MyEnumThreadWindowsProc(hWnd As IntPtr, lParam As IntPtr) As Boolean
  130.            Dim buffer As New StringBuilder(256)
  131.            If GetWindowText(hWnd, buffer, buffer.Capacity) > 0 Then
  132.                Console.WriteLine(buffer)
  133.                If buffer.ToString() = VistaStartMenuCaption Then
  134.                    vistaStartMenuWnd = hWnd
  135.                    Return False
  136.                End If
  137.            End If
  138.            Return True
  139.        End Function
  140.    End Class
  141. End Namespace
  142.  
  143. '=======================================================
  144. 'Service provided by Telerik (www.telerik.com)
  145. 'Conversion powered by NRefactory.
  146. 'Twitter: @telerik, @toddanglin
  147. 'Facebook: facebook.com/telerik
  148. '=======================================================
8927  Programación / .NET (C#, VB.NET, ASP) / Re: Mostrar/Ocultar en: 4 Junio 2013, 19:05 pm
Edito, es codigo de C#

XD tendre que pasarlo a VB.NET

Haz una dll con esa class "taskbar.cs" y luego referencias la dll a tu proyecto y listo.

No intentes traducir el code a VB, no vas a saber ni a poder hacerlo, los traductores online no saben traducirlo,
En el code de C# se llama a una función sin parámetros como si fuese un parámetro en si mismo, y eso en VB no sé como sería el equivalente.

Creo que haré una pregunta sobre como traducir ese maldita código ...sino posteas tu la misma pregunta antes que yo xD
8928  Programación / .NET (C#, VB.NET, ASP) / Re: Mostrar/Ocultar en: 4 Junio 2013, 18:50 pm
Creo que djiste que no era esto, pero si que es:
me imagino que lo que intentabas decir es que tienes la barra de tareas en modo "esconder automáticamente"
y que cuando seleccionas la aplicación en ese momento la barra de tareas se restaura (se vuelve visible)

¿Has probado a modificar la propiedad SHOWINTASKBAR a FALSE como te dije?, si no muestras el icono de la aplicación en el taskbar imagino que el taskbar no tendría motivos para "saltar".

Si eso no es suficiente, entonces como ya te dije hay que usar APIs: http://www.codeproject.com/Articles/25572/Hiding-the-Taskbar-and-Startmenu-start-orb-in-Wind

Código:
Taskbar.Show()
Taskbar.Hide()

Saludos
8929  Programación / .NET (C#, VB.NET, ASP) / Re: Scroll de Imagenes? en: 4 Junio 2013, 14:25 pm
Esto ya está mejor, aunque la parte "alternativa" no está pulida, la parte "progresiva" está sin bugs:



Código
  1. Public Class Form1
  2.  
  3.    Dim Scroll_Position As Int32 = 0
  4.    Dim Button_Down_Is_Pressed As Boolean = False
  5.    Dim Button_Up_Is_Pressed As Boolean = False
  6.    Dim WithEvents Progressive_Scroll_Timer As New Timer
  7.    Dim SmallChange As Int32 = 10
  8.    Dim Largechange As Int32 = 20
  9.    Dim Maximum As Int64 = 0
  10.  
  11.    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  12.        Panel1.AutoScroll = True
  13.        Maximum = Panel1.VerticalScroll.Maximum
  14.        Panel1.AutoScroll = False
  15.        Panel1.VerticalScroll.Maximum = Maximum / 2
  16.        Progressive_Scroll_Timer.Interval = 50
  17.        Panel1.BackColor = Color.FromArgb(150, 0, 0, 0)
  18.  
  19.        For Each PicBox As PictureBox In Panel1.Controls
  20.            AddHandler PicBox.MouseHover, AddressOf Panel_MouseHover
  21.        Next
  22.  
  23.    End Sub
  24.  
  25.    Private Sub Panel_MouseHover(sender As Object, e As EventArgs) Handles Panel1.MouseHover
  26.        sender.select()
  27.        sender.focus()
  28.    End Sub
  29.  
  30.    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Progressive_Scroll_Timer.Tick
  31.        If Button_Down_Is_Pressed Then
  32.            Scroll_Down(SmallChange)
  33.        ElseIf Button_Up_Is_Pressed Then
  34.            Scroll_Up(SmallChange)
  35.        Else
  36.            sender.stop()
  37.        End If
  38.    End Sub
  39.  
  40.    Private Sub Scroll_Up(ByVal Change As Int32)
  41.        Scroll_Position -= Change
  42.        Try
  43.            Panel1.VerticalScroll.Value = Scroll_Position
  44.        Catch
  45.            Scroll_Position = 0
  46.        End Try
  47.    End Sub
  48.  
  49.    Private Sub Scroll_Down(ByVal Change As Int32)
  50.        Scroll_Position += Change
  51.        Try
  52.            Panel1.VerticalScroll.Value = Scroll_Position
  53.        Catch
  54.            Scroll_Position -= Change
  55.        End Try
  56.    End Sub
  57.  
  58.    Private Sub Button_Down_MouseDown(sender As Object, e As MouseEventArgs) Handles Button2.MouseDown
  59.        If e.Button = Windows.Forms.MouseButtons.Left Then
  60.            Button_Down_Is_Pressed = True
  61.            Progressive_Scroll_Timer.Start()
  62.        End If
  63.    End Sub
  64.  
  65.    Private Sub Button_Up_MouseDown(sender As Object, e As MouseEventArgs) Handles Button1.MouseDown
  66.        If e.Button = Windows.Forms.MouseButtons.Left Then
  67.            Button_Up_Is_Pressed = True
  68.            Progressive_Scroll_Timer.Start()
  69.        End If
  70.    End Sub
  71.  
  72.    Private Sub Button_Down_MouseUp(sender As Object, e As MouseEventArgs) Handles Button2.MouseUp
  73.        Button_Down_Is_Pressed = False
  74.    End Sub
  75.  
  76.    Private Sub Button_Up_MouseUp(sender As Object, e As MouseEventArgs) Handles Button1.MouseUp
  77.        Button_Up_Is_Pressed = False
  78.    End Sub
  79.  
  80.    Private Sub Form_MouseWheel(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Panel1.MouseWheel
  81.        Select Case Math.Sign(e.Delta)
  82.            Case Is > 0 : Scroll_Up(Largechange)
  83.            Case Is < 0 : Scroll_Down(Largechange)
  84.        End Select
  85.    End Sub
  86.  
  87.  
  88.  
  89.    ' Versión alternativa:
  90.    Dim PictureBoxes_Height As Int64 = 100 ' La altura de cada picturebox
  91.  
  92.    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  93.        Scroll_Position -= PictureBoxes_Height
  94.        Try
  95.            Panel1.VerticalScroll.Value = Scroll_Position
  96.        Catch
  97.            Panel1.VerticalScroll.Value = 1
  98.            Scroll_Position += PictureBoxes_Height
  99.        End Try
  100.    End Sub
  101.  
  102.    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
  103.        Scroll_Position += PictureBoxes_Height
  104.        Try
  105.            Panel1.VerticalScroll.Value = Scroll_Position
  106.        Catch
  107.  
  108.            Scroll_Position -= PictureBoxes_Height
  109.        End Try
  110.    End Sub
  111.    ' Fin de versión alternativa
  112.  
  113. End Class

Código
  1. Public Class DoubleBufferedPanel
  2.    Inherits Panel
  3.  
  4.    Public Sub New()
  5.        DoubleBuffered = True
  6.        ResumeLayout(False)
  7.    End Sub
  8.  
  9.    Protected Overrides ReadOnly Property CreateParams() As CreateParams
  10.        Get
  11.            Dim cp As CreateParams = MyBase.CreateParams
  12.            cp.ExStyle = cp.ExStyle Or &H2000000
  13.            Return cp
  14.        End Get
  15.    End Property
  16.  
  17. End Class
8930  Programación / .NET (C#, VB.NET, ASP) / Re: Crear PictureBox a través de una config .ini? en: 4 Junio 2013, 14:22 pm
ups... me equivoquñe de post al comentar xD (...tienes tantos).

http://foro.elhacker.net/net/scroll_de_imagenes-t391409.0.html;msg1858088#msg1858088

Sorry por el spam.
Páginas: 1 ... 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 [893] 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines