View Full Version : In Visual Basic
softgames
11-04-2003, 17:37
Come faccio che quando preme un pulsante l'applicazione si va a mettere nella taskbar??
Che intendi per TaskBar ?
softgames
11-04-2003, 20:39
Intendo per quella barra in basso a destra dove c'è l'orologio
Metti queste righe di codice in un modulo BAS:
****************************************
Public Type NOTIFYICONDATA
cbSize As Long
hWnd As Long
uId As Long
uFlags As Long
uCallBackMessage As Long
hIcon As Long
szTip As String * 64
End Type
Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_RBUTTONUP = &H205
Public Const WM_RBUTTONDBLCLK = &H206
Public Declare Function SetForegroundWindow Lib "user32" _
(ByVal hWnd As Long) As Long
Public Declare Function Shell_NotifyIcon Lib "SHELL32" _
Alias "Shell_NotifyIconA" _
(ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Public nid As NOTIFYICONDATA
*************************************
Le righe seguenti invece in una Form (file .frm)
*****************************************
Private Sub Form_Load()
With nid
.cbSize = Len(nid)
.hWnd = Me.hWnd
.uId = vbNull
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.uCallBackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon
.szTip = "Tip Notify TrayIcon" & vbNullChar
End With
Shell_NotifyIcon NIM_ADD, nid
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Result As Long
Dim msg As Long
If Me.ScaleMode = vbPixels Then
msg = X
Else
msg = X / Screen.TwipsPerPixelX
End If
Select Case msg
Case WM_LBUTTONUP
Me.WindowState = vbNormal
Result = SetForegroundWindow(Me.hWnd)
Case WM_RBUTTONUP
PopupMenu mApps
Case Else
Me.WindowState = vbNormal
Result = SetForegroundWindow(Me.hWnd)
End Select
End Sub
Private Sub Form_Resize()
If Me.WindowState = vbMinimized Then
Me.Hide
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Me.WindowState = vbMinimized
Me.Hide
End Sub
Private Sub mNotePad_Click()
Shell ("C:\Windows\NotePad.exe")
End Sub
Private Sub mCalc_Click()
Shell ("C:\Windows\Calc.exe")
End Sub
Private Sub mInfo_Click()
Text1.Text = "Vb Tray Icon Menu"
Me.WindowState = vbNormal
Result = SetForegroundWindow(Me.hWnd)
Me.Show
End Sub
Private Sub mPopExit_Click()
Shell_NotifyIcon NIM_DELETE, nid
Unload Me
End Sub
***************************
Ciao ciao ;-)
Originally posted by "softgames"
Intendo per quella barra in basso a destra dove c'è l'orologio
Si chiama SysTray ;) La TaskBar è quella dove ci sono i bottoni delle varie applicazioni in esecuzione...
cionci, invece di riprendere softgames per aver scritto TAskBar invece di SysTray, trovagli una soluzione al problema come ho fatto io.
Sai che se ne fa delle tue critiche? ;)
Senza rancore :p
Io la soluzione ce l'avevo già pronta (tra l'altro l'avevo già postata in un altro thread, anche recente)...solo che non avevo capito cosa intendeva...
Poi perchè postare un altro codice quando il tuo andava benissimo ? Se fossi arrivato prima di te, l'avrei postato io ;)
softgames
12-04-2003, 20:51
Grazie!! :)
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.