From: Dirk B. <db...@us...> - 2006-07-22 08:23:17
|
Update of /cvsroot/win32forth/win32forth/src/tools In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv27436/src/tools Added Files: DumpWindows.f Log Message: New "DumpWindow" tool added. It dump's all Top-Level-Windows to the console window. --- NEW FILE: DumpWindows.f --- \ File: DumpWindows.f \ Author: Dirk Busch \ Created: May 29th, 2003 - 11:37 - dbu \ Updated: Samstag, Juli 22 2006 - 10:15 - dbu \ \ This is an example of how to use a callback's in Win32Forth. \ It dump's all Top-Level-Windows to the console. anew -DumpWindows.f INTERNAL [UNDEFINED] zCount [if] : zCount ( a1 -- a2 len ) \ get length of zstring TRUE 2dup 0 scan nip - ; [then] : GetProcessId { hWnd -- ProcessID } \ *G Get ProcessId for given window. here hWnd call GetWindowThreadProcessId drop here @ ; : GetThreadId { hWnd -- ThreadID } \ *G Get ThreadId for given window. 0 hWnd call GetWindowThreadProcessId ; 2 CallBack: DumpWindowCallback { hWnd lParam \ buff$ -- int } \ *G The callback function for EnumWindows(). \ *P CallBack: Need's the NUMBER OF PARAMTERS passed to the funtion by \ ** Windows on TOS \ ** \ ** CallBack: Creates TWO definitions! The first has the name you specify, \ ** and the second has the same name, prefixed with a '&' meaning \ ** 'address of' This second definition is the one which returns the \ ** address of the callback, and must be passed to Windows. LMAXCOUNTED localalloc: buff$ cr hWnd h.8 space hWnd GetProcessId h.8 space hWnd GetThreadId h.8 space LMAXCOUNTED buff$ hWnd call GetClassName 0<> if buff$ zcount type then cr 27 spaces LMAXCOUNTED buff$ hWnd call GetWindowText 0<> if buff$ zcount type else ." <no title>" then true ; \ default return value : (.Windows) ( -- ) \ *G Dump all Top-Level-Windows to the console. 0 \ lParam is passed to the callback funtion by Windows &DumpWindowCallback \ get address of the callback function Call EnumWindows drop ; \ and use it EXTERNAL : .Windows ( -- ) \ *G Dump all Top-Level-Windows to the console. cr cr ." Top-Level-Windows:" cr ." hWnd ProcId ThreadId ClassName - WindowTitle" (.Windows) cr ; MODULE .Windows |