Results 1 to 5 of 5

Thread: Application in SystemTray?

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    37

    Post

    How can I make my application go in the system tray when the 'minimize button' is clicked?

    What's the code to make it go in the System Tray?

  2. #2
    Registered User Lior's Avatar
    Join Date
    Jan 2000
    Posts
    307

    Post

    Hey man...
    In order to put your program in Win98's system tray, you need to use the Windows API.
    Here is a piece of code that should help you:

    Option Explicit
    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 WM_MOUSEMOVE = &H200
    Private Const NIF_MESSAGE = &H1
    Private Const NIF_ICON = &H2
    Private Const NIF_TIP = &H4

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

    Dim t As NOTIFYICONDATA

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

    Timer1.Enabled = False

    t.cbSize = Len(t)
    t.hWnd = Picture1.hWnd
    t.uId = 1&

    Shell_NotifyIcon NIM_DELETE, t

    End Sub

    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    If Hex(X) = "1E3C" Then
    Me.PopupMenu menu1
    End If

    End Sub

    Private Sub Timer1_Timer()
    Static i As Long, img As Long
    t.cbSize = Len(t)
    t.hWnd = Picture1.hWnd
    t.uId = 1&
    t.uFlags = NIF_ICON
    t.hIcon = Picture1.Picture
    Shell_NotifyIcon NIM_MODIFY, t
    Timer1.Enabled = True
    i = i + 1
    If i = 2 Then i = 0
    End Sub

    Private Sub Form_Load()

    t.cbSize = Len(t)
    t.hWnd = Picture1.hWnd
    t.uId = 1&
    t.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
    t.ucallbackMessage = WM_MOUSEMOVE
    t.hIcon = Picture1.Picture
    t.szTip = "System Tray" & Chr$(0)

    Shell_NotifyIcon NIM_ADD, t

    Timer1.Enabled = True

    Me.Hide

    App.TaskVisible = False

    End Sub



    ------------------
    ------
    God:
    ------
    Oh...those israeli programmers..!

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    37

    Post

    I copied and pasted the code into my project and drew the necessary controls but it still didn't work. Gave some error about "t" not being a defined type or something.

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    37

    Post

    Thank you,

    But why do you have a timer and a picture box in there?

    [This message has been edited by madd indian (edited 01-23-2000).]

  5. #5
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Leeds, UK
    Posts
    287

    Post

    I think that the picture box hold the image that will be displyed in the System Tray?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width