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

 

 


Tema destacado: Estamos en la red social de Mastodon


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Cambiar estilo de las ventanas (invertir, quitar botones, bloquear, etc)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Cambiar estilo de las ventanas (invertir, quitar botones, bloquear, etc)  (Leído 5,283 veces)
Lekim

Desconectado Desconectado

Mensajes: 268



Ver Perfil
Cambiar estilo de las ventanas (invertir, quitar botones, bloquear, etc)
« en: 27 Noviembre 2015, 19:07 pm »

Hola

He creado este código para cambiar el estilo de las ventanas, se puede invertir la barra de título sin alterar el resto del form, bloquear el form, quitar los botones, desactivar botones de la barra, cambiar la posición de título de la barra de título, quitar los bordes, mostrar el form como un popup menú, etc.

Los cambios son combinables en algunos casos.



CAMBIAR EL ESTILO DE LAS VENTANAS

Código
  1. #Region "Cambiar estilo de la ventana"
  2. Public Module modChangeStyleWindow
  3.    Const GWL_ID = (-12)
  4.    Const GWL_STYLE = (-16)
  5.    Const HWND_NOTOPMOST = -2
  6.    Const SWP_NOZORDER = &H4
  7.    Const SWP_NOSIZE = &H1
  8.    Const SWP_NOMOVE = &H2
  9.    Const SWP_FRAMECHANGED = &H20
  10.    Const SWP_DRAWFRAME = SWP_FRAMECHANGED
  11.  
  12.    Enum WindowsStyle
  13.        WS_SIZABLE = &H0                                'Con todos los botones y la barra de título
  14.        WS_SIZABLE_DISABLEMAXB = &HFFFFFFFFFFFFFFFF     'Desactiva el botón maximizar
  15.        WS_SIZABLE_DISABLEMINB = &HFFFFFFFFFFFE5E08     'Desactiva el botón minimizar
  16.        WS_DLGFRAME_DISABLE = &H5FD8220                 'Cuadro diálogo desactivado (no permite ninguna interacción con el form)
  17.        WS_DLGFRAME_FIXEDSINGLE = &HFFFFFFFFFFF9CA28    'Cuadro diálogo no redimensionable
  18.        WS_DLGFRAME_SIZABLE = &HFFFFFFFFFFFDC5B0        'Cuadro diálogo redimensionable
  19.        WS_DISABLED = &H8000000                         'Desactivado (no permite ninguna interacción con el form)
  20.        WS_SYSMENU_DISABLE = &H5F5E100                  'Desactiva el menú y desactivado              
  21.        WS_SYSMENU_SIZABLE = &HFFFFFFFFFFF8F350         'Desactiva el menú y redimensionable
  22.        WS_SYSMENU_FIXEDSINGLE = &HFFFFFFFFFFF4EC10     'Desactiva el menú y no es redimensionable
  23.        WS_FIXEDSINGLE = &HFFFFFFFFFFFCEAF0             'No redimensionable
  24.        WS_FIXEDSINGLE_DISABLEMAXB = &HFFFFFFFFFFFBBA40 'No redimensionable y desactiva el botón maximizar
  25.        WS_FIXEDSINGLE_DISABLEMINB = &HFFFFFFFFFFFAEF20 'No redimensionable y desactvia el botón minimizar
  26.        WS_NOBORDER = &H325AA0                          'Sin bordes
  27.        WS_FLAT3D = &HB1FE68                            'Sin bordes con línea exterior
  28.        WS_POPUP = &H712CA8                             'Menú Popup
  29.    End Enum
  30.  
  31.    <System.Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True)> _
  32.    Private Function SetWindowLong(ByVal hwnd As IntPtr, _
  33.                                          ByVal nIndex As Integer, _
  34.                                          ByVal dwNewLong As Integer) As Integer
  35.    End Function
  36.  
  37.  
  38.    <System.Runtime.InteropServices.DllImport("user32.dll", SetLastError:=False)> _
  39.    Private Function SetWindowPos(ByVal hwnd As IntPtr, _
  40.                                         ByVal hWndInsertAfter As IntPtr, _
  41.                                         ByVal X As Integer, _
  42.                                         ByVal y As Integer, _
  43.                                         ByVal cx As Integer, _
  44.                                         ByVal cy As Integer, _
  45.                                         ByVal wFlags As Integer) As Integer
  46.    End Function
  47.  
  48.  
  49.    <System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint:="GetWindowLongA", SetLastError:=True)> _
  50.    Private Function GetWindowLong(ByVal hWnd As IntPtr, _
  51.                                          <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.I4)> ByVal nIndex As Integer) As Integer
  52.    End Function
  53.  
  54.    Public Sub ChangeStyleWindow(ByVal hwnd As IntPtr, ByVal StyleForm As Integer, ByVal SetStyle As Boolean)
  55.        'mantiene el tamaño de la ventana
  56.        Dim stl As Integer = GetWindowLong(hwnd, GWL_STYLE)
  57.  
  58.        Select Case SetStyle
  59.            '//Solo Ventana 'Sizable'
  60.            'Case True : If stl = &H16CF0000 Then stl += StyleForm
  61.            'Case False : If stl = &H16CF0000 + StyleForm Then stl -= StyleForm
  62.            '//Cualquier tipo de ventana u objeto con handle
  63.            Case True : stl += StyleForm
  64.            Case False : stl -= StyleForm
  65.        End Select
  66.  
  67.        SetWindowLong(hwnd, GWL_STYLE, stl)
  68.        Call SetWindowPos(hwnd, HWND_NOTOPMOST, Nothing, Nothing, Nothing, Nothing, _
  69.        SWP_NOZORDER + SWP_NOSIZE + SWP_NOMOVE + SWP_DRAWFRAME)
  70.    End Sub
  71.  
  72. End Module
  73. #End Region
  74.  


