|
-
Aug 10th, 2000, 02:07 PM
#1
Thread Starter
Member
I would also like to have it so that the icon doesn't show in the task bar, (it only appears in the system tray ie. ICQ).
-
Aug 10th, 2000, 02:16 PM
#2
transcendental analytic
You could download my trayicon OCX on my homepage, refer to it in your project, add the control to your form.
To make your form not shown in taskbar put showintaskbar to false (for the form(s) you have).
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 10th, 2000, 03:33 PM
#3
Make 2 Forms (frmTray and Form1). On frmTray, make a PictureBox called imgTrayIcon (with an Icon loaded) and set the Index to 0. Set Form1's ShowInTaskBar property to False.
Code for a Module
Code:
Option Explicit
Sub Main()
Load frmTray
Form1.Show
End Sub
Code for frmTray
Code:
Private Const NIM_ADD = &H0 'Adds an icon to the taskbar notification area
Private Const NIM_MODIFY = &H1 'Changes the icon, tooltip text or notification message for an icon in the notification area
Private Const NIM_DELETE = &H2 'Deletes an icon from the taskbar notification area
Private Const NIF_MESSAGE = &H1 'hIcon is valid
Private Const NIF_ICON = &H2 'uCallbackMessage is valid
Private Const NIF_TIP = &H4 'szTip is valid
Private Const WM_MOUSEMOVE = &H200 'MouseMove message identifier
Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const WM_RBUTTONDBLCLK = &H206
Private Const WM_RBUTTONDOWN = &H204
Private Const WM_RBUTTONUP = &H205
Private Type NOTIFYICONDATA
cbSize As Long
hWnd As Long 'Handle of window that receives notification messages
uID As Long 'Application-defined identifier of the taskbar icon
uFlags As Long 'Flags indicating which structure members contain valid data
uCallbackMessage As Long 'Application defined callback message
hIcon As Long 'Handle of taskbar icon
szTip As String * 64 'Tooltip text to display for icon
End Type
Dim mtIconData As NOTIFYICONDATA
Dim mnLight As Integer
Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Long
Private Sub Form_Load()
AddIconToTray
End Sub
Private Sub Form_Unload(Cancel As Integer)
DeleteIconFromTray 'Put cleanup code here so that it always gets executed
Set frmTray = Nothing
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static bBusy As Boolean
If bBusy = False Then
bBusy = True
Select Case CLng(X)
Case WM_LBUTTONDBLCLK ' Left button Double Clicked
Form1.Show ' Show our Form
Case WM_LBUTTONDOWN ' Left button Down
If Shell_NotifyIcon(NIM_MODIFY, mtIconData) = 0 Then
MsgBox "Unable to change icon in system tray!"
End If
Case WM_LBUTTONUP 'Left mouse button released
Case WM_RBUTTONDBLCLK 'Double-click right mouse button
Case WM_RBUTTONDOWN 'Right mouse button pressed
End Select
bBusy = False
End If
End Sub
Private Sub AddIconToTray() 'Adds an icon to the taskbar notification area
With mtIconData
.cbSize = Len(mtIconData)
.hWnd = Me.hWnd 'Use the form to receive callback messages.
.uCallbackMessage = WM_MOUSEMOVE 'Tell icon to send MouseMove messages.
.uID = 1& 'Application defined identifier
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.hIcon = imgTrayIcon(0).Picture 'Initial icon
.szTip = "ToolTipText" & Chr$(0) 'Initial tooltip for icon
If Shell_NotifyIcon(NIM_ADD, mtIconData) = 0 Then 'Create icon in tray
MsgBox "Unable to add icon to system tray!"
End If
End With
End Sub
Private Sub DeleteIconFromTray()
If Shell_NotifyIcon(NIM_DELETE, mtIconData) = 0 Then
MsgBox "Unable to delete icon from system tray!"
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|