Results 1 to 4 of 4

Thread: Please read this, and see if you can help me, has to do with System Tray & Stuff.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 1999
    Posts
    87

    Post

    Is there a way to "make my own TrayWindow" ?

    I mean, how do I make so that instead of programs trying to create a "Shell Notify Icon" in Explorer's TrayWindow, It create the "Shell Notify Icon" in MY program, my own system tray.

    I really, really, reeeealy want help with this.

  2. #2
    Hyperactive Member
    Join Date
    Sep 1999
    Posts
    305

    Post

    I wonder if maybe you could use a picture box, and put your icons in there as you need to. I wouldn't know how to get the other stuff into it, like the icons that go to the real tray, but your could put your own icons in the tray pretty easily.

  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Try somthing like this. Create a menu (call it mnuHidden,uncheck the Visible checkbox) and add two items to that menu (mnuShow and mnuExit), put a Picturebox on the form and set it's Visible property to False:

    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 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
        Shell_NotifyIcon NIM_ADD, tTrayIcon
    End Sub
    
    Private Sub Form_Resize()
        If WindowState = vbMinimized Then
            Hide
        End If
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        Shell_NotifyIcon NIM_DELETE, tTrayIcon
    End Sub
    
    Private Sub mnuExit_Click()
        Unload Me
    End Sub
    
    Private Sub mnuShow_Click()
        Show
    End Sub
    
    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
            Me.PopupMenu mnuHidden
        End Select
    End Sub
    ------------------

    Serge

    Senior Programmer Analyst
    [email protected]
    [email protected]
    ICQ#: 51055819

    [This message has been edited by Serge (edited 02-17-2000).]

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 1999
    Posts
    87

    Post

    Doesn't this code create a Tray Icon for my application ?

    Hmmm, what I really meant was, I want the OTHER programs to create it's menu in MY PROGRAM instead of in the REAL TRAY...


    If you can help me, please do so.

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