CAMBIAR EL ESTILO DE LA BARRA
Código
  1. Region "Cambiar estilo de la Barra de Título"
  2. Module modChangeStyleBar
  3.    Const GWL_ID = (-12)
  4.    Const GWL_STYLE = (-16)
  5.    Const GWL_EXSTYLE = (-20)
  6.    Const HWND_NOTOPMOST = -2
  7.    Const SWP_NOZORDER = &H4
  8.    Const SWP_NOSIZE = &H1
  9.    Const SWP_NOMOVE = &H2
  10.    Const SWP_FRAMECHANGED = &H20
  11.    Const SWP_DRAWFRAME = SWP_FRAMECHANGED
  12.  
  13.    Enum WStyleBarTitle
  14.        WStB_NORMAL_THICKBORDER = &H200                             'Normal con borde ancho
  15.        WStB_NORMALCAPTIONLEFT = &H0                                'Título a la izquierda
  16.        WStB_NORMAL_CAPTIONRIGHT = &H1000                           'Título a la derecha
  17.        WStB_INVERT_CAPTIONLEFT = &H405000                          'Invertido con título a la izquierda
  18.        WStB_INVERT_CAPTIONRIGHT = &H400000                         'Invertido con título a la derecha
  19.        WStB_TOOLWINDOW_CAPTIONLEFT = &H6590                        'Tool window con título a la izquierda y borde fino
  20.        WStB_TOOLWINDOW_CAPTIONRIGHT = &H5580                       'Tool window con título a la derecha y borde fino
  21.        WStB_TOOLWINDOW_THICKBORDER_CAPTONLEFT = &H68F              'Tool window con título a la izquierda y borde grueso
  22.        WStB_TOOLWINDOW_THICKBORDER_CAPTONRIGHT = &H5A80            'Tool window con título a la derecha y borde grueso
  23.        WStB_TOOLWINDOWS_INVERT_CAPTIONLEFT = &H401080              'Tool window Invertido con título a la izquierda y borde fino
  24.        WStB_TOOLWINDOWS_INVERT_CAPTIONRIGHT = &H400180             'Tool window invertido con título a la derecha y borde fino
  25.        WStB_TOOLWINDOWS_INVERT_THICKBORDER_TITLELEFT = &H403390    'Tool window Invertido con título a la izquierda y borde grueso
  26.        WStB_TOOLWINDOWS_INVERT_THICKBORDER_TITLERIGHT = &H400290   'Tool window invertido con título a la derecha y borde grueso
  27.        WS_EX_DLGMODALFRAME = &H1
  28.        WS_EX_NOPARENTNOTIFY = &H4
  29.        WS_EX_TOPMOST = &H8
  30.        WS_EX_ACCEPTFILES = &H10                                    'Cambia el cursor cuando se arrastr un archivo a la ventana
  31.        WS_EX_TRANSPARENT = &H20
  32.        WS_EX_MDICHILD = &H40
  33.        WS_EX_TOOLWINDOW = &H80
  34.        WS_EX_WINDOWEDGE = &H100
  35.        WS_EX_CLIENTEDGE = &H200
  36.        WS_EX_CONTEXTHELP = &H400
  37.        WS_EX_RIGHT = &H1000
  38.        WS_EX_LEFT = &H0
  39.        WS_EX_RTLREADING = &H2000
  40.        WS_EX_LTRREADING = &H0
  41.        WS_EX_LEFTSCROLLBAR = &H4000
  42.        WS_EX_RIGHTSCROLLBAR = &H0
  43.        WS_EX_CONTROLPARENT = &H10000
  44.        WS_EX_STATICEDGE = &H20000
  45.        WS_EX_APPWINDOW = &H40000
  46.        WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE Or WS_EX_CLIENTEDGE)
  47.        WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE Or WS_EX_TOOLWINDOW Or WS_EX_TOPMOST)
  48.        WS_EX_LAYERED = &H80000
  49.        WS_EX_NOINHERITLAYOUT = &H100000 ' Disable inheritence of mirroring by children
  50.        WS_EX_LAYOUTRTL = &H400000 ' Right to left mirroring
  51.        WS_EX_COMPOSITED = &H2000000
  52.        WS_EX_NOACTIVATE = &H8000000
  53.    End Enum
  54.    <System.Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True)> _
  55.    Private Function SetWindowLong(ByVal hwnd As IntPtr, _
  56.                                          ByVal nIndex As Integer, _
  57.                                          ByVal dwNewLong As Integer) As Integer
  58.    End Function
  59.  
  60.  
  61.    <System.Runtime.InteropServices.DllImport("user32.dll", SetLastError:=False)> _
  62.    Private Function SetWindowPos(ByVal hwnd As IntPtr, _
  63.                                         ByVal hWndInsertAfter As IntPtr, _
  64.                                         ByVal X As Integer, _
  65.                                         ByVal y As Integer, _
  66.                                         ByVal cx As Integer, _
  67.                                         ByVal cy As Integer, _
  68.                                         ByVal wFlags As Integer) As Integer
  69.    End Function
  70.  
  71.  
  72.    <System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint:="GetWindowLongA", SetLastError:=True)> _
  73.    Private Function GetWindowLong(ByVal hWnd As IntPtr, _
  74.                                          <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.I4)> ByVal nIndex As Integer) As Integer
  75.    End Function
  76.  
  77.    'Estilo de la barra de título
  78.    Public Sub ChangeStyleBarWindow(ByVal hwnd As IntPtr, ByVal StyleBar As Integer)
  79.        SetWindowLong(hwnd, GWL_EXSTYLE, StyleBar)
  80.        Call SetWindowPos(hwnd, HWND_NOTOPMOST, Nothing, Nothing, Nothing, Nothing, _
  81.        SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME)
  82.    End Sub
  83. End Module
  84. #End Region



EJEMPLO DE USO


Si se aplican varias veces el mismo estilo se pueden obtener estilos curiosos.



Código
  1.    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.        For i As Integer = 0 To 5
  3.            modChangeStyleWindow.ChangeStyleWindow(Me.Handle, WindowsStyle.WS_SYSMENU_FIXEDSINGLE, True)
  4.        Next i
  5.    End Sub


para modo popup:

Código
  1.   modChangeStyleWindow.ChangeStyleWindow(Me.Handle, WindowsStyle.WS_POPUP, True)


Para invertir la barra de título:
Código
  1.       Call modChangeStyleBar.ChangeStyleBarWindow(Me.Handle, modChangeStyleBar.WStyleBarTitle.WStB_INVERT_CAPTIONRIGHT)


Invertido y desactivado:
Código
  1.   Call modChangeStyleWindow.ChangeStyleWindow(Me.Handle, modChangeStyleWindow.WindowsStyle.WS_DISABLED, True)
  2.        Call modChangeStyleBar.ChangeStyleBarWindow(Me.Handle, modChangeStyleBar.WStyleBarTitle.WStB_INVERT_CAPTIONRIGHT)


Espero os sirva  ;)

Sl2s


Se me olvidaba, para restaurar la ventana establecer 'False'
'Activa el cambio
Código
  1. Call modChangeStyleWindow.ChangeStyleWindow(Me.Handle, modChangeStyleWindow.WindowsStyle.WS_DISABLED, True)

'Desactiva el cambio (en este caso se tendría que hacer con un timer o similar ya que WS_DISABLE no permite la interacción con el form ni con los controles que contiene)
Código
  1. Call modChangeStyleWindow.ChangeStyleWindow(Me.Handle, modChangeStyleWindow.WindowsStyle.WS_DISABLED, False)

sl2s


« Última modificación: 28 Noviembre 2015, 05:19 am por Lekim » En línea

XresH


Desconectado Desconectado

Mensajes: 384



Ver Perfil WWW
Re: Cambiar estilo de las ventanas (invertir, quitar botones, bloquear, etc)
« Respuesta #1 en: 27 Noviembre 2015, 21:29 pm »

