Results 1 to 5 of 5

Thread: Minimising to systray

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 1999
    Posts
    13

    Post

    Hi All,

    I've not been for a while, but now come seeking help and knowing you are all so wonderful, hope you can help me (Yes I am creeping!!)

    I am in the middle of writing a fairly simple run-of-the-mill app to make my day easier, but When I minimize it, I want it to go into the Sys tray(The little thingy on the toolbar where the clock is - I think it's the systray anyway!). How can I do this? I'm sure it's been done before, but I can't find the code

    TIA

    Ell

  2. #2
    Junior Member
    Join Date
    Jan 1999
    Location
    Pierre, SD USA
    Posts
    23

    Post

    I think this article might give you some ideas:
    http://www.vb-world.net/tips/tip61.html

  3. #3
    New Member
    Join Date
    Nov 1999
    Location
    AuburnHills, Michigan, USA
    Posts
    6

    Post

    Check out the artical called: How to add an icon to the tray, on this site, which will add the icon to the taskbar tray. You will then need to hide your form and then transfer control to the little icon.

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    Like this:

    Add an Invisible Picturebox to your Form..
    Code:
    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 Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
    
    Private Const NIF_ICON = &H2
    Private Const NIF_MESSAGE = &H1
    Private Const NIF_TIP = &H4
    Private Const NIM_ADD = &H0
    Private Const NIM_DELETE = &H2
    Private Const WM_MOUSEMOVE = &H200
    
    Private tTrayIcon As NOTIFYICONDATA
    
    Private Sub Form_Load()
        With tTrayIcon
            .hIcon = Icon
            .hwnd = Picture1.hwnd
            .szTip = Caption & Chr(0)
            .uCallbackMessage = WM_MOUSEMOVE
            .uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
            .uID = 1
            .cbSize = Len(tTrayIcon)
        End With
    End Sub
    
    Private Sub Form_Resize()
        If WindowState = vbMinimized Then
            Hide
            Shell_NotifyIcon NIM_ADD, tTrayIcon
        End If
    End Sub
    
    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Right(Hex(X), 1) = "D" Then
            WindowState = vbNormal
            Show
            Shell_NotifyIcon NIM_DELETE, tTrayIcon
        End If
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    adyoung@win.bright.net


    [This message has been edited by Aaron Young (edited 11-10-1999).]

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 1999
    Posts
    13

    Post

    Thank you both very much, This should do the trick!!

    Ell

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