?
Solved

Icon in Taskbar ?

Posted on 2003-03-11
3
Medium Priority
?
379 Views
Last Modified: 2010-04-07
At the time of installment of our software , how can we make our icon appear in the right hand side of the taskbar(not sure what it is called as )....where curent time appears...?
0
Comment
Question by:Amita
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 150 total points
ID: 8109874
Hi Amita,

Here is an example of how to achieve this, there are many such samples available. Just search for Shell_NotifyIcon either here or on google for example.

'Download the full source+pictures+... at http://kpdteam.hypermart.net/download/tray.zip
Private 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

Private Const NIM_ADD = &H0
Private Const NIM_MODIFY = &H1
Private Const NIM_DELETE = &H2
Private Const NIF_MESSAGE = &H1
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4

Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_RBUTTONUP = &H205

Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Dim TrayI As NOTIFYICONDATA
Private Sub Form_Load()
    TrayI.cbSize = Len(TrayI)
    'Set the window's handle (this will be used to hook the specified window)
    TrayI.hWnd = pichook.hWnd
    'Application-defined identifier of the taskbar icon
    TrayI.uId = 1&
    'Set the flags
    TrayI.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
    'Set the callback message
    TrayI.ucallbackMessage = WM_LBUTTONDOWN
    'Set the picture (must be an icon!)
    TrayI.hIcon = imgIcon(2).Picture
    'Set the tooltiptext
    TrayI.szTip = "Recent" & Chr$(0)
    'Create the icon
    Shell_NotifyIcon NIM_ADD, TrayI

    Me.Hide
End Sub
Private Sub Form_Unload(Cancel As Integer)
    'remove the icon
    TrayI.cbSize = Len(TrayI)
    TrayI.hWnd = pichook.hWnd
    TrayI.uId = 1&
    Shell_NotifyIcon NIM_DELETE, TrayI
    End
End Sub
Private Sub mnuPop_Click(Index As Integer)
    Select Case Index
        Case 0
            MsgBox "KPD-Team 1998" + Chr$(13) + "URL: http://www.allapi.net/" + Chr$(13) + "E-Mail: KPDTeam@Allapi.net", vbInformation + vbOKOnly
        Case 2
            Unload Me
    End Select
End Sub
Private Sub pichook_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Msg = X / Screen.TwipsPerPixelX
    If Msg = WM_LBUTTONDBLCLK Then
        'Left button double click
        mnuPop_Click 0
    ElseIf Msg = WM_RBUTTONUP Then
        'Right button click
        Me.PopupMenu mnuPopUp
    End If
End Sub
Private Sub Timer1_Timer()
    Static Tek As Integer
    'Animate the icon
    Me.Icon = imgIcon(Tek).Picture
    TrayI.hIcon = imgIcon(Tek).Picture
    Tek = Tek + 1
    If Tek = 3 Then Tek = 0
    Shell_NotifyIcon NIM_MODIFY, TrayI
End Sub


Tim Cottee MCSD, MCDBA, CPIM
http://www.timcottee.tk 

Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 8109895
It's called System Tray.

Here is an example:

Private 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

Private Const NIM_ADD = &H0
Private Const NIM_MODIFY = &H1
Private Const NIM_DELETE = &H2
Private Const NIF_MESSAGE = &H1
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4

Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_LBUTTONUP = &H202
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_RBUTTONUP = &H205

Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Dim TrayI As NOTIFYICONDATA

Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Private Const SW_HIDE = 0
Private Const SW_SHOW = 5
Private Const SW_MAXIMIZE = 3
Private Const SW_MINIMIZE = 6
Private Const SW_NORMAL = 1

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    'Divide by Screen.TwipsPerPixelX if ScaleMode = vbTwips
    If Me.ScaleMode = vbTwips Then
        msg = x / Screen.TwipsPerPixelX
    Else
        msg = x
    End If
    If msg = WM_LBUTTONDBLCLK Then
        'Left button double click
        LeftButtonDlbClick
    ElseIf msg = WM_LBUTTONUP Or msg = WM_RBUTTONUP Then
        'Left/ Right button click
        Me.PopupMenu mnuPop
    End If
End Sub

Private Sub LeftButtonDlbClick()
    tmp = Me.WindowState
    i = ShowWindow(Me.hwnd, SW_SHOW)
    If isDownloading = False Then Me.Show
    Me.WindowState = vbNormal
    DoEvents
    If isDownloading = False Then Me.SetFocus
    If Val(tmp) <> vbNormal Then
        Call ReleaseCapture
        lngReturnValue = SendMessage(Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
    End If
    End Sub

Private Sub CreateTray()
    TrayI.cbSize = Len(TrayI)
    'Set the window's handle (this will be used to hook the specified window)
    TrayI.hwnd = Me.hwnd
    'Application-defined identifier of the taskbar icon
    TrayI.uid = 1&
    'Set the flags
    TrayI.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
    'Set the callback message
    TrayI.ucallbackMessage = WM_LBUTTONDOWN
    'Set the picture (must be an icon!)
    TrayI.hIcon = Me.Icon
    'Set the tooltiptext
    TrayI.szTip = "HPB Gaming Console" & Chr$(0)
    'Create the icon
    Shell_NotifyIcon NIM_ADD, TrayI
   
    isTray = True
    Me.Hide
End Sub

Private Sub ModifyTray(ic As Long)
    'Set the picture (must be an icon!)
    TrayI.hIcon = ic
    'Modify the icon
    Shell_NotifyIcon NIM_MODIFY, TrayI
End Sub

Private Sub removeTray()
    'remove the icon
    TrayI.cbSize = Len(TrayI)
    TrayI.hwnd = Me.hwnd
    TrayI.uid = 1&
    Shell_NotifyIcon NIM_DELETE, TrayI
    isTray = False
End Sub
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 8109900
ops.. :)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month8 days, 15 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question