Solved

system tray icon and configuration.

Posted on 2001-06-15
1
235 Views
Last Modified: 2010-05-18
I want to have a VB app. It should have the following functionalities:

1. It doesn't have a start form. But it should have a system tray icon sits on the system tray.(how to do the system tray?)

2. when right click on the system tray, it should have a configure option on it.

3. when click on the configure option, a configuration form pops up.

How do I do the above?

Thanks
0
Comment
Question by:chrislee8
[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
1 Comment
 
LVL 1

Accepted Solution

by:
ny971181 earned 30 total points
ID: 6196661
Option Explicit
Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal cmd As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Public Type NOTIFYICONDATA
    cbSize As Long
    hwnd As Long
    uID As Long
    uFlags As Long
    uCallbackMessage As Long
    hIcon As Long
    sTip 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 NIF_DOALL = NIF_MESSAGE Or NIF_ICON Or NIF_TIP
    Public Const SW_RESTORE = 9
    Public Const SW_MINIMIZE = 6
    Public Const WM_MOUSEMOVE = &H200
    Public Const WM_LBUTTONDBLCLK = &H203
    Public Const WM_RBUTTONUP = &H205

Dim Tic As NOTIFYICONDATA

Private Sub Form_Load()
    Dim rc As Long
    Tic.cbSize = Len(Tic)
    Tic.hwnd = Me.hwnd
    Tic.uID = vbNull
    Tic.uFlags = NIF_DOALL
    Tic.uCallbackMessage = WM_MOUSEMOVE
    Tic.hIcon = Me.Icon
    Tic.sTip = "SysTray Example By: -RiDiUM-" & vbNullChar
    rc = Shell_NotifyIcon(NIM_ADD, Tic)
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Dim msg As Long
        Dim sFilter As String
        msg = X / Screen.TwipsPerPixelX
        Select Case msg
            Case WM_RBUTTONUP
                PopupMenu mnuMain
            Case WM_LBUTTONDBLCLK
                Me.Show
        End Select
End Sub

Private Sub Form_Unload(Cancel As Integer)
Shell_NotifyIcon NIM_DELETE, Tic
End Sub

Private Sub mnuExit_Click()
Unload Me
End Sub

Private Sub mnuHide_Click()
Form1.Hide
mnuMain.Visible = True
End Sub

Private Sub mnuShow_Click()
Form1.Show
mnuMain.Visible = False
End Sub


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 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