Gracias por el aporte, se ve excelente y muy bien explicado (Y)


Saludos.


En línea

[ - Si eres programador y quieres que tus proyectos esten en mi blog(con o sin source), consúltame! - ]
Entra A Mi Blog De Programación | | Dudas en este post :| | >>Clic para ir al Post<<
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Cambiar estilo de las ventanas (invertir, quitar botones, bloquear, etc)
« Respuesta #2 en: 28 Noviembre 2015, 01:23 am »

EDITO:

Lee esto:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms633585%28v=vs.85%29.aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/ms644898%28v=vs.85%29.aspx



EDITO 2:
Código
  1. ''' ----------------------------------------------------------------------------------------------------
  2. ''' <summary>
  3. ''' Retrieves information about the specified window.
  4. ''' <para></para>
  5. ''' The function also retrieves the 32-bit (<c>DWORD</c>) value at the specified offset into the extra window memory.
  6. ''' </summary>
  7. ''' ----------------------------------------------------------------------------------------------------
  8. ''' <remarks>
  9. ''' <see href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms633584%28v=vs.85%29.aspx"/>
  10. ''' </remarks>
  11. ''' ----------------------------------------------------------------------------------------------------
  12. <DllImport("user32.dll", EntryPoint:="GetWindowLong", SetLastError:=True)>
  13. Public Shared Function GetWindowLong(ByVal hwnd As IntPtr,
  14.       <MarshalAs(UnmanagedType.I4)> ByVal nIndex As WindowLongFlags
  15. ) As UInteger
  16. End Function
  17.  
  18. ''' ----------------------------------------------------------------------------------------------------
  19. ''' <summary>
  20. ''' Changes an attribute of the specified window.
  21. ''' <para></para>
  22. ''' The function also sets the 32-bit (<c>LONG</c>) value at the specified offset into the extra window memory.
  23. ''' </summary>
  24. ''' ----------------------------------------------------------------------------------------------------
  25. ''' <remarks>
  26. ''' <see href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms633591%28v=vs.85%29.aspx"/>
  27. ''' </remarks>
  28. ''' ----------------------------------------------------------------------------------------------------
  29. <DllImport("user32.dll", EntryPoint:="SetWindowLong", SetLastError:=True)>
  30. Public Shared Function SetWindowLong(ByVal hwnd As IntPtr,
  31.       <MarshalAs(UnmanagedType.I4)> ByVal nIndex As WindowLongFlags,
  32.                                     ByVal dwNewLong As UInteger
  33. ) As UInteger
  34. End Function
  35.  
  36. ''' ----------------------------------------------------------------------------------------------------
  37. ''' <summary>
  38. ''' Retrieves information about the specified window.
  39. ''' <para></para>
  40. ''' The function also retrieves the value at a specified offset into the extra window memory.
  41. ''' </summary>
  42. ''' ----------------------------------------------------------------------------------------------------
  43. ''' <remarks>
  44. ''' <see href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms633585%28v=vs.85%29.aspx"/>
  45. ''' </remarks>
  46. ''' ----------------------------------------------------------------------------------------------------
  47. <SuppressMessage("Microsoft.Interoperability", "CA1400:PInvokeEntryPointsShouldExist",
  48. justification:="Code-Analysis is 32-Bit so it only checks for the entrypoint in the user32.dll of the Win32 API.")>
  49. <DllImport("user32.dll", EntryPoint:="GetWindowLongPtr", SetLastError:=True)>
  50. Public Shared Function GetWindowLongPtr(ByVal hwnd As IntPtr,
  51.          <MarshalAs(UnmanagedType.I4)> ByVal nIndex As WindowLongFlags
  52. ) As IntPtr
  53. End Function
  54.  
  55. ''' ----------------------------------------------------------------------------------------------------
  56. ''' <summary>
  57. ''' Changes an attribute of the specified window.
  58. ''' <para></para>
  59. ''' The function also sets a value at the specified offset in the extra window memory.
  60. ''' </summary>
  61. ''' ----------------------------------------------------------------------------------------------------
  62. ''' <remarks>
  63. ''' <see href="https://msdn.microsoft.com/es-es/library/windows/desktop/ms644898%28v=vs.85%29.aspx"/>
  64. ''' </remarks>
  65. ''' ----------------------------------------------------------------------------------------------------
  66. <SuppressMessage("Microsoft.Interoperability", "CA1400:PInvokeEntryPointsShouldExist",
  67. justification:="Code-Analysis is 32-Bit so it only checks for the entrypoint in the user32.dll of the Win32 API.")>
  68. <DllImport("user32.dll", EntryPoint:="SetWindowLongPtr", SetLastError:=True)>
  69. Public Shared Function SetWindowLongPtr(ByVal hwnd As IntPtr,
  70.          <MarshalAs(UnmanagedType.I4)> ByVal nIndex As WindowLongFlags,
  71.                                        ByVal dwNewLong As IntPtr
  72. ) As IntPtr
  73. End Function
  74.  
  75. ''' ----------------------------------------------------------------------------------------------------
  76. ''' <summary>
  77. ''' The zero-based offset to the value to be set or retrieved.
  78. ''' </summary>
  79. ''' ----------------------------------------------------------------------------------------------------
  80. ''' <remarks>
  81. ''' <see href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548%28v=vs.85%29.aspx"/>
  82. ''' </remarks>
  83. ''' ----------------------------------------------------------------------------------------------------
  84. Public Enum WindowLongFlags As Integer
  85.  
  86.    ''' <summary>
  87.    ''' Retrieves the window styles.
  88.    ''' </summary>
  89.    WindowStyle = -16
  90.  
  91.    ''' <summary>
  92.    ''' Retrieves the extended window styles.
  93.    ''' </summary>
  94.    WindowStyleEx = -20
  95.  
  96.    ''' <summary>
  97.    ''' Retrieves a handle to the application instance.
  98.    ''' </summary>
  99.    HInstance = -6
  100.  
  101.    ''' <summary>
  102.    ''' Retrieves a handle to the parent window, if any.
  103.    ''' </summary>
  104.    HwndParent = -8
  105.  
  106.    ''' <summary>
  107.    ''' Retrieves the identifier of the window.
  108.    ''' </summary>
  109.    Id = -12
  110.  
  111.    ''' <summary>
  112.    ''' Retrieves the user data associated with the window.
  113.    ''' <para></para>
  114.    ''' This data is intended for use by the application that created the window.
  115.    ''' <para></para>
  116.    ''' Its value is initially zero.
  117.    ''' </summary>
  118.    UserData = -21
  119.  
  120.    ''' <summary>
  121.    ''' Retrieves the address of the window procedure, or a handle representing the address of the window procedure.
  122.    ''' <para></para>
  123.    ''' You must use the <c>CallWindowProc</c> function to call the window procedure.
  124.    ''' </summary>
  125.    WndProc = -4
  126.  
  127.    ''' <summary>
  128.    ''' ( This value is only available when the <paramref name="hwnd"/> parameter identifies a dialog box. )
  129.    ''' <para></para>
  130.    ''' Retrieves extra information private to the application, such as handles or pointers.
  131.    ''' </summary>
  132.    DlgUser = 8
  133.  
  134.    ''' <summary>
  135.    ''' ( This value is only available when the <paramref name="hwnd"/> parameter identifies a dialog box. )
  136.    ''' <para></para>
  137.    ''' Retrieves the return value of a message processed in the dialog box procedure.
  138.    ''' </summary>
  139.    DlgMsgresult = 0
  140.  
  141.    ''' <summary>
  142.    ''' ( This value is only available when the <paramref name="hwnd"/> parameter identifies a dialog box. )
  143.    ''' <para></para>
  144.    ''' Retrieves the address of the dialog box procedure,
  145.    ''' or a handle representing the address of the dialog box procedure.
  146.    ''' <para></para>
  147.    ''' You must use the <c>CallWindowProc</c> function to call the dialog box procedure.
  148.    ''' </summary>
  149.    DlgProc = 4
  150.  
  151. End Enum



