VFP如何遍历所有窗口
请教各位大侠,VFP如何实现遍历所有窗口?
网上找到一段代码,网址如下:
http://hi.baidu.com/myvfp/item/29287724ee028f122b0f1c5e
但其中有一句运行出错(EnumChildWindows(0,AdrCode,0),不知何因?
或者各位大侠有没有其它方法实现,望赐教.
[解决办法]
*-- VFP Code
#Define GW_HWNDNEXT 2
Declare Integer GetActiveWindow In user32
Declare Integer GetWindow In win32api Integer HWnd, Integer wFlag
Declare Integer GetWindowText In win32api Integer hand, String @ctitle, Integer ntitle
Declare Integer SetForegroundWindow In Win32api Integer
hCurrent=GetActiveWindow() &&从当前活动窗口开始
lnhCurrent=hCurrent
SetForegroundWindow(_Screen.HWnd) &&或Thisform.HWnd
*SetForegroundWindow(hCurrent)&& vfp8 以下没有 HWnd
lcWinLists=""
Create Cursor t1 (WindowHWnd I,WindowTitle C(254))
Do While hCurrent>0
lcWinTitle=Space(255)
lnlength=GetWindowText(hCurrent,@lcWinTitle,Len(lcWinTitle))
lcWinTitle=Iif(lnlength>0,Strtran(Trim(lcWinTitle),Chr(0),""),"")
Insert Into t1 Values (hCurrent,lcWinTitle)
hCurrent=GetWindow(hCurrent,GW_HWNDNEXT) &&得到下一个窗口句柄
Enddo
SetForegroundWindow(lnhCurrent)
Select t1
Locate
Browse
Clear Dlls