Results 1 to 8 of 8

Thread: How do I add an animated ico into the systray?

  1. #1

    Thread Starter
    Addicted Member Daniel_Christie's Avatar
    Join Date
    Jan 2000
    Location
    USA
    Posts
    245
    How do I add an animated ico into the systray?

    I appreciate any time or effort spent on your replies,
    Daniel christie

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You have to do some subclassing, or download my traycontrol that is not ready yet. Subclassing is somwhat dangerous for your vb and crashes it for me about 30 times a day, so my traycontrol will take some time to be finnished.

    The icon can be animated by modifying a picture added to imagelistcontrol, extracting it and set it to the tray.

  3. #3
    Lively Member
    Join Date
    Nov 1999
    Posts
    98
    you don't have to subclass or use a activex control. all you have to do is add an icon to the system tray by using the code below and set a timer to change it for each frame you have in your animation. here's the code:

    In the declarations area:
    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 Const WM_RBUTTONUP = &H205
    Private Const WM_LBUTTONUP = &H202
    Private Const WM_LBUTTONDBLCLK = &H203
    Private tTrayIcon As NOTIFYICONDATA
    on a form put a control array of as many picture boxes as you have frames in your animation (let's say 5 here). in each picture box, IN ORDER, place the frames of the animation. so in Picture(0) would be frame 1 of the animation, in Picture(1) would be frame 2, etc.

    in the Form_load() sub:

    Code:
    Dim i as integer
    i = 0
    now in a timer put this code:

    Code:
    'play the animation and loop it when it is done
    'the animation has 5 frames, picture(0) up to picture(4)
    i = i + 1
    if i > 4 then i = 0
    
    With tTrayIcon
        .hIcon = Picture(i).Picture
        .hwnd = Picture(i).hwnd
        .szTip = Caption & Chr(0)
        .uCallbackMessage = WM_MOUSEMOVE
        .uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
        .uID = 1
        .cbSize = Len(tTrayIcon)
    End With
    'add the icon to the system tray
    Shell_NotifyIcon NIM_ADD, tTrayIcon
    now set the timer to however fast you want the animation to appear running.

    that should work. sorry if it doesn't. i haven't tested this yet. it's just an idea. and it may not be the most efficient way to do this but who knows? give it a shot. lemme know what turns out. take care.

    [Edited by funkheads on 03-31-2000 at 02:57 PM]

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    No, you have to subclass to get the event when you click on the icon, so that it makes a popupmenu. Damn, that was not the qwestion here, I was more into my own project when I answered in my last post. Sorry about that. And setting that picture to the icon property, I don't know if it works. But extracting it from an imagelistcontrol will give true icon.

  5. #5
    Lively Member
    Join Date
    Nov 1999
    Posts
    98
    i am afraid again i must prove you wrong. you do not have to subclass to get a popup menu to popup when clicked. here's the code:

    Code:
    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Select Case ScaleX(X, vbTwips, vbPixels)
        Case WM_RBUTTONUP
            frmMenu.PopupMenu mnuMain
        Case WM_LBUTTONUP
            Exit Sub
            'or whatever code you may need when the user left-clicks on the icon
        End Select
    End Sub
    [

    [Edited by funkheads on 04-01-2000 at 12:47 PM]

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Im still talking about the tray icon, not any picturebox.

  7. #7
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408
    Hmm I saw this a while ago without having to subclass (I think) or any other garbage and it is just like like funk heads said let me see if I can find that demo project. They set it up a little wierd so I changed it to fit my project so the first link is theres and the second link is mine so mix them and you should have what you are looking for.

    http://www.angelfire.com/yt/PITBULLCJR/tray.zip
    http://www.angelfire.com/yt/PITBULLCJR/SystemTray.zip

    Hope this helps!!
    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

  8. #8
    Lively Member
    Join Date
    Nov 1999
    Posts
    98
    kedaman -

    i am also talking about the tray icon. in order to get the popup menu to popup when you click on the system tray icon using my code you need to bind the click event to the picturebox_mousemove function. do me a favor and put my code into a VB project and see if it works. i did and it works perfectly. so before you make anymore comments try it. thanks.

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