Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to determine what application are iconified on the taskbar.

API Functions

How to determine what application are iconified on the taskbar.

by  Mike Gagnon  Posted    (Edited  )
Rather than listing all the processes running, it migh be easier just to list the ones that are running iconified on the taskbar.

Code:
#Define GW_HWNDNEXT         2
#Define GW_CHILD            5
#Define GWL_STYLE 			-16
#Define WS_VISIBLE 			0x10000000
#Define WS_POPUP   			0x80000000

Declare Long GetWindow In WIN32API Long HWnd, Long uCmd
Declare Long GetWindowText In WIN32API Long HWnd, String @lpString, Long nMaxCount
Declare Integer GetDesktopWindow In Win32API
Declare Long GetWindowLong In WIN32API Long HWnd, Long nIndex
DECLARE INTEGER IsIconic IN user32 INTEGER hWnd 
Create Cursor crsWindows ( ;
	hwnd I, WindTitle C(50),isIconic L)

lhWnd = GetDesktopWindow()
lhWnd = GetWindow(lhWnd, GW_CHILD)
Do While lhWnd > 0
	m.WindTitle = GetTitle(lhWnd)
	If Not Empty(m.WindTitle)
		m.hwnd 	= lhWnd
		m.Style = GetWindowLong(lhWnd, GWL_STYLE)
		m.hex 	= Transform(m.Style, "@0")
        m.isiconic = IIF(IsIconic(lhWnd)=0,.f.,.t.)
		If  Bitand(m.Style, WS_VISIBLE) > 0 ;
				AND Bitand(m.Style, WS_POPUP) = 0 
			Insert Into crsWindows From Memvar
		Endif
	Endif
	lhWnd = GetWindow(lhWnd, GW_HWNDNEXT )
Enddo
SELECT crsWindows 
LOCATE 
Browse Nowait
Return

Function GetTitle(lhWnd)
Local lcTitle
lcTitle = Space(512)
lnTitle = GetWindowText(lhWnd , @lcTitle, 256)
If lnTitle > 0
	lcTitle = Left(lcTitle, lnTitle )
Else
	lcTitle = ""
Endif
Return lcTitle
[sup]P.S.: Part of this code is credited to Sergey Berezniker[/sup]

Mike Gagnon
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top