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

 

 


Tema destacado: Los 10 CVE más críticos (peligrosos) de 2020


  Mostrar Mensajes
Páginas: 1 ... 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 [708] 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 ... 1236
7071  Programación / .NET (C#, VB.NET, ASP) / Re: No permitir resizear un form en: 28 Junio 2014, 06:22 am
Debería eliminar el tema... pero prefiero dejar este código para quien busque una solución al mismo problema.

El código lo desarrollé para administrar/personalizar los bordes de un Form, pero, por otro lado, permite de una manera sencilla deshabilitar la redimensión de todos los bordes de la aplicación, con estas instrucciones:
Código
  1. Private FormBorders As New FormBorderManager(Me)
  2. FormBorders.SetAllEdgesToNonResizable()

Aquí tienen el resto:
Código
  1. ' ***********************************************************************
  2. ' Author   : Elektro
  3. ' Created  : 01-12-2014
  4. ' Modified : 01-12-2014
  5. ' ***********************************************************************
  6. ' <copyright file="FormBorderManager.vb" company="Elektro Studios">
  7. '     Copyright (c) Elektro Studios. All rights reserved.
  8. ' </copyright>
  9. ' ***********************************************************************
  10.  
  11. #Region " Usage Examples "
  12.  
  13. 'Public Class Form1
  14.  
  15. '    ' Disable resizing on all border edges.
  16. '    Private FormBorders As New FormBorderManager(Me) With
  17. '            {
  18. '                .Edges = New FormBorderManager.FormEdges With
  19. '                         {
  20. '                             .Top = FormBorderManager.WindowHitTestRegions.TitleBar,
  21. '                             .Left = FormBorderManager.WindowHitTestRegions.TitleBar,
  22. '                             .Right = FormBorderManager.WindowHitTestRegions.TitleBar,
  23. '                             .Bottom = FormBorderManager.WindowHitTestRegions.TitleBar,
  24. '                             .TopLeft = FormBorderManager.WindowHitTestRegions.TitleBar,
  25. '                             .TopRight = FormBorderManager.WindowHitTestRegions.TitleBar,
  26. '                             .BottomLeft = FormBorderManager.WindowHitTestRegions.TitleBar,
  27. '                             .BottomRight = FormBorderManager.WindowHitTestRegions.TitleBar
  28. '                         }
  29. '            }
  30.  
  31. '    Private Shadows Sub Load(sender As Object, e As EventArgs) Handles MyBase.Load
  32.  
  33. '        ' Disables the moving on all border edges.
  34. '        FormBorders.SetAllEdgesToNonMoveable()
  35.  
  36. '    End Sub
  37.  
  38. 'End Class
  39.  
  40. #End Region
  41.  
  42. #Region " Imports "
  43.  
  44. Imports System.ComponentModel
  45.  
  46. #End Region
  47.  
  48. #Region " FormBorderManager "
  49.  
  50. ''' <summary>
  51. ''' Class FormBorderManager.
  52. ''' Manages each Form border to indicate their Hit-Region.
  53. ''' </summary>
  54. <Description("Manages each Form border to indicate their Hit-Region")>
  55. Friend NotInheritable Class FormBorderManager : Inherits NativeWindow : Implements IDisposable
  56.  
  57. #Region " Members "
  58.  
  59. #Region " Miscellaneous "
  60.  
  61.    ''' <summary>
  62.    ''' The form to manage their borders.
  63.    ''' </summary>
  64.    Private WithEvents form As Form = Nothing
  65.  
  66. #End Region
  67.  
  68. #Region " Properties "
  69.  
  70.    ''' <summary>
  71.    ''' Gets or sets the Hit-Region of the edges.
  72.    ''' </summary>
  73.    ''' <value>The Form edges.</value>
  74.    Public Property Edges As New FormEdges
  75.  
  76.    ''' <summary>
  77.    ''' The Edges of the Form.
  78.    ''' </summary>
  79.    Partial Public NotInheritable Class FormEdges
  80.  
  81.        ''' <summary>
  82.        ''' Gets or sets the Hit-Region of the Top form border.
  83.        ''' </summary>
  84.        Public Property Top As WindowHitTestRegions = WindowHitTestRegions.TopSizeableBorder
  85.  
  86.        ''' <summary>
  87.        ''' Gets or sets the Hit-Region of the Left form border.
  88.        ''' </summary>
  89.        Public Property Left As WindowHitTestRegions = WindowHitTestRegions.LeftSizeableBorder
  90.  
  91.        ''' <summary>
  92.        ''' Gets or sets the Hit-Region of the Right form border.
  93.        ''' </summary>
  94.        Public Property Right As WindowHitTestRegions = WindowHitTestRegions.RightSizeableBorder
  95.  
  96.        ''' <summary>
  97.        ''' Gets or sets the Hit-Region of the Bottom form border.
  98.        ''' </summary>
  99.        Public Property Bottom As WindowHitTestRegions = WindowHitTestRegions.BottomSizeableBorder
  100.  
  101.        ''' <summary>
  102.        ''' Gets or sets the Hit-Region of the Top-Left form border.
  103.        ''' </summary>
  104.        Public Property TopLeft As WindowHitTestRegions = WindowHitTestRegions.TopLeftSizeableCorner
  105.  
  106.        ''' <summary>
  107.        ''' Gets or sets the Hit-Region of the Top-Right form border.
  108.        ''' </summary>
  109.        Public Property TopRight As WindowHitTestRegions = WindowHitTestRegions.TopRightSizeableCorner
  110.  
  111.        ''' <summary>
  112.        ''' Gets or sets the Hit-Region of the Bottom-Left form border.
  113.        ''' </summary>
  114.        Public Property BottomLeft As WindowHitTestRegions = WindowHitTestRegions.BottomLeftSizeableCorner
  115.  
  116.        ''' <summary>
  117.        ''' Gets or sets the Hit-Region of the Bottom-Right form border.
  118.        ''' </summary>
  119.        Public Property BottomRight As WindowHitTestRegions = WindowHitTestRegions.BottomRightSizeableCorner
  120.  
  121.    End Class
  122.  
  123. #End Region
  124.  
  125. #Region " Enumerations "
  126.  
  127.    ''' <summary>
  128.    ''' Known Windows Message Identifiers.
  129.    ''' </summary>
  130.    <Description("Messages to process in WndProc")>
  131.    Private Enum KnownMessages As Integer
  132.  
  133.        ''' <summary>
  134.        ''' Sent to a window in order to determine what part of the window corresponds to a particular screen coordinate.
  135.        ''' This can happen, for example, when the cursor moves, when a mouse button is pressed or released,
  136.        ''' or in response to a call to a function such as WindowFromPoint.
  137.        ''' If the mouse is not captured, the message is sent to the window beneath the cursor.
  138.        ''' Otherwise, the message is sent to the window that has captured the mouse.
  139.        ''' <paramref name="WParam" />
  140.        ''' This parameter is not used.
  141.        ''' <paramref name="LParam" />
  142.        ''' The low-order word specifies the x-coordinate of the cursor.
  143.        ''' The coordinate is relative to the upper-left corner of the screen.
  144.        ''' The high-order word specifies the y-coordinate of the cursor.
  145.        ''' The coordinate is relative to the upper-left corner of the screen.
  146.        ''' </summary>
  147.        WM_NCHITTEST = &H84
  148.  
  149.    End Enum
  150.  
  151.    ''' <summary>
  152.    ''' Indicates the position of the cursor hot spot.
  153.    ''' Options available when a form is tested for mose positions with 'WM_NCHITTEST' message.
  154.    ''' </summary>
  155.    <Description("Return value of the 'WM_NCHITTEST' message")>
  156.    Public Enum WindowHitTestRegions
  157.  
  158.        ''' <summary>
  159.        ''' HTERROR: On the screen background or on a dividing line between windows.
  160.        ''' (same as HTNOWHERE, except that the DefWindowProc function produces a system beep to indicate an error).
  161.        ''' </summary>
  162.        [Error] = -2
  163.  
  164.        ''' <summary>
  165.        ''' HTTRANSPARENT: In a window currently covered by another window in the same thread.
  166.        ''' (the message will be sent to underlying windows in the same thread
  167.        ''' until one of them returns a code that is not HTTRANSPARENT).
  168.        ''' </summary>
  169.        TransparentOrCovered = -1
  170.  
  171.        ''' <summary>
  172.        ''' HTNOWHERE: On the screen background or on a dividing line between windows.
  173.        ''' </summary>
  174.        NoWhere = 0
  175.  
  176.        ''' <summary>
  177.        ''' HTCLIENT: In a client area.
  178.        ''' </summary>
  179.        ClientArea = 1
  180.  
  181.        ''' <summary>
  182.        ''' HTCAPTION: In a title bar.
  183.        ''' </summary>
  184.        TitleBar = 2
  185.  
  186.        ''' <summary>
  187.        ''' HTSYSMENU: In a window menu or in a Close button in a child window.
  188.        ''' </summary>
  189.        SystemMenu = 3
  190.  
  191.        ''' <summary>
  192.        ''' HTGROWBOX: In a size box (same as HTSIZE).
  193.        ''' </summary>
  194.        GrowBox = 4
  195.  
  196.        ''' <summary>
  197.        ''' HTMENU: In a menu.
  198.        ''' </summary>
  199.        Menu = 5
  200.  
  201.        ''' <summary>
  202.        ''' HTHSCROLL: In a horizontal scroll bar.
  203.        ''' </summary>
  204.        HorizontalScrollBar = 6
  205.  
  206.        ''' <summary>
  207.        ''' HTVSCROLL: In the vertical scroll bar.
  208.        ''' </summary>
  209.        VerticalScrollBar = 7
  210.  
  211.        ''' <summary>
  212.        ''' HTMINBUTTON: In a Minimize button.
  213.        ''' </summary>
  214.        MinimizeButton = 8
  215.  
  216.        ''' <summary>
  217.        ''' HTMAXBUTTON: In a Maximize button.
  218.        ''' </summary>
  219.        MaximizeButton = 9
  220.  
  221.        ''' <summary>
  222.        ''' HTLEFT: In the left border of a resizable window.
  223.        ''' (the user can click the mouse to resize the window horizontally).
  224.        ''' </summary>
  225.        LeftSizeableBorder = 10
  226.  
  227.        ''' <summary>
  228.        ''' HTRIGHT: In the right border of a resizable window.
  229.        ''' (the user can click the mouse to resize the window horizontally).
  230.        ''' </summary>
  231.        RightSizeableBorder = 11
  232.  
  233.        ''' <summary>
  234.        ''' HTTOP: In the upper-horizontal border of a window.
  235.        ''' </summary>
  236.        TopSizeableBorder = 12
  237.  
  238.        ''' <summary>
  239.        ''' HTTOPLEFT: In the upper-left corner of a window border.
  240.        ''' </summary>
  241.        TopLeftSizeableCorner = 13
  242.  
  243.        ''' <summary>
  244.        ''' HTTOPRIGHT: In the upper-right corner of a window border.
  245.        ''' </summary>
  246.        TopRightSizeableCorner = 14
  247.  
  248.        ''' <summary>
  249.        ''' HTBOTTOM: In the lower-horizontal border of a resizable window.
  250.        ''' (the user can click the mouse to resize the window vertically).
  251.        ''' </summary>
  252.        BottomSizeableBorder = 15
  253.  
  254.        ''' <summary>
  255.        ''' HTBOTTOMLEFT: In the lower-left corner of a border of a resizable window.
  256.        ''' (the user can click the mouse to resize the window diagonally).
  257.        ''' </summary>
  258.        BottomLeftSizeableCorner = 16
  259.  
  260.        ''' <summary>
  261.        ''' HTBOTTOMRIGHT: In the lower-right corner of a border of a resizable window.
  262.        ''' (the user can click the mouse to resize the window diagonally).
  263.        ''' </summary>
  264.        BottomRightSizeableCorner = 17
  265.  
  266.        ''' <summary>
  267.        ''' HTBORDER: In the border of a window that does not have a sizing border.
  268.        ''' </summary>
  269.        NonSizableBorder = 18
  270.  
  271.        ' ''' <summary>
  272.        ' ''' HTOBJECT: Not implemented.
  273.        ' ''' </summary>
  274.        ' [Object] = 19
  275.  
  276.        ''' <summary>
  277.        ''' HTCLOSE: In a Close button.
  278.        ''' </summary>
  279.        CloseButton = 20
  280.  
  281.        ''' <summary>
  282.        ''' HTHELP: In a Help button.
  283.        ''' </summary>
  284.        HelpButton = 21
  285.  
  286.        ''' <summary>
  287.        ''' HTSIZE: In a size box (same as HTGROWBOX).
  288.        ''' (Same as GrowBox).
  289.        ''' </summary>
  290.        SizeBox = GrowBox
  291.  
  292.        ''' <summary>
  293.        ''' HTREDUCE: In a Minimize button.
  294.        ''' (Same as MinimizeButton).
  295.        ''' </summary>
  296.        ReduceButton = MinimizeButton
  297.  
  298.        ''' <summary>
  299.        ''' HTZOOM: In a Maximize button.
  300.        ''' (Same as MaximizeButton).
  301.        ''' </summary>
  302.        ZoomButton = MaximizeButton
  303.  
  304.    End Enum
  305.  
  306. #End Region
  307.  
  308. #End Region
  309.  
  310. #Region " Constructor "
  311.  
  312.    ''' <summary>
  313.    ''' Initializes a new instance of the <see cref="FormBorderManager"/> class.
  314.    ''' </summary>
  315.    ''' <param name="form">The form to assign.</param>
  316.    Public Sub New(ByVal form As Form)
  317.  
  318.        ' Assign the Formulary.
  319.        Me.form = form
  320.  
  321.    End Sub
  322.  
  323. #End Region
  324.  
  325. #Region " Event Handlers "
  326.  
  327.    ''' <summary>
  328.    ''' Assign the handle of the target Form to this NativeWindow,
  329.    ''' necessary to override target Form's WndProc.
  330.    ''' </summary>
  331.    Private Sub SetFormHandle() _
  332.    Handles form.HandleCreated, form.Load, form.Shown
  333.  
  334.        If Not MyBase.Handle.Equals(Me.form.Handle) Then
  335.            MyBase.AssignHandle(Me.form.Handle)
  336.        End If
  337.  
  338.    End Sub
  339.  
  340.    ''' <summary>
  341.    ''' Releases the Handle.
  342.    ''' </summary>
  343.    Private Sub OnHandleDestroyed() _
  344.    Handles Form.HandleDestroyed
  345.  
  346.        MyBase.ReleaseHandle()
  347.  
  348.    End Sub
  349.  
  350. #End Region
  351.  
  352. #Region " WndProc "
  353.  
  354.    ''' <summary>
  355.    ''' Invokes the default window procedure associated with this window to process messages for this Window.
  356.    ''' </summary>
  357.    ''' <param name="m">
  358.    ''' A <see cref="T:System.Windows.Forms.Message" /> that is associated with the current Windows message.
  359.    ''' </param>
  360.    Protected Overrides Sub WndProc(ByRef m As Message)
  361.  
  362.        MyBase.WndProc(m)
  363.  
  364.        Select Case m.Msg
  365.  
  366.            Case KnownMessages.WM_NCHITTEST
  367.  
  368.                Select Case CType(m.Result, WindowHitTestRegions)
  369.  
  370.                    Case WindowHitTestRegions.TopSizeableBorder ' The mouse hotspot is pointing to Top border.
  371.                        m.Result = New IntPtr(Edges.Top)
  372.  
  373.                    Case WindowHitTestRegions.LeftSizeableBorder ' The mouse hotspot is pointing to Left border.
  374.                        m.Result = New IntPtr(Edges.Left)
  375.  
  376.                    Case WindowHitTestRegions.RightSizeableBorder ' The mouse hotspot is pointing to Right border.
  377.                        m.Result = New IntPtr(Edges.Right)
  378.  
  379.                    Case WindowHitTestRegions.BottomSizeableBorder ' The mouse hotspot is pointing to Bottom border.
  380.                        m.Result = New IntPtr(Edges.Bottom)
  381.  
  382.                    Case WindowHitTestRegions.TopLeftSizeableCorner ' The mouse hotspot is pointing to Top-Left border.
  383.                        m.Result = New IntPtr(Edges.TopLeft)
  384.  
  385.                    Case WindowHitTestRegions.TopRightSizeableCorner ' The mouse hotspot is pointing to Top-Right border.
  386.                        m.Result = New IntPtr(Edges.TopRight)
  387.  
  388.                    Case WindowHitTestRegions.BottomLeftSizeableCorner ' The mouse hotspot is pointing to Bottom-Left border.
  389.                        m.Result = New IntPtr(Edges.BottomLeft)
  390.  
  391.                    Case WindowHitTestRegions.BottomRightSizeableCorner ' The mouse hotspot is pointing to Bottom-Right border.
  392.                        m.Result = New IntPtr(Edges.BottomRight)
  393.  
  394.                End Select
  395.  
  396.        End Select
  397.  
  398.    End Sub
  399.  
  400. #End Region
  401.  
  402. #Region " Public Methods "
  403.  
  404.    ''' <summary>
  405.    ''' Disables the resizing on all border edges.
  406.    ''' </summary>
  407.    Public Sub SetAllEdgesToNonResizable()
  408.  
  409.        DisposedCheck()
  410.  
  411.        Me.Edges.Top = WindowHitTestRegions.TitleBar
  412.        Me.Edges.Left = WindowHitTestRegions.TitleBar
  413.        Me.Edges.Right = WindowHitTestRegions.TitleBar
  414.        Me.Edges.Bottom = WindowHitTestRegions.TitleBar
  415.        Me.Edges.TopLeft = WindowHitTestRegions.TitleBar
  416.        Me.Edges.TopRight = WindowHitTestRegions.TitleBar
  417.        Me.Edges.BottomLeft = WindowHitTestRegions.TitleBar
  418.        Me.Edges.BottomRight = WindowHitTestRegions.TitleBar
  419.  
  420.    End Sub
  421.  
  422.    ''' <summary>
  423.    ''' Enables the resizing on all border edges.
  424.    ''' </summary>
  425.    Public Sub SetAllEdgesToResizable()
  426.  
  427.        DisposedCheck()
  428.  
  429.        Me.Edges.Top = WindowHitTestRegions.TopSizeableBorder
  430.        Me.Edges.Left = WindowHitTestRegions.LeftSizeableBorder
  431.        Me.Edges.Right = WindowHitTestRegions.RightSizeableBorder
  432.        Me.Edges.Bottom = WindowHitTestRegions.BottomSizeableBorder
  433.        Me.Edges.TopLeft = WindowHitTestRegions.TopLeftSizeableCorner
  434.        Me.Edges.TopRight = WindowHitTestRegions.TopRightSizeableCorner
  435.        Me.Edges.BottomLeft = WindowHitTestRegions.BottomLeftSizeableCorner
  436.        Me.Edges.BottomRight = WindowHitTestRegions.BottomRightSizeableCorner
  437.  
  438.    End Sub
  439.  
  440.    ''' <summary>
  441.    ''' Enabled the moving on all border edges.
  442.    ''' </summary>
  443.    Public Sub SetAllEdgesToMoveable()
  444.  
  445.        DisposedCheck()
  446.  
  447.        Me.Edges.Top = WindowHitTestRegions.TopSizeableBorder
  448.        Me.Edges.Left = WindowHitTestRegions.LeftSizeableBorder
  449.        Me.Edges.Right = WindowHitTestRegions.RightSizeableBorder
  450.        Me.Edges.Bottom = WindowHitTestRegions.BottomSizeableBorder
  451.        Me.Edges.TopLeft = WindowHitTestRegions.TopLeftSizeableCorner
  452.        Me.Edges.TopRight = WindowHitTestRegions.TopRightSizeableCorner
  453.        Me.Edges.BottomLeft = WindowHitTestRegions.BottomLeftSizeableCorner
  454.        Me.Edges.BottomRight = WindowHitTestRegions.BottomRightSizeableCorner
  455.  
  456.    End Sub
  457.  
  458.    ''' <summary>
  459.    ''' Disables the moving on all border edges.
  460.    ''' </summary>
  461.    Public Sub SetAllEdgesToNonMoveable()
  462.  
  463.        DisposedCheck()
  464.  
  465.        Me.Edges.Top = WindowHitTestRegions.NoWhere
  466.        Me.Edges.Left = WindowHitTestRegions.NoWhere
  467.        Me.Edges.Right = WindowHitTestRegions.NoWhere
  468.        Me.Edges.Bottom = WindowHitTestRegions.NoWhere
  469.        Me.Edges.TopLeft = WindowHitTestRegions.NoWhere
  470.        Me.Edges.TopRight = WindowHitTestRegions.NoWhere
  471.        Me.Edges.BottomLeft = WindowHitTestRegions.NoWhere
  472.        Me.Edges.BottomRight = WindowHitTestRegions.NoWhere
  473.  
  474.    End Sub
  475.  
  476. #End Region
  477.  
  478. #Region " Hidden methods "
  479.  
  480.    ' These methods and properties are purposely hidden from Intellisense just to look better without unneeded methods.
  481.    ' NOTE: The methods can be re-enabled at any-time if needed.
  482.  
  483.    ''' <summary>
  484.    ''' Assigns a handle to this window.
  485.    ''' </summary>
  486.    <EditorBrowsable(EditorBrowsableState.Never)>
  487.    Public Shadows Sub AssignHandle()
  488.    End Sub
  489.  
  490.    ''' <summary>
  491.    ''' Creates a window and its handle with the specified creation parameters.
  492.    ''' </summary>
  493.    <EditorBrowsable(EditorBrowsableState.Never)>
  494.    Public Shadows Sub CreateHandle()
  495.    End Sub
  496.  
  497.    ''' <summary>
  498.    ''' Creates an object that contains all the relevant information required
  499.    ''' to generate a proxy used to communicate with a remote object.
  500.    ''' </summary>
  501.    <EditorBrowsable(EditorBrowsableState.Never)>
  502.    Public Shadows Sub CreateObjRef()
  503.    End Sub
  504.  
  505.    ''' <summary>
  506.    ''' Invokes the default window procedure associated with this window.
  507.    ''' </summary>
  508.    <EditorBrowsable(EditorBrowsableState.Never)>
  509.    Public Shadows Sub DefWndProc()
  510.    End Sub
  511.  
  512.    ''' <summary>
  513.    ''' Destroys the window and its handle.
  514.    ''' </summary>
  515.    <EditorBrowsable(EditorBrowsableState.Never)>
  516.    Public Shadows Sub DestroyHandle()
  517.    End Sub
  518.  
  519.    ''' <summary>
  520.    ''' Determines whether the specified object is equal to the current object.
  521.    ''' </summary>
  522.    <EditorBrowsable(EditorBrowsableState.Never)>
  523.    Public Shadows Sub Equals()
  524.    End Sub
  525.  
  526.    ''' <summary>
  527.    ''' Serves as the default hash function.
  528.    ''' </summary>
  529.    <EditorBrowsable(EditorBrowsableState.Never)>
  530.    Public Shadows Sub GetHashCode()
  531.    End Sub
  532.  
  533.    ''' <summary>
  534.    ''' Retrieves the current lifetime service object that controls the lifetime policy for this instance.
  535.    ''' </summary>
  536.    <EditorBrowsable(EditorBrowsableState.Never)>
  537.    Public Shadows Sub GetLifetimeService()
  538.    End Sub
  539.  
  540.    ''' <summary>
  541.    ''' Obtains a lifetime service object to control the lifetime policy for this instance.
  542.    ''' </summary>
  543.    <EditorBrowsable(EditorBrowsableState.Never)>
  544.    Public Shadows Sub InitializeLifetimeService()
  545.    End Sub
  546.  
  547.    ''' <summary>
  548.    ''' Releases the handle associated with this window.
  549.    ''' </summary>
  550.    <EditorBrowsable(EditorBrowsableState.Never)>
  551.    Public Shadows Sub ReleaseHandle()
  552.    End Sub
  553.  
  554.    ''' <summary>
  555.    ''' Gets the handle for this window.
  556.    ''' </summary>
  557.    <EditorBrowsable(EditorBrowsableState.Never)>
  558.    Public Shadows Property Handle()
  559.  
  560. #End Region
  561.  
  562. #Region " IDisposable "
  563.  
  564.    ''' <summary>
  565.    ''' To detect redundant calls when disposing.
  566.    ''' </summary>
  567.    Private IsDisposed As Boolean = False
  568.  
  569.    ''' <summary>
  570.    ''' Prevent calls to methods after disposing.
  571.    ''' </summary>
  572.    ''' <exception cref="System.ObjectDisposedException"></exception>
  573.    Private Sub DisposedCheck()
  574.        If Me.IsDisposed Then
  575.            Throw New ObjectDisposedException(Me.GetType().FullName)
  576.        End If
  577.    End Sub
  578.  
  579.    ''' <summary>
  580.    ''' Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
  581.    ''' </summary>
  582.    Public Sub Dispose() Implements IDisposable.Dispose
  583.        Dispose(True)
  584.        GC.SuppressFinalize(Me)
  585.    End Sub
  586.  
  587.    ''' <summary>
  588.    ''' Releases unmanaged and - optionally - managed resources.
  589.    ''' </summary>
  590.    ''' <param name="IsDisposing">
  591.    ''' <c>true</c> to release both managed and unmanaged resources;
  592.    ''' <c>false</c> to release only unmanaged resources.
  593.    ''' </param>
  594.    Protected Sub Dispose(ByVal IsDisposing As Boolean)
  595.  
  596.        If Not Me.IsDisposed Then
  597.  
  598.            If IsDisposing Then
  599.                Me.form = Nothing
  600.                MyBase.ReleaseHandle()
  601.                MyBase.DestroyHandle()
  602.            End If
  603.  
  604.        End If
  605.  
  606.        Me.IsDisposed = True
  607.  
  608.    End Sub
  609.  
  610. #End Region
  611.  
  612. End Class
  613.  
  614. #End Region
  615.  
7072  Programación / .NET (C#, VB.NET, ASP) / Re: llenar un textbox con un combobox en: 28 Junio 2014, 06:10 am
¿Podrías explicar con mayor calidad de detalles lo que intentas conseguir?, no entendí tu pregunta.

Saludos
7073  Programación / .NET (C#, VB.NET, ASP) / Re: Archivo de Configuración. en: 28 Junio 2014, 06:06 am
Me pregunto si el uso correcto para hacer un archivo de configuracion es este:
...

Microsoft recomienda encarecidamente que los desarrolladores de aplicación .NET guardemos la configuración de usuario en el registro de Windows (antes que usar My.Settings).

Y si te fijas un poco en como trabajan las aplicaciones más profesionales (Ej: Photoshop), estas almacenan todo tipo de información tanto en el registro como en archivos locales, está todo bastante disperso.

Pero en mi opinión lo más correcto depende de tus necesidades...
...Por ejemplo, si yo desarrollo una aplicación y la quiero hacer portable con opciones configurables para el enduser, y que al portabilizar mi aplicación (copiar y pegar de un PC a otro) se mantenga esa configuración de usuario, pues obviamente no podré usar ni el registro, ni un archivo local que se almacene en otra ubicación como (Ej: APPDATA\Roaming\...) ni nada por el estilo ...porque eso lo complicaría un poquito para hacerlo persistente de un PC a otro, así que lo más correcto en mi opinión en un caso así es usar un archivo de inicialización (.ini) o en resumen un archivo de texto plano como un TXT o un XML que esté en el directorio de trabajo de la aplicación, aunque la estructura de un XML para manejar un par de opciones es complicarse la vida sinceramente...

Pero para un programa normal y corriente que se instala en un PC y que se suele mantener instalado hasta una reinstalación/actualización del SO, pues en ese caso yo me acomodaría a la interface que Microsoft provee y de muy facil acceso y manejo para crear un archivo de configuración gracias a My.Settings.

Saludos
7074  Programación / .NET (C#, VB.NET, ASP) / Re: Ayuda con textbox (Comparar y eliminar cadenas) en vs.net en: 28 Junio 2014, 05:45 am
Cierro el tema por pregunta duplicada.

PD: Te dejo esto por aquí, por si no llegas a leer mi respuesta en el otro tema:

Puedes utilizar el método Except para llevar a cabo la tarea:

Código
  1. Dim Seriales1 As String = "_xxxxxxxx_zzzzzzzzz"
  2. Dim Seriales2 As String = "_xxxxxxxx_hhhhhhhh_zzzzzzzzz"
  3. Dim Seriales3 As String = String.Join("_", Seriales2.Split("_").Except(Seriales1.Split("_")))

Saludos

Saludos
7075  Programación / .NET (C#, VB.NET, ASP) / [SOURCE] Imgur Uploader.NET en: 28 Junio 2014, 05:33 am





DESCRIPCIÓN:

Una simple aplicacición para subir imagenes (de forma anonima) usando la API de imgur.

La aplicación permite arrastrar y soltar archivos al Form, así como iniciar el programa cargando una imagen mediante argumentos commandline,
y el instalador que viene incluido en la descarga permite asociar los archivos de imagen soportados para automatizar aún más la tarea.

Nota para programadores:
Los eventos y los controles de errores en la Class ImgurAPI (así como los event-handlers suscritos a dichos eventos, en el Form principal) es algo que dejé inacabado y en fase de pruebas.





IMÁGENES:

(lo sé, es un poco feo)

   





DESCARGA:
-> http://www.mediafire.com/?12bdq6o65owy8lt

Incluye source, compilación, instalador, y portable.[/s]
7076  Programación / .NET (C#, VB.NET, ASP) / Re: Arraste de raton en aplicacion externa en: 28 Junio 2014, 04:11 am
La función Mouse_Event se ha quedado ""anticuada"" y ha sido "sustituida" por la función SendInput, te sugiero integrar la utilización de dicha función en tu aplicación.

Te dejo un regalito para ti y para todos por parte de un servidor por si te sirve de ayuda:
=> http://pastebin.com/9wGBM5nM

Ejemplo de uso:

Citar
Código
  1. SendInputs.MouseClick(SendInputs.MouseButton.RightPress)
  2. SendInputs.MouseMove(X:=5, Y:=-5)
  3. SendInputs.MouseMove(Offset:=New Point With {.X = 5, .Y = -5})
  4. SendInputs.MousePosition(Position:=New Point With {.X = 100, .Y = -500})

Saludos
7077  Programación / .NET (C#, VB.NET, ASP) / Re: Parsear código HTML en Vb.net en: 28 Junio 2014, 04:02 am
He leido en un post tuyo más reciente que comentabas la falta de atención a este post, lo digo porque de lo contrario no respondería a un post de antiguedad por no ser un buen ejemplo...



Para ser sinceros, el compañero @.:Weeds:.te ha sugerido la mejor opción que hay, pero es una librería demasiado completa y amplia para tus necesidades, lo cual resolverías descargando el source y usando un simple RegEx.

De todas formas, te dejo un ejemplo que escribí hace tiempo sobre el uso de dicha librería, espero que te sirva en algo:

Código
  1. Public Class Form1
  2.  
  3.    Private ReadOnly html As String =
  4.        <a><![CDATA[
  5. <!DOCTYPE html>
  6. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  7. <body>
  8.  
  9. <div class="infolinks"><input type="hidden" name="IL_IN_TAG" value="1"/></div><div id="main">
  10.  
  11. <div class="music">
  12.  
  13. <h2 class="boxtitle">New releases \ <small>
  14. <a href="/newalbums" title="New releases mp3 downloads" rel="bookmark">see all</a></small>
  15. </h2>
  16.  
  17. <div class="item">
  18.  
  19.     <div class="thumb">
  20. <a href="http://www.mp3crank.com/curt-smith/deceptively-heavy-121861" rel="bookmark" lang="en" title="Curt Smith - Deceptively Heavy album downloads"><img width="100" height="100" alt="Mp3 downloads Curt Smith - Deceptively Heavy" title="Free mp3 downloads Curt Smith - Deceptively Heavy" src="http://www.mp3crank.com/cover-album/Curt-Smith-Deceptively-Heavy-400x400.jpg"/></a>
  21.     </div>
  22.  
  23. <div class="release">
  24. <h3>Curt Smith</h3>
  25. <h4>
  26. <a href="http://www.mp3crank.com/curt-smith/deceptively-heavy-121861" title="Mp3 downloads Curt Smith - Deceptively Heavy">Deceptively Heavy</a>
  27. </h4>
  28. <script src="/ads/button.js"></script>
  29. </div>
  30.  
  31. <div class="release-year">
  32. <p>Year</p>
  33. <span>2013</span>
  34. </div>
  35.  
  36. <div class="genre">
  37. <p>Genre</p>
  38. <a href="http://www.mp3crank.com/genre/indie" rel="tag">Indie</a><a href="http://www.mp3crank.com/genre/pop" rel="tag">Pop</a>
  39. </div>
  40.  
  41. </div>
  42.  
  43. <div class="item">
  44.  
  45.     <div class="thumb">
  46. <a href="http://www.mp3crank.com/wolf-eyes/lower-demos-121866" rel="bookmark" lang="en" title="Wolf Eyes - Lower Demos album downloads"><img width="100" height="100" alt="Mp3 downloads Wolf Eyes - Lower Demos" title="Free mp3 downloads Wolf Eyes - Lower Demos" src="http://www.mp3crank.com/cover-album/Wolf-Eyes-–-Lower-Demos.jpg" /></a>
  47.     </div>
  48.  
  49. <div class="release">
  50. <h3>Wolf Eyes</h3>
  51. <h4>
  52. <a href="http://www.mp3crank.com/wolf-eyes/lower-demos-121866" title="Mp3 downloads Wolf Eyes - Lower Demos">Lower Demos</a>
  53. </h4>
  54. <script src="/ads/button.js"></script>
  55. </div>
  56.  
  57. <div class="release-year">
  58. <p>Year</p>
  59. <span>2013</span>
  60. </div>
  61.  
  62. <div class="genre">
  63. <p>Genre</p>
  64. <a href="http://www.mp3crank.com/genre/rock" rel="tag">Rock</a>
  65. </div>
  66.  
  67. </div>
  68.  
  69. </div>
  70.  
  71. </div>
  72.  
  73. </body>
  74. </html>
  75. ]]$cdataend$</a>.Value
  76.  
  77.    Private sb As New System.Text.StringBuilder
  78.  
  79.    Private htmldoc As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument
  80.    Private htmlnodes As HtmlAgilityPack.HtmlNodeCollection = Nothing
  81.  
  82.    Private Title As String = String.Empty
  83.    Private Cover As String = String.Empty
  84.    Private Year As String = String.Empty
  85.    Private Genres As String() = {String.Empty}
  86.    Private URL As String = String.Empty
  87.  
  88.    Private Sub Test() Handles MyBase.Shown
  89.  
  90.        ' Load the html document.
  91.        htmldoc.LoadHtml(html)
  92.  
  93.        ' Select the (10 items) nodes.
  94.        ' All "SelectSingleNode" below will use this DIV element as a starting point.
  95.        htmlnodes = htmldoc.DocumentNode.SelectNodes("//div[@class='item']")
  96.  
  97.        ' Loop trough the nodes.
  98.        For Each node As HtmlAgilityPack.HtmlNode In htmlnodes
  99.  
  100.             ' Set the values:
  101.            Title = node.SelectSingleNode(".//div[@class='release']/h4/a[@title]").GetAttributeValue("title", "Unknown Title")
  102.            Cover = node.SelectSingleNode(".//div[@class='thumb']/a/img[@src]").GetAttributeValue("src", String.Empty)
  103.            Year = node.SelectSingleNode(".//div[@class='release-year']/span").InnerText
  104.            Genres = (From genre In node.SelectNodes(".//div[@class='genre']/a") Select genre.InnerText).ToArray
  105.            URL = node.SelectSingleNode(".//div[@class='release']/h4/a[@href]").GetAttributeValue("href", "Unknown URL")
  106.  
  107.            ' Display the values:
  108.            sb.Clear()
  109.            sb.AppendLine(String.Format("Title : {0}", Title))
  110.            sb.AppendLine(String.Format("Cover : {0}", Cover))
  111.            sb.AppendLine(String.Format("Year  : {0}", Year))
  112.            sb.AppendLine(String.Format("Genres: {0}", String.Join(", ", Genres)))
  113.            sb.AppendLine(String.Format("URL   : {0}", URL))
  114.            MsgBox(sb.ToString)
  115.  
  116.        Next node
  117.  
  118.    End Sub
  119.  
  120. End Class
  121.  


+ Como descargar el source de una página:

Código
  1.    ' Get SourcePage Array
  2.    ' ( By Elektro )
  3.    '
  4.    ' Usage Examples:
  5.    ' Dim SourceLines As String() = GetSourcePageArray("http://www.ElHacker.net", TrimLines:=True)
  6.    ' For Each Line As String In SourceLines : MsgBox(Line) : Next Line
  7.    '
  8.    ''' <summary>
  9.    ''' Gets a web source page.
  10.    ''' </summary>
  11.    ''' <param name="URL">Indicates the source page URL to get.</param>
  12.    ''' <param name="TrimLines">Indicates whether to trim the lines.</param>
  13.    ''' <param name="SplitOptions">Indicates the split options.</param>
  14.    ''' <returns>System.String[][].</returns>
  15.    ''' <exception cref="Exception"></exception>
  16.    Private Function GetSourcePageArray(ByVal URL As String,
  17.                                        Optional ByVal TrimLines As Boolean = False,
  18.                                        Optional ByVal SplitOptions As StringSplitOptions =
  19.                                                       StringSplitOptions.None) As String()
  20.  
  21.        Try
  22.  
  23.            Using StrReader As New IO.StreamReader(Net.HttpWebRequest.Create(URL).GetResponse().GetResponseStream)
  24.  
  25.                If TrimLines Then
  26.  
  27.                    Return (From Line As String
  28.                           In StrReader.ReadToEnd.Split({Environment.NewLine}, SplitOptions)
  29.                           Select Line.Trim).ToArray
  30.  
  31.                Else
  32.                    Return StrReader.ReadToEnd.Split({Environment.NewLine}, SplitOptions)
  33.  
  34.                End If
  35.  
  36.            End Using
  37.  
  38.        Catch ex As Exception
  39.            Throw New Exception(ex.Message)
  40.            Return Nothing
  41.  
  42.        End Try
  43.  
  44.    End Function

+ Un breve ejemplo de la utilización de un RegEx:

Código
  1. #Region " RegEx Match Tag "
  2.  
  3.    ' [ RegEx Match Tag Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' Dim str As String = <a><![CDATA[href=>Drifter - In Search of Something More [EP] (2013)</a>]]></a>.Value
  9.    ' MsgBox(RegEx_Match_Tag(str, 1)) ' Result: Drifter - In Search of Something More [EP] (2013)
  10.  
  11.    Private Function RegEx_Match_Tag(ByVal str As String, Optional ByVal Group As Int32 = 0) As String
  12.  
  13.        ' Match criteria:
  14.        '
  15.        ' >Text<
  16.  
  17.        Dim RegEx As New System.Text.RegularExpressions.Regex( _
  18.        <a><![CDATA[>([^<]+?)<]]$cdataend$</a>.Value)
  19.  
  20.        Return RegEx.Match(str).Groups(Group).ToString
  21.  
  22.    End Function
  23.  
  24. #End Region


Saludos
7078  Programación / .NET (C#, VB.NET, ASP) / Re: Help Gui en: 28 Junio 2014, 03:51 am
el problema es que cuando meto mi codigo no me compila el codigo

que problema me pasa ?

¿Que código tienes?.

Saludos
7079  Programación / .NET (C#, VB.NET, ASP) / Re: DETECTAR EVENTO RATON Y TECLADO "ELIMINAR ARCHIVO -> ACEPTAR" en: 28 Junio 2014, 03:44 am
Opino lo mismo que el compañero @KuBox, o bien desarrollas una aplicación simple y usas API Hooking, o bien te pones a desarrollar un Driver,
hace tiempo estuve interesando sobre el mismo tema, pero me di cuenta de que era una eternidad de trabajo del que me habia podido imaginar ...y solo quería hacerlo por capricho, así que no lo intenté.

Mi consejo: olvídalo, conformate con menos, o busca una alternativa de terceros.

Algo que puedes hacer y que es mucho más llevadero ...pero con sus obvios inconvenientes, es usar un FileSystemWatcher para detectar la eliminación de un archivo (una vez ya ha sido enviado a la papelera) y la librería WindowsApiCodePack de Microsoft para manejar la papelera, entonces puedes recuperar el archivo eliminado de la papelera y su contenido, para restaurarlo a su ubicación original, ¿cual es el inconveniente?: la falta de control sobre la eliminación permanente de un archivo (Shift + Del).

Saludos!
7080  Programación / .NET (C#, VB.NET, ASP) / Re: [C#] VirusTotal Scanner 0.1 en: 28 Junio 2014, 03:32 am
Doddy, permiteme decirte que siempre has utilizado unos contrastes de colores demasiado "altos" para la vista, y yo siempre he respetado los gustos de los demás, pero es que esa GUI es la que más me ha jodido los ojos de todas las que hiciste xD, te lo digo desde el aprecio q sabes q te tengo.

Un saludo!
Páginas: 1 ... 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 [708] 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines