遍歷視窗所有子窗體控制代碼,參考如下:PrivateTypeWndClassInfo"自定義的視窗類資料結構lHandleAsLong"返回的窗體控制代碼pSANameAsLongpSACaptionAsLongEndType"(程式段,使用時應放入相應的Sub/Function中)DimtClsInfoAsWndClassInfoDimbClsName()AsByte,bClsCaption()AsBytebClsName="要查的類名""類名bClsCaption="要查的標題名""標題名WithtClsInfo.lHandle=0&CallCopyMemory(.pSAName,ByValVarPtrArray(bClsName),4)CallCopyMemory(.pSACaption,ByValVarPtrArray(bClsCaption),4)EndWithCallEnumChildWindows(hwnd,AddressOfEnumChildProc,VarPtr(tClsInfo))PrivateFunctionEnumChildProc(ByValhwndAsLong,ByVallParamAsLong)AsBooleanDimtClsInfoAsWndClassInfoDimsTarNameAsString,sTarCaptionAsString"待查的目標類名及標題名DimbBuffer1()AsByte,bBuffer2()AsByte"陣列,按位元組存放字串,用來克服VBBSTR跨函式呼叫的種種問題DimsBuffer1AsString,sBuffer2AsString"當前的類名及標題名CallCopyMemory(tClsInfo,ByVallParam,Len(tClsInfo))sBuffer1=String(64,Chr$(0))sBuffer2=String(64,Chr$(0))sBuffer1=Left$(sBuffer1,GetClassName(hwnd,sBuffer1,63))sBuffer2=Left$(sBuffer2,GetWindowText(hwnd,sBuffer2,63))CallCopyMemory(ByValVarPtrArray(bBuffer1),tClsInfo.pSAName,4)CallCopyMemory(ByValVarPtrArray(bBuffer2),tClsInfo.pSACaption,4)sTarName=bBuffer1sTarCaption=bBuffer2CallCopyMemory(ByValVarPtrArray(bBuffer1),0&,4)CallCopyMemory(ByValVarPtrArray(bBuffer2),0&,4)IfsTarCaption=""AndsBuffer1=sTarName_OrsBuffer1=sTarNameAndsBuffer2=sTarCaptionThentClsInfo.lHandle=hwndCallCopyMemory(ByVallParam,tClsInfo,Len(tClsInfo))EnumChildProc=FalseElseEnumChildProc=TrueEndIfEndFunction
遍歷視窗所有子窗體控制代碼,參考如下:PrivateTypeWndClassInfo"自定義的視窗類資料結構lHandleAsLong"返回的窗體控制代碼pSANameAsLongpSACaptionAsLongEndType"(程式段,使用時應放入相應的Sub/Function中)DimtClsInfoAsWndClassInfoDimbClsName()AsByte,bClsCaption()AsBytebClsName="要查的類名""類名bClsCaption="要查的標題名""標題名WithtClsInfo.lHandle=0&CallCopyMemory(.pSAName,ByValVarPtrArray(bClsName),4)CallCopyMemory(.pSACaption,ByValVarPtrArray(bClsCaption),4)EndWithCallEnumChildWindows(hwnd,AddressOfEnumChildProc,VarPtr(tClsInfo))PrivateFunctionEnumChildProc(ByValhwndAsLong,ByVallParamAsLong)AsBooleanDimtClsInfoAsWndClassInfoDimsTarNameAsString,sTarCaptionAsString"待查的目標類名及標題名DimbBuffer1()AsByte,bBuffer2()AsByte"陣列,按位元組存放字串,用來克服VBBSTR跨函式呼叫的種種問題DimsBuffer1AsString,sBuffer2AsString"當前的類名及標題名CallCopyMemory(tClsInfo,ByVallParam,Len(tClsInfo))sBuffer1=String(64,Chr$(0))sBuffer2=String(64,Chr$(0))sBuffer1=Left$(sBuffer1,GetClassName(hwnd,sBuffer1,63))sBuffer2=Left$(sBuffer2,GetWindowText(hwnd,sBuffer2,63))CallCopyMemory(ByValVarPtrArray(bBuffer1),tClsInfo.pSAName,4)CallCopyMemory(ByValVarPtrArray(bBuffer2),tClsInfo.pSACaption,4)sTarName=bBuffer1sTarCaption=bBuffer2CallCopyMemory(ByValVarPtrArray(bBuffer1),0&,4)CallCopyMemory(ByValVarPtrArray(bBuffer2),0&,4)IfsTarCaption=""AndsBuffer1=sTarName_OrsBuffer1=sTarNameAndsBuffer2=sTarCaptionThentClsInfo.lHandle=hwndCallCopyMemory(ByVallParam,tClsInfo,Len(tClsInfo))EnumChildProc=FalseElseEnumChildProc=TrueEndIfEndFunction