Foros del Web » Programación para mayores de 30 ;) » .NET »

Truco Truco 1... No Mover ni cerrar un form en Vis Basic

Estas en el tema de Truco Truco 1... No Mover ni cerrar un form en Vis Basic en el foro de .NET en Foros del Web. Caso 2 No dejar cerrar el form. Ni Moverlos Propiedades Border estilo, Minimizar, maximizar y Cerrar No Importa Como esten Configurados. Public Class frmConfStock Inherits ...
  #1 (permalink)  
Antiguo 04/08/2004, 21:26
 
Fecha de Ingreso: mayo-2004
Ubicación: cordoba
Mensajes: 27
Antigüedad: 20 años
Puntos: 0
De acuerdo Truco Truco 1... No Mover ni cerrar un form en Vis Basic

Caso 2 No dejar cerrar el form. Ni Moverlos

Propiedades Border estilo, Minimizar, maximizar y Cerrar No Importa Como esten Configurados.

Public Class frmConfStock
Inherits System.Windows.Forms.Form
Dim rcCaption As Rectangle 'Necesaria
..............
..............

Private Sub CmdSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdSalir1.ClickButton
If EstadoProceso Then
Me.Close()
Else
MessageBox.Show("El Proceso Actualizaciión No ha Terminado.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End Sub


Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_NCHITTEST Then
Call MyForCaptionWindow(Me, m, rcCaption)
Else
MyBase.WndProc(m)
End If
End Sub
.............

End Clase

Ademas Agregamos un Modulo

Imports System.Windows.Forms

Module ApiHitTestHandling

Public Const WM_NCHITTEST = &H84

Public Enum HitTestResult
HTBORDER = 18
HTBOTTOM = 15
HTBOTTOMLEFT = 16
HTBOTTOMRIGHT = 17
HTCAPTION = 2
HTCLIENT = 1
HTERROR = (-2)
HTGROWBOX = 4
HTHSCROLL = 6
HTLEFT = 10
HTMAXBUTTON = 9
HTMENU = 5
HTMINBUTTON = 8
HTNOWHERE = 0
HTRIGHT = 11
HTSYSMENU = 3
HTTOP = 12
HTTOPLEFT = 13
HTTOPRIGHT = 14
HTVSCROLL = 7
HTTRANSPARENT = (-1)
HTOBJECT = 19
HTCLOSE = 20
HTHELP = 21
End Enum

Public Sub MyForCaptionWindow(ByVal fParent As Form, ByRef m As Message, ByVal CaptionRectangle As Rectangle)
If m.Msg = WM_NCHITTEST Then
Dim ptClickLocation As New Point(m.LParam.ToInt32)
ptClickLocation = fParent.PointToClient(ptClickLocation)

If CaptionRectangle.Contains(ptClickLocation) Then
m.Result = New IntPtr(HitTestResult.HTCAPTION)
Else
m.Result = New IntPtr(HitTestResult.HTCLIENT)
End If
End If
End Sub

End Module

Eso es todo espero que les sirva y ASUNTO SELLADO.

Saludossssssssss.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:56.