Buenas bueno resulta que tengo un form que al iniciarse se dibujan unas lineas. normal uso el siguiente metodo:
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
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!
Heee ya lo intente y no me da!!!
Postea tu código, si es muy largo puedes ponerlo en pastebin.com
Posteo el que tengo actualmente.
Contiene, un Label=lblTitle, un panel=pnTitle,2 imagenes= picExit; picMaxMin, y algunas funciones de manejo de ventanas.
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
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!
En el frmAddItem_Resize colocas:
Me.Refresh()
y con eso basta.