No announcement yet.

Trapping System Tray Events

  • Filter
  • Time
  • Show
Clear All
new posts

  • Trapping System Tray Events

    I'm making a security program that will only allow people to run
    selected applications. The downfall that I'm running into is
    that some applications such as "outlook" send icons to the
    systray. I'm wanting to know how I could get those messages
    within my program. The entire taskbar isn't going to be
    loaded at all. Any ideas?

    [email protected]

  • #2
    Gregory -
    I think, that you talk about windows with WS_EX_TOOLWINDOW style ("invisible" for TaskBar and in Alt-Tab's list).
    These windows very well visible in EnumWindows.
    I cut a fragment from one my utility to demonstrate, what I mean.
       #Compile Exe
       #Register None
       #Dim All
       #Include "Win32Api.Inc"
       %ID_LISTBOX = 101
       Global hDlg As Long
       Function EnumWindowsCallBack(ByVal hwnd As Long, _
           ByVal lParam As Long) As Long
           Dim lExStyle    As Long
           Dim Caption     As Asciiz * %MAX_PATH
           Function = %True
           If IsWindowVisible(hwnd) = 0 Then Exit Function
           lExStyle = GetWindowLong(hwnd, %GWL_EXSTYLE)
           If (lExStyle And %WS_EX_TOOLWINDOW) = %WS_EX_TOOLWINDOW Then
               GetWindowText hwnd, Caption, SizeOf(Caption)
               ListBox Add hDlg, %ID_LISTBOX, "hWnd = &H" + Hex$(hwnd, 8) + " " + Caption
           End If
        End Function
        CallBack Function DlgProc
           Select Case CbMsg
              Case %WM_INITDIALOG: SetTimer CbHndl, 1, 1000, ByVal 0&
              Case %WM_TIMER
                ListBox Reset CbHndl, %ID_LISTBOX
                EnumWindows CodePtr(EnumWindowsCallBack), GetDlgItem(CbHndl, %ID_LISTBOX)
              Case %WM_DESTROY: KillTimer CbHndl, 1
           End Select
        End Function
        Function PbMain
           Dialog New 0, "Alt-Tab", , , 400, 170, %WS_CAPTION Or %WS_SYSMENU, _
              %WS_EX_TOPMOST Or %WS_EX_TOOLWINDOW To hDlg
           Control Add ListBox, hDlg, %ID_LISTBOX, , 10, 10, 380, 150
           Dialog Show Modal hDlg, Call DlgProc
        End Function

    [This message has been edited by Semen Matusovski (edited July 22, 2000).]