Test Foro de elhacker.net SMF 2.1

Programación => Programación General => .NET (C#, VB.NET, ASP) => Mensaje iniciado por: Zeroql en 24 Agosto 2010, 04:37 AM

Título: Problemas con redibujado de lineas en el form
Publicado por: Zeroql en 24 Agosto 2010, 04:37 AM
Buenas bueno resulta que tengo un form que al iniciarse se dibujan unas lineas. normal uso el siguiente metodo:

Código (vbnet) [Seleccionar]
Private Sub frmAddItem_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim oPen As New Pen(Color.DimGray, 1)
        Dim oGraphics As Graphics = Me.CreateGraphics
        oGraphics.DrawLine(oPen, 0, 0, 0, Me.Height)
        oGraphics.DrawLine(oPen, Me.Width - 1, 0, Me.Width - 1, Me.Height)
        oGraphics.DrawLine(oPen, 0, Me.Height - 1, Me.Width, Me.Height - 1)
        oPen = New Pen(Color.DarkGray, 1)
        oGraphics.DrawLine(oPen, 1, 0, 1, Me.Height)
        oGraphics.DrawLine(oPen, Me.Width - 2, 0, Me.Width - 2, Me.Height)
        oGraphics.DrawLine(oPen, 0, Me.Height - 2, Me.Width, Me.Height - 2)
        oPen.Dispose()
        oGraphics.Dispose()
    End Sub


ahi no tengo problema. pero resulta que deseo hacer el form redimencionable y borrar estas lineas y crear otras nuevas con el nuevo tamaño del form.
¿Como hago para borrar las antiguas lineas?


De ante mano les agradezco la ayuda
Título: Re: Problemas con redibujado de lineas en el form
Publicado por: [D4N93R] en 24 Agosto 2010, 04:47 AM
Cada vez que el formulario necesita dibujarse, se llama a ese método que tu tienes, por lo tanto solo tienes que redimensionar el formulario y en ese evento Obligas al form a dibujarse de nuevo, esto lo haces llamando al método Invalidate del Form. Saludos!
Título: Re: Problemas con redibujado de lineas en el form
Publicado por: Zeroql en 24 Agosto 2010, 04:49 AM
Heee ya lo intente y no me da!!!
Título: Re: Problemas con redibujado de lineas en el form
Publicado por: [D4N93R] en 24 Agosto 2010, 04:54 AM
Postea tu código, si es muy largo puedes ponerlo en pastebin.com
Título: Re: Problemas con redibujado de lineas en el form
Publicado por: Zeroql en 24 Agosto 2010, 05:00 AM
Posteo el que tengo actualmente.


Contiene, un Label=lblTitle, un panel=pnTitle,2 imagenes= picExit; picMaxMin, y algunas funciones de manejo de ventanas.
Código (vbnet) [Seleccionar]
Public Class frmAddItem

    Private maximized As Boolean                        'Indica si el formulario esta maximizado o normal

    Private Sub frmAddItem_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        CloseForm(Me.Name)
    End Sub

    Private Sub frmAddItem_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.MdiParent = mdiMain
        loadImgsTitle(Me)
        loadForm(Me.Name, Me.Text)
    End Sub

    Private Sub frmAddItem_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim oPen As New Pen(Color.DimGray, 1)
        Dim oGraphics As Graphics = Me.CreateGraphics
        oGraphics.DrawLine(oPen, 0, 0, 0, Me.Height)
        oGraphics.DrawLine(oPen, Me.Width - 1, 0, Me.Width - 1, Me.Height)
        oGraphics.DrawLine(oPen, 0, Me.Height - 1, Me.Width, Me.Height - 1)
        oPen = New Pen(Color.DarkGray, 1)
        oGraphics.DrawLine(oPen, 1, 0, 1, Me.Height)
        oGraphics.DrawLine(oPen, Me.Width - 2, 0, Me.Width - 2, Me.Height)
        oGraphics.DrawLine(oPen, 0, Me.Height - 2, Me.Width, Me.Height - 2)
        oPen.Dispose()
        oGraphics.Dispose()
    End Sub

    Private Sub frmAddItem_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        If maximized = True Then
            Me.Width = mdiMain.ClientRectangle.Width - frmMenu.Width - 5
            Me.Height = mdiMain.ClientRectangle.Height - frmTaskBar.Height - 5
            If mdiMain.mnuMain.Visible = True Then
                Me.Top = mdiMain.mnuMain.Height + 2
            Else
                Me.Top = 0
            End If
        Else
            Me.Width = 687
            Me.Height = 560
            Me.Left = (mdiMain.ClientRectangle.Width - Me.Width) / 2
            Me.Top = (mdiMain.ClientRectangle.Height - Me.Height) / 2
        End If
        pnTitle.Width = Me.Width
        picExit.Left = pnTitle.Width - picExit.Width - 3
        picMaxMin.Left = picExit.Left - picMaxMin.Width - 3
        Me.Left = frmMenu.Width
    End Sub

    Private Sub picExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picExit.Click
        Me.Close()
    End Sub

    Private Sub picExit_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picExit.MouseMove
        Dim shellR = New shellresx.clsRes
        picExit.Image = shellR.useImage("btExitS")
    End Sub

    Private Sub picMaxMin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picMaxMin.Click
        maximized = Not maximized
        frmAddItem_Resize(Nothing, Nothing)
        me.refresh
        frmAddItem_Paint(Nothing, Nothing)
    End Sub

    Private Sub picMaxMin_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picMaxMin.MouseMove
        Dim shellR = New shellresx.clsRes
        picMaxMin.Image = shellR.useImage("btMaxS")
    End Sub

    Private Sub pnTitle_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnTitle.MouseDown
        MoveForm(Me)
    End Sub

    Private Sub pnTitle_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnTitle.MouseMove
        Dim shellR = New shellresx.clsRes
        picExit.Image = shellR.useImage("btExitN")
        picMaxMin.Image = shellR.useImage("btMaxN")
    End Sub
End Class



Título: Re: Problemas con redibujado de lineas en el form
Publicado por: [D4N93R] en 24 Agosto 2010, 05:23 AM
En el método que controla el Resize, frmAddItem_Resize, tienes que llamar a Invalidate. Pruébalo a ver.

Me voy a dormir, xD sigo mañana!
Título: Re: Problemas con redibujado de lineas en el form
Publicado por: 43H4FH44H45H4CH49H56H45H en 24 Agosto 2010, 05:34 AM
En el  frmAddItem_Resize colocas:

Código (vbnet) [Seleccionar]
Me.Refresh()

y con eso basta.