Estuve implementado las enumeraciones de estilos de ventanas en mi (futura)api. Aquí les dejo las enumeraciones con documentación xml por si alguien lo prefiere así para aprovechar IntelliSense o compilar un archivo de ayuda:

Código
  1.    ''' ----------------------------------------------------------------------------------------------------
  2.    ''' <summary>
  3.    ''' The following styles can be specified wherever a window style is required.
  4.    ''' <para></para>
  5.    ''' After the control has been created, these styles cannot be modified, except as noted.
  6.    ''' </summary>
  7.    ''' ----------------------------------------------------------------------------------------------------
  8.    ''' <remarks>
  9.    ''' <see href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms632600%28v=vs.85%29.aspx"/>
  10.    ''' </remarks>
  11.    ''' ----------------------------------------------------------------------------------------------------
  12.    <Flags>
  13.    Public Enum WindowStyles As UInteger
  14.  
  15.        ''' <summary>
  16.        ''' The window has a thin-line border.
  17.        ''' </summary>
  18.        Border = &H800000UI
  19.  
  20.        ''' <summary>
  21.        ''' The window has a title bar.
  22.        ''' <para></para>
  23.        ''' (includes the <see cref="WindowStyles.Border"/> style).
  24.        ''' </summary>
  25.        Caption = &HC00000UI
  26.  
  27.        ''' <summary>
  28.        ''' The window is a child window.
  29.        ''' <para></para>
  30.        ''' A window with this style cannot have a menu bar.
  31.        ''' <para></para>
  32.        ''' This style cannot be used with the <see cref="WindowStyles.Popup"/> style.
  33.        ''' </summary>
  34.        Child = &H40000000UI
  35.  
  36.        ''' <summary>
  37.        ''' Excludes the area occupied by child windows when drawing occurs within the parent window.
  38.        ''' <para></para>
  39.        ''' This style is used when creating the parent window.
  40.        ''' </summary>
  41.        ClipChildren = &H2000000UI
  42.  
  43.        ''' <summary>
  44.        ''' Clips child windows relative to each other;
  45.        ''' that is, when a particular child window receives a <c>WM_PAINT</c> message,
  46.        ''' the <see cref="WindowStyles.ClipSiblings"/> style clips all other overlapping child windows out of the
  47.        ''' region of the child window to be updated.
  48.        ''' <para></para>
  49.        ''' If <see cref="WindowStyles.ClipSiblings"/> is not specified and child windows overlap,
  50.        ''' it is possible, when drawing within the client area of a child window,
  51.        ''' to draw within the client area of a neighboring child window.
  52.        ''' </summary>
  53.        ClipSiblings = &H4000000UI
  54.  
  55.        ''' <summary>
  56.        ''' The window is initially disabled.
  57.        ''' <para></para>
  58.        ''' A disabled window cannot receive input from the user.
  59.        ''' <para></para>
  60.        ''' To change this after a window has been created, use the <c>EnableWindow</c> function.
  61.        ''' </summary>
  62.        Disabled = &H8000000UI
  63.  
  64.        ''' <summary>
  65.        ''' The window has a border of a style typically used with dialog boxes.
  66.        ''' <para></para>
  67.        ''' A window with this style cannot have a title bar.
  68.        ''' </summary>
  69.        DlgFrame = &H400000UI
  70.  
  71.        ''' <summary>
  72.        ''' The window is the first control of a group of controls.
  73.        ''' <para></para>
  74.        ''' The group consists of this first control and all controls defined after it,
  75.        ''' up to the next control with the <see cref="WindowStyles.Group"/> style.
  76.        ''' <para></para>
  77.        ''' The first control in each group usually has the <see cref="WindowStyles.TabStop"/> style
  78.        ''' so that the user can move from group to group.
  79.        ''' <para></para>
  80.        ''' The user can subsequently change the keyboard focus from one control in the
  81.        ''' group to the next control in the group by using the direction keys.
  82.        ''' <para></para>
  83.        ''' You can turn this style on and off to change dialog box navigation.
  84.        ''' <para></para>
  85.        ''' To change this style after a window has been created, use the <c>SetWindowLong</c> function.
  86.        ''' </summary>
  87.        Group = &H20000UI
  88.  
  89.        ''' <summary>
  90.        ''' The window has a horizontal scroll bar.
  91.        ''' </summary>
  92.        HScroll = &H100000UI
  93.  
  94.        ''' <summary>
  95.        ''' The window is initially maximized.
  96.        ''' </summary>
  97.        Maximize = &H1000000UI
  98.  
  99.        ''' <summary>
  100.        ''' The window has a maximize button.
  101.        ''' <para></para>
  102.        ''' Cannot be combined with the <c>WS_EX_CONTEXTHELP</c> extended style.
  103.        ''' <para></para>
  104.        ''' The <see cref="WindowStyles.SysMenu"/> style must also be specified.
  105.        ''' </summary>
  106.        MaximizeBox = &H10000UI
  107.  
  108.        ''' <summary>
  109.        ''' The window is initially minimized.
  110.        ''' </summary>
  111.        Minimize = &H20000000UI
  112.  
  113.        ''' <summary>
  114.        ''' The window has a minimize button.
  115.        ''' <para></para>
  116.        ''' Cannot be combined with the <c>WS_EX_CONTEXTHELP</c> extended style.
  117.        ''' <para></para>
  118.        ''' The <see cref="WindowStyles.SysMenu"/> style must also be specified.
  119.        ''' </summary>
  120.        MinimizeBox = &H20000UI
  121.  
  122.        ''' <summary>
  123.        ''' The window is an overlapped window.
  124.        ''' <para></para>
  125.        ''' An overlapped window has a title bar and a border.
  126.        ''' </summary>
  127.        Overlapped = &H0UI
  128.  
  129.        ''' <summary>
  130.        ''' The window is an overlapped window.
  131.        ''' </summary>
  132.        OverlappedWindow = (Overlapped Or Caption Or SysMenu Or SizeFrame Or MinimizeBox Or MaximizeBox)
  133.  
  134.        ''' <summary>
  135.        ''' The window is a pop-up window.
  136.        ''' <para></para>
  137.        ''' This style cannot be used with the <see cref="WindowStyles.Child"/> style.
  138.        ''' </summary>
  139.        Popup = &H80000000UI
  140.  
  141.        ''' <summary>
  142.        ''' The window is a pop-up window.
  143.        ''' <para></para>
  144.        ''' The <see cref="WindowStyles.Caption"/> and <see cref="WindowStyles.PopupWindow"/> styles
  145.        ''' must be combined to make the window menu visible.
  146.        ''' </summary>
  147.        PopupWindow = (Popup Or Border Or SysMenu)
  148.  
  149.        ''' <summary>
  150.        ''' The window has a sizing border.
  151.        ''' </summary>
  152.        SizeFrame = &H40000UI
  153.  
  154.        ''' <summary>
  155.        ''' The window has a window menu on its title bar.
  156.        ''' <para></para>
  157.        ''' The <see cref="WindowStyles.Caption"/> style must also be specified.
  158.        ''' </summary>
  159.        SysMenu = &H80000UI
  160.  
  161.        ''' <summary>
  162.        ''' The window is a control that can receive the keyboard focus when the user presses the <c>TAB</c> key.
  163.        ''' <para></para>
  164.        ''' Pressing the <c>TAB</c> key changes the keyboard focus to the next control
  165.        ''' with the <see cref="WindowStyles.TabStop"/> style.
  166.        ''' <para></para>
  167.        ''' You can turn this style on and off to change dialog box navigation.
  168.        ''' <para></para>
  169.        ''' To change this style after a window has been created, use the <c>SetWindowLong</c> function.
  170.        ''' <para></para>
  171.        ''' For user-created windows and modeless dialogs to work with tab stops,
  172.        ''' alter the message loop to call the <c>IsDialogMessage</c> function.
  173.        ''' </summary>
  174.        TabStop = &H10000UI
  175.  
  176.        ''' <summary>
  177.        ''' The window is initially visible.
  178.        ''' <para></para>
  179.        ''' This style can be turned on and off by using the <c>ShowWindow</c> or <c>SetWindowPos</c> function.
  180.        ''' </summary>
  181.        Visible = &H10000000UI
  182.  
  183.        ''' <summary>
  184.        ''' The window has a vertical scroll bar.
  185.        ''' </summary>
  186.        VScroll = &H200000UI
  187.  
  188.    End Enum

Código
  1.    ''' ----------------------------------------------------------------------------------------------------
  2.    ''' <summary>
  3.    ''' Extended window styles.
  4.    ''' </summary>
  5.    ''' ----------------------------------------------------------------------------------------------------
  6.    ''' <remarks>
  7.    ''' <see href="https://msdn.microsoft.com/es-es/library/windows/desktop/ff700543%28v=vs.85%29.aspx"/>
  8.    ''' </remarks>
  9.    ''' ----------------------------------------------------------------------------------------------------
  10.    <Flags>
  11.    Public Enum WindowStylesEx As UInteger
  12.  
  13.        ''' <summary>
  14.        ''' Specifies a window that accepts drag-drop files.
  15.        ''' </summary>
  16.        AcceptFiles = &H10UI
  17.  
  18.        ''' <summary>
  19.        ''' Forces a top-level window onto the taskbar when the window is visible.
  20.        ''' </summary>
  21.        AppWindow = &H40000UI
  22.  
  23.        ''' <summary>
  24.        ''' Specifies a window that has a border with a sunken edge.
  25.        ''' </summary>
  26.        ClientEdge = &H200UI
  27.  
  28.        ''' <summary>
  29.        ''' Specifies a window that paints all descendants in bottom-to-top painting order using double-buffering.
  30.        ''' <para></para>
  31.        ''' This cannot be used if the window has a class style of either <c>CS_OWNDC</c> or <c>CS_CLASSDC</c>.
  32.        ''' <para></para>
  33.        ''' This style is not supported in Windows 2000.
  34.        ''' </summary>
  35.        ''' <remarks>
  36.        ''' With <see cref="WindowStylesEx.Composited"/> set,
  37.        ''' all descendants of a window get bottom-to-top painting order using double-buffering.
  38.        ''' <para></para>
  39.        ''' Bottom-to-top painting order allows a descendent window to have translucency (alpha) and transparency (color-key) effects,
  40.        ''' but only if the descendent window also has the<see cref="WindowStylesEx.Transparent"/> bit set.
  41.        ''' <para></para>
  42.        ''' Double-buffering allows the window and its descendents to be painted without flicker.
  43.        ''' </remarks>
  44.        Composited = &H2000000UI
  45.  
  46.        ''' <summary>
  47.        ''' Specifies a window that includes a question mark in the title bar.
  48.        ''' <para></para>
  49.        ''' When the user clicks the question mark, the cursor changes to a question mark with a pointer.
  50.        ''' <para></para>
  51.        ''' If the user then clicks a child window, the child receives a <c>WM_HELP</c> message.
  52.        ''' <para></para>
  53.        ''' The child window should pass the message to the parent window procedure,
  54.        ''' which should call the <c>WinHelp</c> function using the <c>HELP_WM_HELP</c> command.
  55.        ''' <para></para>
  56.        ''' The Help application displays a pop-up window that typically contains help for the child window.
  57.        ''' <para></para>
  58.        ''' <see cref="WindowStylesEx.ContextHelp"/> cannot be used with the <c>WS_MAXIMIZEBOX</c> or <c>WS_MINIMIZEBOX</c> styles.
  59.        ''' </summary>
  60.        ContextHelp = &H400UI
  61.  
  62.        ''' <summary>
  63.        ''' Specifies a window which contains child windows that should take part in dialog box navigation.
  64.        ''' <para></para>
  65.        ''' If this style is specified, the dialog manager recurses into children of
  66.        ''' this window when performing navigation operations
  67.        ''' such as handling the <c>TAB</c> key, an arrow key, or a keyboard mnemonic.
  68.        ''' </summary>
  69.        ControlParent = &H10000UI
  70.  
  71.        ''' <summary>
  72.        ''' Specifies a window that has a double border.
  73.        ''' </summary>
  74.        DlgModalFrame = &H1UI
  75.  
  76.        ''' <summary>
  77.        ''' Specifies a window that is a layered window.
  78.        ''' <para></para>
  79.        ''' This cannot be used for child windows or if the window has a class style of either <c>CS_OWNDC</c> or <c>CS_CLASSDC</c>.
  80.        ''' </summary>
  81.        Layered = &H80000UI
  82.  
  83.        ''' <summary>
  84.        ''' Specifies a window with the horizontal origin on the right edge.
  85.        ''' <para></para>
  86.        ''' Increasing horizontal values advance to the left.
  87.        ''' <para></para>
  88.        ''' The shell language must support reading-order alignment for this to take effect.
  89.        ''' </summary>
  90.        LayoutRtl = &H400000UI
  91.  
  92.        ''' <summary>
  93.        ''' Specifies a window that has generic left-aligned properties.
  94.        ''' <para></para>
  95.        ''' This is the default.
  96.        ''' </summary>
  97.        Left = &H0UI
  98.  
  99.        ''' <summary>
  100.        ''' Specifies a window with the vertical scroll bar (if present) to the left of the client area.
  101.        ''' <para></para>
  102.        ''' The shell language must support reading-order alignment for this to take effect.
  103.        ''' </summary>
  104.        LeftScrollbar = &H4000UI
  105.  
  106.        ''' <summary>
  107.        ''' Specifies a window that displays text using left-to-right reading-order properties.
  108.        ''' <para></para>
  109.        ''' This is the default.
  110.        ''' </summary>
  111.        LtrReading = &H0UI
  112.  
  113.        ''' <summary>
  114.        ''' Specifies a multiple-document interface (MDI) child window.
  115.        ''' </summary>
  116.        MdiChild = &H40UI
  117.  
  118.        ''' <summary>
  119.        ''' Specifies a top-level window created with this style does not become the
  120.        ''' foreground window when the user clicks it.
  121.        ''' <para></para>
  122.        ''' The system does not bring this window to the foreground when the user minimizes or closes the foreground window.
  123.        ''' <para></para>
  124.        ''' The window does not appear on the taskbar by default.
  125.        ''' <para></para>
  126.        ''' To force the window to appear on the taskbar, use the <see cref="WindowStylesEx.AppWindow"/> style.
  127.        ''' <para></para>
  128.        ''' To activate the window, use the <c>SetActiveWindow</c> or <c>SetForegroundWindow</c> function.
  129.        ''' </summary>
  130.        NoActivate = &H8000000UI
  131.  
  132.        ''' <summary>
  133.        ''' Specifies a window which does not pass its window layout to its child windows.
  134.        ''' </summary>
  135.        NoInheritLayout = &H100000UI
  136.  
  137.        ''' <summary>
  138.        ''' Specifies that a child window created with this style does not send the <c>WM_PARENTNOTIFY</c> message
  139.        ''' to its parent window when it is created or destroyed.
  140.        ''' </summary>
  141.        NoParentNotify = &H4UI
  142.  
  143.        ''' <summary>
  144.        ''' Specifies an overlapped window.
  145.        ''' </summary>
  146.        OverlappedWindow = (WindowEdge Or ClientEdge)
  147.  
  148.        ''' <summary>
  149.        ''' Specifies a palette window, which is a modeless dialog box that presents an array of commands.
  150.        ''' </summary>
  151.        PaletteWindow = (WindowEdge Or ToolWindow Or TopMost)
  152.  
  153.        ''' <summary>
  154.        ''' Specifies a window that has generic "right-aligned" properties. This depends on the window class.
  155.        ''' <para></para>
  156.        ''' The shell language must support reading-order alignment for this to take effect.
  157.        ''' <para></para>
  158.        ''' Using the <see cref="WindowStylesEx.Right"/> style has the same effect as
  159.        ''' using the <c>SS_RIGHT</c> (static), <c>ES_RIGHT</c> (edit),
  160.        ''' and <c>BS_RIGHT</c>/<c>BS_RIGHTBUTTON</c> (button) control styles.
  161.        ''' </summary>
  162.        Right = &H1000UI
  163.  
  164.        ''' <summary>
  165.        ''' Specifies a window with the vertical scroll bar (if present) to the right of the client area.
  166.        ''' <para></para>
  167.        ''' This is the default.
  168.        ''' </summary>
  169.        RightScrollbar = &H0UI
  170.  
  171.        ''' <summary>
  172.        ''' Specifies a window that displays text using right-to-left reading-order properties.
  173.        ''' <para></para>
  174.        ''' The shell language must support reading-order alignment for this to take effect.
  175.        ''' </summary>
  176.        RtlReading = &H2000UI
  177.  
  178.        ''' <summary>
  179.        ''' Specifies a window with a three-dimensional border style intended to be used for
  180.        ''' items that do not accept user input.
  181.        ''' </summary>
  182.        StaticEdge = &H20000UI
  183.  
  184.        ''' <summary>
  185.        ''' Specifies a window that is intended to be used as a floating toolbar.
  186.        ''' <para></para>
  187.        ''' A tool window has a title bar that is shorter than a normal title bar,
  188.        ''' and the window title is drawn using a smaller font.
  189.        ''' <para></para>
  190.        ''' A tool window does not appear in the taskbar or in the dialog that appears when the user presses <c>ALT</c>+<c>TAB</c>.
  191.        ''' <para></para>
  192.        ''' If a tool window has a system menu, its icon is not displayed on the title bar.
  193.        ''' <para></para>
  194.        ''' However, you can display the system menu by right-clicking or by typing <c>ALT</c>+<c>SPACE</c>.
  195.        ''' </summary>
  196.        ToolWindow = &H80UI
  197.  
  198.        ''' <summary>
  199.        ''' Specifies a window that should be placed above all non-topmost windows and should stay above them,
  200.        ''' even when the window is deactivated.
  201.        ''' <para></para>
  202.        ''' To add or remove this style, use the <c>SetWindowPos</c> function.
  203.        ''' </summary>
  204.        TopMost = &H8UI
  205.  
  206.        ''' <summary>
  207.        ''' Specifies a window that should not be painted until siblings beneath the window
  208.        ''' (that were created by the same thread) have been painted.
  209.        ''' <para></para>
  210.        ''' The window appears transparent because the bits of underlying sibling windows have already been painted.
  211.        ''' <para></para>
  212.        ''' To achieve transparency without these restrictions, use the <c>SetWindowRgn</c> function.
  213.        ''' </summary>
  214.        Transparent = &H20UI
  215.  
  216.        ''' <summary>
  217.        ''' Specifies a window that has a border with a raised edge.
  218.        ''' </summary>
  219.        WindowEdge = &H100UI
  220.  
  221.    End Enum
« Última modificación: 28 Noviembre 2015, 04:56 am por Eleкtro » En línea

Lekim

Desconectado Desconectado

Mensajes: 268



Ver Perfil
Re: Cambiar estilo de las ventanas (invertir, quitar botones, bloquear, etc)
« Respuesta #3 en: 28 Noviembre 2015, 03:19 am »

Gracias Elektro
¿Entonces según eso mi código no funcionaría en 64bits?
Tengo un PC con W764bits ahora lo pruebo y hago los cambios... jeje

Por cierto, se hace muy engorroso ver el código con el <summary>

Código
  1. ''' ----------------------------------------------------------------------------------------------------
  2. ''' <summary>
  3. ''' Changes an attribute of the specified window.
  4. ''' <para></para>
  5. ''' The function also sets the 32-bit (<c>LONG</c>) value at the specified offset into the extra window memory.
  6. ''' </summary>
  7. ''' ----------------------------------------------------------------------------------------------------
  8. ''' <remarks>
  9. ''' <see href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms633591%28v=vs.85%29.aspx"/>
  10. ''' </remarks>

Creo que está bien pero en el navegador tienes que ir bajando y bajando.... :¬¬

Sl2s
« Última modificación: 28 Noviembre 2015, 03:22 am por Lekim » En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Cambiar estilo de las ventanas (invertir, quitar botones, bloquear, etc)
« Respuesta #4 en: 28 Noviembre 2015, 03:34 am »

¿Entonces según eso mi código no funcionaría en 64bits?

Eso dice la MSDN.

De todas formas no lo he testeado en un Windows x86 (me da pereza encender la V.M.) así que no se que tipo de "incompatibilidad" causará, quizás devuelva valores incorrectos, no lo se. EDITO: si que me funciona incorrectamente.

Cuando juegues con el P/Invoking debes asegurarte de hacer un análisis de código con la herramienta Code-Analysis de VisualStudio, ya que suele detectar y advertirte de conflictos de ese tipo con firmas de p/invokes que no son portables.

En tu código, puedes escribir una condicional que evalue el tamaño en bytes de un IntPtr (Marshal.SizeOf(GetType(IntPtr))) lo que dará 4 bytes en Win32 y 8 bytes en Win64, o simplemente recurrir a la propiedad Environment.Is64BitOperatingSystem :

Código
  1. If Environment.Is64BitOperatingSystem Then
  2. ...WindowLongPtr
  3.  
  4. Else
  5. ...WindowLong
  6.  
  7. End If

EDITO:
te muestro un ejemplo más extenso:
Código
  1. Dim target As IntPtr = MyBase.Handle
  2. Dim flag As WindowLongFlags = WindowLongFlags.WindowStyleEx
  3. Dim oldStyle As WindowStylesEx
  4. Dim newStyle As WindowStylesEx
  5.  
  6. If Environment.Is64BitOperatingSystem Then
  7.    oldStyle = CType(NativeMethods.GetWindowLongPtr(target, flag).ToInt64, WindowStylesEx)
  8.    newStyle = (oldStyle Or WindowStylesEx.ToolWindow)
  9.    NativeMethods.SetWindowLongPtr(target, flag, New IntPtr(newStyle))
  10.  
  11. Else
  12.    oldStyle = CType(NativeMethods.GetWindowLong(target, flag), WindowStylesEx)
  13.    newStyle = (oldStyle Or WindowStylesEx.ToolWindow)
  14.    NativeMethods.SetWindowLong(target, flag, newStyle)
  15.  
  16. End If



Por cierto, se hace muy engorroso ver el código con el <summary>

Lo siento si se te hace engorroso, pero resulta necesario para generar la descripción del miembro en IntelliSense y/o compilar el archivos de ayuda html.

Siempre puedes colapsar toda la documentación XML usando la combinación CTRL + M + L.

saludos
« Última modificación: 28 Noviembre 2015, 05:01 am por Eleкtro » En línea

Lekim

Desconectado Desconectado

Mensajes: 268



Ver Perfil
Re: Cambiar estilo de las ventanas (invertir, quitar botones, bloquear, etc)
« Respuesta #5 en: 28 Noviembre 2015, 05:18 am »

Está genial no sabía esa propiedad de Environtment  ;-)

Lo testearé en 64bits más tarde, porque el ratón se quedó sin pilas y estoy recargando y el ratón con teclado numérico es un palo.

sl2s


TESTEADO EN 64BITS

Bueno, ya lo he testeado funciona perfecto y no da ningún error.

Hay que tener en cuenta que el nombre que usé al declarar la función del API es irrelevante. Yo puedo poner VivaLaPepa y funcionaría igual:

 
Código
  1.  <System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint:="GetWindowLongA", SetLastError:=True)> _
  2.    Private Function VivaLaPepa(ByVal hWnd As IntPtr, _
  3.                                          <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.I4)> ByVal nIndex As Integer) As Integer
  4.    End Function

Lo importante es el punto de entrada GetWindowLongA. Si no establezco el punto de entrada como ocurre por ejemplo en SetWindowPos entonces NO puedo hacer la llamada con otro nombre que no sea SetWindowPos, pues este mismo nombre va actuar como punto de entrada.

Ahora bien, he importado las entradas de USER32.DLL tando en X86 com x64 (Windows 7 64bits) y he encontrado dos  entradas distintas que no se encuentran e x86. Estas son las entradas en User32.dll:

x86
Código:
1916  197 00017D64 GetWindowLongA
1919  19A 00019938 GetWindowLongW

x64
Código:
1916  197 00017D64 GetWindowLongA
1917  198 00016050 GetWindowLongPtrA
1918  199 0001B970 GetWindowLongPtrW
1919  19A 00019938 GetWindowLongW

Importar Apis


Sin embargo si uso la entrada GetWindowLongPtrA (en sistema de 64bits) o GetWindowLongPtr aparece el siguiente error:

Código:
Unable to find an entry point named 'GetWindowLongPtrA' in DLL 'user32.dll

Así no entiendo lo del MSDN. Además pone que para que sea compatible con 32bit y 64bits y ya era compatible con 32bits usando GetWindowLong normal y punto de entrada  GetWindowLongA. Ahora se también que sigue siendo compatible también a 64bits.

Y otro detalle importate. Como he mencionado en 32bits no existen las entradadas GetWindowLongPtrA y GetWindowLongPtrW ¿Por qué dice
To write code that is compatible with both 32-bit ? si dichas entradas no existen en 32 bits XD. No se puede que sea para Windows 8 o posterior o desde lenguaje C
 

Lo de Environment.Is64BitOperatingSystem ya me ha resultado útil y lo he añadido al código de Importar Apis  ;D. Me va genial para determinar que ProgramFiles usar.

Sl2s

[NUEVO DATO SOBRE ESTE TEMA]

Dandole vueltas al asunto y viendo que Elektro a usado la siguiente convención de llamada para GetWindoLong:
Código
  1. <SuppressMessage("Microsoft.Interoperability", "CA1400:PInvokeEntryPointsShouldExist",justification:="Code-Analysis is 32-Bit so it only checks for the entrypoint in the user32.dll of the Win32 API.")><DllImport("user32.dll", EntryPoint:="GetWindowLongPtr", SetLastError:=True)>Public Shared Function GetWindowLongPtr(ByVal hwnd As IntPtr,          <MarshalAs(UnmanagedType.I4)> ByVal nIndex As WindowLongFlags) As IntPtrEnd Function

Me he preguntado ¿Y si mi apliación se está ejecutando con compatibilidad en X86 o como si se ejecutara en X86?

Así que me he dirigido a la configuración de mi proyecto haciendo doble click en My Project  en el Explorador de soluciones y en 'Compilar'
he visto que ponía CPU Destino = X86  y lo he cambiado a X64. He cambiado la llamada a GetWindowLong usando el punto de control GetWindowLongPtrA y sin suprimir errores:

Código
  1.  <DllImport("user32.dll", EntryPoint:="GetWindowLongPtrA", SetLastError:=True)> _
  2.    Public Function GetWindowLong(ByVal hwnd As IntPtr, _
  3.     <MarshalAs(UnmanagedType.I4)> ByVal nIndex As Integer) As IntPtr
  4.    End Function

Y NO me da error. Encuentra el punto de entrada  y el programa funciona perfecdtamente. Vuelvo a cambiar a  CPU Destino = X86 y denuevo me dice que no encuentra el punto de entrada.

Entonces llego a la conclusión que la llamada debe hacerse según como compiles el programa y no en el hecho que se ejecute en 32bits o 64bits. De modo que si lo compilo para 64bits y CPU Destino = X64 y llamo al punto de entrada GetWindowLongPtrA sólo será compatible con 64bits. Sin embargo si hago la llamada al punto de entrada GetWindowLongA es compatible en ambos.
« Última modificación: 28 Noviembre 2015, 17:33 pm por Lekim » En línea

Lekim

Desconectado Desconectado

Mensajes: 268



Ver Perfil
Re: Cambiar estilo de las ventanas (invertir, quitar botones, bloquear, etc)
« Respuesta #6 en: 29 Noviembre 2015, 00:24 am »

Otra forma de cambiar el estilo de una ventana...

Código
  1. Public Class Form1
  2.    Const WS_VSCROLL As Integer = &H200000
  3.    Const WS_HSCROLL As Integer = &H100000
  4.    Const WS_DISABLED As Integer = &H8000000
  5.  
  6.    Enum Style_Window
  7.        FLAT = &H0
  8.        NOBORDER_3D = &H400000 '3d sin bordes
  9.        NOTITLEBAR = &H40000 'con bordes sin barra de título
  10.        FLAT_3D = &H800000 'Flat style con línea externa
  11.        BORDER_NOTITLEBAR_SCROLLBAR = &HBEBC20 'con bordes sin barra de título con ScrollBAr
  12.        NOBUTTONSBAR = &HC00000 'sin botones en la barra y no redimensionable
  13.        NOBUTTONSBAR_RESIZABLE = &HC50000 'sin botones en la barra y  redimensionable
  14.        TYPE_MSGBOX = &HC89500 'solo boton cerrar no redimensionable (tipo msgbox)
  15.        TYPE_MSGBOX_NOMIN = &HC99500 'Cerrar + max no redimensionable (tipo msgbox)
  16.        TYPE_MSGBOX_NOMAX = &HCA0000 'Cerrar + min no redimensionable (tipo msgbox)
  17.        TYPE_MSGBOX_ALLBUTTONS = &HCB0000 'todo no redimensionable
  18.        ONLY_CLOSEBUTTON = &HCC0000 'Solo botón Cerrar redimensionable
  19.        ONLY_CLOSE_MAX = &HCD0000 'Cerrar + max redimensionable
  20.        ONLY_CLOSE_MIN = &HCE0000 'Cerrar + min redimensionable
  21.        ALLBUTTONS_RESIZABLE = &HCF0000  'redimensionable
  22.        SCROLLBARS = WS_VSCROLL + WS_HSCROLL
  23.    End Enum
  24.    Enum ExStyle_Window
  25.        BIGBORDER = &H200  'borde ancho
  26.        NORMAL_TITLE_LEFT = &H0 'título a la izquierda
  27.        NORMAL_TITLE_RIGHT = &H1000  'título a la derecha
  28.        INVERT_TITLE_LEFT = &H405000  'Invertido con título a la izquierda
  29.        INVERT_TITLE_RIGHT = &H400000  'Invertido con título a la derecha
  30.        TOOLWINDOW_BIGBORDER_TITLELEFT = &H102390 'Tool window con título a la izquierda y borde grueso
  31.        TOOLWINDOW_BIGBORDER_TITLERIGHT = &H103390 'Tool window con título a la derecha y borde grueso
  32.        TOOLWINDOW_TITLELEFT = &H102490 'Tool window Invertido con título a la izquierda y borde fino
  33.        TOOLWINDOW_TITLERIGHT = &H103490 'Tool window invertido con título a la derecha y borde fino
  34.        TOOLWINDOWS_INVERT_TITLELEFT = &H401080 'Tool window Invertido con título a la izquierda y borde fino
  35.        TOOLWINDOWS_INVERT_TITLERIGHT = &H400180 'Tool window invertido con título a la derecha y borde fino
  36.        TOOLWINDOWS_INVERT_BIGBORDER_TITLELEFT = &H403390 'Tool window Invertido con título a la izquierda y borde grueso
  37.        TOOLWINDOWS_INVERT_BIGBORDER_TITLERIGHT = &H400290 'Tool window invertido con título a la derecha y borde grueso
  38.    End Enum
  39.    Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
  40.        Get
  41.            Dim cp As CreateParams = MyBase.CreateParams
  42.            'cp.Style = cp.Style Or Style_Window.SCROLLBARS
  43.            cp.ExStyle = ExStyle_Window.TOOLWINDOWS_INVERT_TITLERIGHT
  44.            Return cp
  45.        End Get
  46.    End Property
  47.    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
  48.    End Sub
  49. End Class
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Botones estilo XP, MAC, JAVA, FLAT, NETSCAPE ... [VB6]
Java
Mad Antrax 2 6,301 Último mensaje 7 Julio 2004, 06:53 am
por Mad Antrax
Abrir ventanas ajustables con botones flash
Diseño Gráfico
manuschroeder 1 2,177 Último mensaje 19 Marzo 2005, 01:14 am
por Morris
ayuda!!! tengo problemas con botones minimizar,maxim,cerrar, mover ventanas ...
Windows
Geredor 3 13,965 Último mensaje 18 Diciembre 2014, 01:37 am
por simorg
Aspectos de botones y ventanas java
Java
AsTeroine 7 13,744 Último mensaje 12 Agosto 2009, 01:08 am
por 1mpuls0
Definir estilo css a botones de formulario
Desarrollo Web
estebanjd 2 3,660 Último mensaje 5 Noviembre 2011, 19:29 pm
por estebanjd
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines