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

 

 


Tema destacado: Guía actualizada para evitar que un ransomware ataque tu empresa


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Minizar form y ponerlo al lado del reloj
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] 2 Ir Abajo Respuesta Imprimir
Autor Tema: Minizar form y ponerlo al lado del reloj  (Leído 5,521 veces)
_CrisiS_

Desconectado Desconectado

Mensajes: 286


Ver Perfil
Minizar form y ponerlo al lado del reloj
« en: 1 Septiembre 2010, 03:45 am »

Buenas otra dudilla =P, Como aria que por un boton se minise mi sistema  desaparesca la ventana del form para situarse al lado del reloj y al aserle doble clic se me abra asia un form ejemplo login


En línea

xkiz ™


Desconectado Desconectado

Mensajes: 1.252


Ver Perfil WWW
Re: Minizar form y ponerlo al lado del reloj
« Respuesta #1 en: 1 Septiembre 2010, 05:02 am »

Cómo usar la bandeja del sistema desde Visual Basic


En línea

_katze_

Desconectado Desconectado

Mensajes: 140



Ver Perfil WWW
Re: Minizar form y ponerlo al lado del reloj
« Respuesta #2 en: 1 Septiembre 2010, 05:09 am »

noc si te sirva man no son como los grandes codes que postean aki estos grandes !

Código
  1. 'esto va en un modulo.bas
  2. 'lo modifique y lo cree a mi gusto con funciones esta bn pero lo pueden modificar mas si kieren
  3. '_k4tz3_ vb6.0
  4. Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
  5. Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
  6. Public Type NOTIFYICONDATA
  7. cbSize As Long
  8. hwnd As Long
  9. uId As Long
  10. uFlags As Long
  11. uCallBackMessage As Long
  12. hIcon As Long
  13. szTip As String * 128
  14. dwState As Long
  15. dwStateMask As Long
  16. szInfo As String * 256
  17. uTimeout As Long
  18. szInfoTitle As String * 64
  19. dwInfoFlags As Long
  20. End Type
  21. Public Const NIM_ADD = &H0
  22. Public Const NIM_DELETE = &H2
  23. Public Const NIF_MESSAGE = &H1
  24. Public Const NIF_ICON = &H2
  25. Public Const NIF_INFO = &H10
  26. Public Const NIF_TIP = &H4
  27. Public Const WM_MOUSEMOVE = &H200
  28. Public Const WM_LBUTTONDBLCLK = &H203
  29. Public Const WM_LBUTTONDOWN = &H201
  30. Public Const WM_LBUTTONUP = &H202
  31. Public Const WM_RBUTTONDBLCLK = &H206
  32. Public Const WM_RBUTTONDOWN = &H204
  33. Public Const WM_RBUTTONUP = &H205
  34. Public nID As NOTIFYICONDATA
  35. Public Function CierraTray(frm As Form)
  36. With nID
  37. .cbSize = Len(nID)
  38. .hwnd = frm.hwnd
  39. .uId = 1&
  40. End With
  41. Shell_NotifyIcon NIM_DELETE, nID
  42. End Function
  43. Public Function showfrm(frm As Form)
  44.    If frm.WindowState = 1 Then frm.WindowState = 0
  45.    frm.Show
  46.    End Function
  47. Public Function tray(frm As Form, Title As String)
  48. With nID
  49. .cbSize = Len(nID)
  50. .hwnd = frm.hwnd
  51. .uId = vbNull
  52. .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE Or NIF_INFO
  53. .uCallBackMessage = WM_MOUSEMOVE
  54. .hIcon = frm.Icon
  55. .szTip = Title & Chr(0) '& vbNullChar
  56. .dwState = 0
  57. .dwStateMask = 0
  58. .szInfoTitle = "mensaje" & Chr(0)
  59. .szInfo = "mensaje" & vbNullChar
  60. .uTimeout = 1
  61. End With
  62. Shell_NotifyIcon NIM_ADD, nID
  63. End Function



con esto seria mas o menos una forma de aplicarlo !!!
Código
  1. Private Declare Function ReleaseCapture Lib "user32.dll" () As Long
  2. Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  3. Private Const WM_NCLBUTTONDOWN      As Long = &HA1
  4. Private Const HTCAPTION             As Long = 2
  5.  
  6. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  7.  
  8.    ReleaseCapture
  9.    SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
  10.  
  11.   Dim lResult As Long
  12.    Dim lMsg As Long
  13.  
  14.    If Me.ScaleMode = vbPixels Then
  15.        lMsg = x
  16.    Else
  17.        lMsg = x / Screen.TwipsPerPixelX
  18.    End If
  19.  
  20.    Select Case lMsg
  21.        Case WM_RBUTTONUP
  22.            lResult = SetForegroundWindow(Me.hwnd)
  23.           Me.PopupMenu mmenutray 'click derecho en el systray llama al popumenu dado en parametro !
  24.        Case WM_LBUTTONDBLCLK
  25.            If Me.Visible = False Then
  26.                Call showfrm(Me) ' llamamos al formulario llamando a showfrm!
  27.  
  28.            End If
  29.    End Select
  30.    End Sub
  31. 'para llamar al systray cuando se minimized
  32. Private Sub Form_Resize()
  33. If Me.WindowState = vbMinimized Then
  34.            Call tray(Me, "hola")
  35.            Me.Hide
  36.        End If
  37. End Sub
  38.  
  39. Private Sub Form_Unload(Cancel As Integer)
  40. Call CierraTray(Me)
  41. end sub
  42. 'mas claro que el agua
  43.  

« Última modificación: 1 Septiembre 2010, 17:55 pm por _katze_ » En línea

_CrisiS_

Desconectado Desconectado

Mensajes: 286


Ver Perfil
Re: Minizar form y ponerlo al lado del reloj
« Respuesta #3 en: 1 Septiembre 2010, 06:47 am »

xkiz > por alguna razon nunca puedo ver paginas de support.microsoft =S.

 _katze_> no me funciono =S
En línea

xmbeat92

Desconectado Desconectado

Mensajes: 40



Ver Perfil
Re: Minizar form y ponerlo al lado del reloj
« Respuesta #4 en: 1 Septiembre 2010, 07:09 am »

http://foro.elhacker.net/programacion_vb/efecto_minimizar_al_systray_con_drawanimatedrect_shellnoty-t284088.0.html
En línea

El hombre encuentra a Dios detrás de cada puerta que la ciencia logra abrir. -Einstein
xkiz ™


Desconectado Desconectado

Mensajes: 1.252


Ver Perfil WWW
Re: Minizar form y ponerlo al lado del reloj
« Respuesta #5 en: 1 Septiembre 2010, 17:29 pm »

xkiz > por alguna razon nunca puedo ver paginas de support.microsoft =S.

pongo aca el code que muestra  Microsoft:

Código
  1. 'user defined type required by Shell_NotifyIcon API call
  2. Public Type NOTIFYICONDATA
  3.    cbSize As Long
  4.    hwnd As Long
  5.    uId As Long
  6.    uFlags As Long
  7.    uCallBackMessage As Long
  8.    hIcon As Long
  9.    szTip As String * 64
  10. End Type
  11.  
  12. 'constants required by Shell_NotifyIcon API call:
  13. Public Const NIM_ADD = &H0
  14. Public Const NIM_MODIFY = &H1
  15. Public Const NIM_DELETE = &H2
  16. Public Const NIF_MESSAGE = &H1
  17. Public Const NIF_ICON = &H2
  18. Public Const NIF_TIP = &H4
  19. Public Const WM_MOUSEMOVE = &H200
  20. Public Const WM_LBUTTONDOWN = &H201     'Button down
  21. Public Const WM_LBUTTONUP = &H202       'Button up
  22. Public Const WM_LBUTTONDBLCLK = &H203   'Double-click
  23. Public Const WM_RBUTTONDOWN = &H204     'Button down
  24. Public Const WM_RBUTTONUP = &H205       'Button up
  25. Public Const WM_RBUTTONDBLCLK = &H206   'Double-click
  26.  
  27. Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
  28. Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
  29.  
  30. Public nid As NOTIFYICONDATA
  31.  

Código
  1. Private Sub Form_Load()
  2.       'the form must be fully visible before calling Shell_NotifyIcon
  3. Me.Show
  4. Me.Refresh
  5. With nid
  6.    .cbSize = Len(nid)
  7.    .hwnd = Me.hwnd
  8.    .uId = vbNull
  9.    .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
  10.    .uCallBackMessage = WM_MOUSEMOVE
  11.    .hIcon = Me.Icon
  12.    .szTip = "Your ToolTip" & vbNullChar
  13. End With
  14. Shell_NotifyIcon NIM_ADD, nid
  15. End Sub
  16.  
  17. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  18. 'this procedure receives the callbacks from the System Tray icon.
  19. Dim Result As Long
  20. Dim msg As Long
  21. 'the value of X will vary depending upon the scalemode setting
  22. If Me.ScaleMode = vbPixels Then
  23.    msg = X
  24. Else
  25.    msg = X / Screen.TwipsPerPixelX
  26. End If
  27.  
  28. Select Case msg
  29.    Case WM_LBUTTONUP        '514 restore form window
  30.         Me.WindowState = vbNormal
  31.         Result = SetForegroundWindow(Me.hwnd)
  32.         Me.Show
  33.    Case WM_LBUTTONDBLCLK    '515 restore form window
  34.         Me.WindowState = vbNormal
  35.         Result = SetForegroundWindow(Me.hwnd)
  36.         Me.Show
  37.    Case WM_RBUTTONUP        '517 display popup menu
  38.         Result = SetForegroundWindow(Me.hwnd)
  39.         Me.PopupMenu Me.mPopupSys
  40. End Select
  41.  
  42. End Sub
  43.  
  44. Private Sub Form_Resize()
  45. 'this is necessary to assure that the minimized window is hidden
  46. If Me.WindowState = vbMinimized Then Me.Hide
  47. End Sub
  48.  
  49. Private Sub Form_Unload(Cancel As Integer)
  50. 'this removes the icon from the system tray
  51. Shell_NotifyIcon NIM_DELETE, nid
  52. End Sub
  53.  
  54. Private Sub mPopExit_Click()
  55. 'called when user clicks the popup menu Exit command
  56. Unload Me
  57. End Sub
  58.  
  59. Private Sub mPopRestore_Click()
  60. 'called when the user clicks the popup menu Restore command
  61. Dim Result As Long
  62. Me.WindowState = vbNormal
  63. Result = SetForegroundWindow(Me.hwnd)
  64. Me.Show
  65. End Sub
  66.  


En línea

_katze_

Desconectado Desconectado

Mensajes: 140



Ver Perfil WWW
Re: Minizar form y ponerlo al lado del reloj
« Respuesta #6 en: 1 Septiembre 2010, 17:56 pm »

hay te modifique mi code, lo saque de un soft que tenia y es por eso que te daba un error en el resise ! proba y copia y veras que funciona!!
tmb te dejo un ejemplo echo para que veas ! modifiques a gusto
http://www.sendspace.com/file/mp5lx3
« Última modificación: 1 Septiembre 2010, 18:05 pm por _katze_ » En línea

_CrisiS_

Desconectado Desconectado

Mensajes: 286


Ver Perfil
Re: Minizar form y ponerlo al lado del reloj
« Respuesta #7 en: 2 Septiembre 2010, 04:23 am »

=o vaya si funciono, solo un par de cosillas:
-Cuando se le haga doble clic seria bueno q desaparesca de la barra y vuelva como una ventana normal .

- Lo estoy pasando para vb net (que es donde lo nesesito , por q en el 6 salio =P), mi problema asta ahorita para migrarlo es en esta linea:

vb6> szTip As String * 128

vb net > Dim szTip As String * 128    // pero me marca error y dice se esperaba fin de la instruccion
En línea

_katze_

Desconectado Desconectado

Mensajes: 140



Ver Perfil WWW
Re: Minizar form y ponerlo al lado del reloj
« Respuesta #8 en: 2 Septiembre 2010, 18:28 pm »

con mi code cada uno lo modifica a gusto! con lo que dices ni idea !nunca intente migrarlo para vb.net  :-X
En línea

ranslsad


Desconectado Desconectado

Mensajes: 492


Dim Ranslsad as String * :P - Que Vicio!


Ver Perfil WWW
Re: Minizar form y ponerlo al lado del reloj
« Respuesta #9 en: 20 Septiembre 2010, 12:02 pm »

Miren para ahorrar cantidad de codigo en sus formularios/modulos les dejo un UserControl que maneja esto a la perfeccion!

http://www.filefront.com/17305067/SysTray.rar

Espero que les sea de mas utilidad!, Es el que uso yo en mis aplicaciones.
Y tambien os da la posibilidad de enviar mensajes popupbaloon nose si algunos saben lo que es, compruebenlo!

Código
  1. 'Agregar Icono
  2. SysTray1.AgregarIcono Me.Icon, "Nombre"
  3. 'qUITAR Icono
  4. SysTray1.QuitarIcono
  5.  
  6. 'Clickear en el icono
  7. Private Sub SysTray1_MouseUp(Button As Integer)
  8. PopupMenu MenuSystray
  9. End Sub
  10.  
  11. 'Minimizar Programa AL Tray
  12. SysTray1.AnimateWindow Me
  13.  
  14. 'Enviar Mensaje
  15. systray1.mostrarglobo "Hola", ..., "titulo"

Salu2

Ranslsad
En línea

Páginas: [1] 2 Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Minimizar ventana al lado del reloj en la barra de tareas. « 1 2 »
Programación C/C++
Destro- 10 8,152 Último mensaje 12 Enero 2011, 21:32 pm
por Destro-
Como abrir un form al lado izquierdo de otro form?
.NET (C#, VB.NET, ASP)
_CrisiS_ 1 3,152 Último mensaje 31 Diciembre 2017, 11:04 am
por Eleкtro
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines