Ventana persistente

Deseo lograr el efecto de un msgbox en un formulario de mi aplicacion, es decir, mentener activo(este form) haste que se pulse un boton de el.
Respuesta
1
No se exactamente cual es tu proposito final en el proyecto que estas realizando, por lo que te propongo dos soluciones:
1) Mostrar el formulario de forma modal (Form1.Show vbModal) de tal manera que no podras pasar a otro formulario hasta que no lo hayas cerrado.
2) Ponerlo siempre visible. Afecta tanto a las ventanas de tu aplicacion como al resto de aplicaciones que estes ejecutando en ese momento en tu ordenador. Es un poco mas complicado:
'Declaracion de la llamada API
Public Declare Function SetWindowPos Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long
Private Sub Form_Activate()
pFormularioSiempreVisible Me
End Sub
Public Sub pFormularioSiempreVisible(frm As Form, Optional ByVal Poner As Boolean = True)
Const HWND_BOTTOM As Integer = 1
Const HWND_NOTOPMOST As Integer = -2
Const HWND_TOP As Integer = 0
Const HWND_TOPMOST As Integer = -1
Const SWP_ASYNCWINDOWPOS As Integer = &H4000
Const SWP_DEFERERASE As Integer = &H2000
Const SWP_FRAMECHANGED As Integer = &H20
Const SWP_DRAWFRAME As Integer = SWP_FRAMECHANGED
Const SWP_HIDEWINDOW As Integer = &H80
Const SWP_NOACTIVATE As Integer = &H10
Const SWP_NOCOPYBITS As Integer = &H100
Const SWP_NOMOVE As Integer = &H2
Const SWP_NOOWNERZORDER As Integer = &H200
Const SWP_NOREDRAW As Integer = &H8
Const SWP_NOREPOSITION As Integer = SWP_NOOWNERZORDER
Const SWP_NOSENDCHANGING As Integer = &H400
Const SWP_NOSIZE As Integer = &H1
Const SWP_NOZORDER As Integer = &H4
Const SWP_SHOWWINDOW As Integer = &H40
If Poner Then
SetWindowPos frm.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW Or SWP_NOACTIVATE
Else
SetWindowPos frm.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW Or SWP_NOACTIVATE
End If
End Sub

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas