Click to See Complete Forum and Search --> : how 2 put icon in bottom right


Anchor Blue
January 9th, 2000, 05:41 PM
how do you put your icon and stuff in that taskbar thing in the bottom right corner?

AndyK
January 9th, 2000, 08:20 PM
That bottom-right thing called system tray and search for it in codeguru's search engine, because code is kind of big for me to post

wilton
January 10th, 2000, 12:17 AM
Here's some useful code:



Put this part in a module

'Name of Application
Const Balloon as string = "Email Check"

'user defined type required by Shell_NotifyIcon API call
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

'constants required by Shell_NotifyIcon API call:
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 'Button down
public Const WM_LBUTTONUP = &H202 'Button up
public Const WM_LBUTTONDBLCLK = &H203 'Double-click
public Const WM_RBUTTONDOWN = &H204 'Button down
public Const WM_RBUTTONUP = &H205 'Button up
public Const WM_RBUTTONDBLCLK = &H206 'Double-click
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



Sub ShowTrayIcon()

'ShowTray-Icon!
frmMain.Show
frmMain.Refresh
With nid
.cbSize = len(nid)
.hwnd = frmMain.picAnon.hwnd
.uId = vbNull
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.uCallBackMessage = WM_MOUSEMOVE
.hIcon = frmMain.Icon
.szTip = Balloon & vbNullChar
End With

Shell_NotifyIcon NIM_ADD, nid

End the module code

Place this code in the code section of your main form

This sub routine is a mousemove event for a picture box on the form.:

private Sub picAnon_MouseMove(Button as Integer, Shift as Integer, X as Single, Y as Single)

static lngMsg as Long
static bInHere as Boolean

If bInHere then Exit Sub
bInHere = true

If me.ScaleMode = vbPixels then
lngMsg = X
else
lngMsg = X / Screen.TwipsPerPixelX
End If

Select Case lngMsg
Case WM_RBUTTONUP
'This was commented out because we don't want the main window coming to the front on a right clickup
'SetForegroundWindow (me.hwnd)
'This Displays the menu on a right click
me.PopupMenu me.menuPopupSys

Case WM_LBUTTONDOWN

Debug.print "X " & X
Debug.print "TPP " & Screen.TwipsPerPixelX
Debug.print "lngMsg " & lngMsg
If frmMain.Visible then
SetForegroundWindow (me.hwnd)
else
frmMain.WindowState = Normal
frmMain.Show
End If

Case WM_LBUTTONDBLCLK

Case else

End Select

bInHere = false

End Sub

End Sub

You'll want to call showtrayicon in you code to invoke the creation of the icon.

You'll need to use this code to destroy the icon.
'Remove the notify icon in the status are
Shell_NotifyIcon NIM_DELETE, nid