HOW TO DETECT STATUS OFF ICON IN TASKBAR IN VB6

BIAPRO
BIAPRO used Ask the Experts™
on
I print a form while a PDF creater is my active printer.  The (third party) program shows at right in taskbar while creating, when
done it disappears.   When done and not before I send the created PDF to the faxprinter.
Now the user must look at taskbar before pressing cmdFaxIT  to see its ready.
Can i decect in  VB6 that this Icon is not active anymore on Tasbar,  then I can send automaticly instead of pressing cmdFaxIt
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Brook BraswellApplication Development Manager

Commented:
Here is a start on using the task bar

http://support.microsoft.com/kb/176085


Brook BraswellApplication Development Manager

Commented:
A better option is that you should know where the file is being created...
Then watch for the file and force the cmdFaxIt when the file is there.
I am doing a similar function - sending an email for the user by creating a PDF from crystal report then emailing the generated PDF.

The user does nothing but click one send button and I handle the rest.

Author

Commented:
Hi brook1966, the page does not inform on checking the status on a icon, as far as i understand, only creating icons on taskbar
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Application Development Manager
Commented:
Here is some code to Detect what icons are in the system tray

Option Explicit
   
' Systemtray information.
   
Private Const PROCESS_QUERY_INFORMATION     As Long = 1024
Private Const PROCESS_VM_READ               As Long = &H10
   
Private Const MEM_COMMIT                    As Long = &H1000
Private Const MEM_RELEASE                   As Long = &H8000
Private Const PAGE_READONLY                 As Long = &H2
   
Private Const WM_USER                       As Long = &H400
Private Const TB_BUTTONCOUNT                As Long = (WM_USER + 24)
Private Const TB_GETBUTTON                  As Long = (WM_USER + 23)
   
Private Const TBSTATE_HIDDEN                As Long = &H8
   
Private Type TrayMore
  SyshWnd       As Long
  SysIconId     As Long
End Type
   
Private Type TBBUTTON
  iBitmap      As Long
  idCommand    As Long
  fsState      As Byte
  fsStyle      As Byte
  bReserved1   As Byte
  bReserved2   As Byte
  dwData       As Long
  iString      As Long
End Type
   
Private Declare Function FindWindowW Lib "user32" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
Private Declare Function FindWindowExW Lib "user32" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As Long, ByVal lpsz2 As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function VirtualAllocEx Lib "kernel32" (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Private Declare Function VirtualFreeEx Lib "kernel32" (ByVal hProcess As Long, lpAddress As Any, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, ByVal lpBuffer As Long, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function GetModuleFileNameExW Lib "Psapi.dll" (ByVal hProcess As Long, ByVal hModule As Long, ByVal lpFileName As Long, ByVal nSize As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
   
Public Function GetProcessNameFromhWnd(ByVal dwhWnd As Long) As String
   
  ' Returns process name from hwnd.
    
  Dim Buffer(1024 - 1)  As Byte
  Dim hProcess          As Long
  Dim ThreadId          As Long
  Dim Pid               As Long
  Dim cbLen             As Long
    
  ThreadId = GetWindowThreadProcessId(dwhWnd, Pid)
  hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, Pid)
  cbLen = GetModuleFileNameExW(hProcess, 0, VarPtr(Buffer(0)), UBound(Buffer))
  GetProcessNameFromhWnd = Left$(Buffer, cbLen)
  CloseHandle hProcess
  Erase Buffer
    
End Function
   
Public Sub GetTrayWindowInfo()
   
  Dim Tray            As TBBUTTON
  Dim TrayM           As TrayMore
  Dim ThreadId        As Long
  Dim hProcess        As Long
  Dim AddrPtr         As Long
  Dim Pid             As Long
  Dim cb              As Long
  Dim cbRead          As Long
  Dim TrayCount       As Long
  Dim hWindow         As Long
    
  ' * Get the tray window handle. ( Window XP).
  hWindow = FindWindowW(StrPtr("Shell_TrayWnd"), 0)
  hWindow = FindWindowExW(hWindow, 0, StrPtr("TrayNotifyWnd"), 0)
  hWindow = FindWindowExW(hWindow, 0, StrPtr("SysPager"), 0)
  hWindow = FindWindowExW(hWindow, 0, StrPtr("ToolbarWindow32"), 0)
    
  ' * Get the count of buttons in tray window.
  TrayCount = SendMessage(hWindow, TB_BUTTONCOUNT, 0, 0)
    
  ' Allocate memory
  ThreadId = GetWindowThreadProcessId(hWindow, Pid)
  hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, Pid)
  AddrPtr = VirtualAllocEx(hProcess, 0, LenB(Tray), MEM_COMMIT, PAGE_READONLY)
    
  ' Read information into TBUTTON struct
  For cb = 0 To TrayCount - 1
    
    SendMessage hWindow, TB_GETBUTTON, cb, AddrPtr
    ReadProcessMemory hProcess, AddrPtr, VarPtr(Tray), LenB(Tray), cbRead
    ReadProcessMemory hProcess, ByVal Tray.dwData, VarPtr(TrayM), LenB(TrayM), cbRead
      
    ' * Show only the visible buttons(remove this line to show all)
    If Tray.fsState <> TBSTATE_HIDDEN Then
      Debug.Print GetProcessNameFromhWnd(TrayM.SyshWnd)
   End If
      
  Next cb
    
  ' * Cleanup
  VirtualFreeEx hProcess, AddrPtr, 0, MEM_RELEASE
  CloseHandle hProcess
       
End Sub

Open in new window

Brook BraswellApplication Development Manager

Commented:
I believe that with both of these, you could look at the icons, find the one you are interested in.  Then you can respond on it.


Author

Commented:
Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial