'-------------------------------------------------------------------------------------------- ' This is "FindDialog.inc" ' It returns the number of dialog founds based on a filter (1st parameter), ' and fills a dialog information array passed as second parameter. '-------------------------------------------------------------------------------------------- DECLARE FUNCTION FindDialog(BYVAL filter AS STRING, BYREF dlgList() AS STRING) AS LONG '-------------------------------------------------------------------------------------------- ' Examples of use: ' LOCAL nbDlg as LONG ' ' ' Following returns dialogs based on all-or-part of a caption string ' nbDlg = FindDialog(BYVAL "CAP:Explorer", BYREF dlgList()) ' ' ' Following returns dialog information based on a dialog handle, ' ' in this case 'nbDlg' is either 0 (no dialog found) or 1 (dialog found) ' nbDlg = FindDialog(BYVAL "HND:12345", BYREF dlgList()) '-------------------------------------------------------------------------------------------- ' dlgList() will contain: ' dlgList(0) = "#12345:Full dialog caption", ' dlgList(1) = "#23456:Second full dialog caption", ' ... ' dlgList(nbDlg-1) = "#99999:Another dialog caption" '-------------------------------------------------------------------------------------------- '-------------------------------------------------------------------------------------------- TYPE WINDOWLIST hwnd AS DWORD PARENT AS LONG R AS RECT END TYPE '-------------------------------------------------------------------------------------------- '-------------------------------------------------------------------------------------------- GLOBAL fd_wList() AS WINDOWLIST GLOBAL fd_iCount, fd_iResult AS LONG '-------------------------------------------------------------------------------------------- '-------------------------------------------------------------------------------------------- MACRO fdM_AddToFoundDlg INCR foundDlg dlgList(foundDlg-1) = "#" + FORMAT$(fd_wList(i).hwnd) + ":" + TRIM$(szText) END MACRO '-------------------------------------------------------------------------------------------- '-------------------------------------------------------------------------------------------- FUNCTION FindDialog(BYVAL filter AS STRING, BYREF dlgList() AS STRING) AS LONG LOCAL szText AS ASCIIZ * %MAX_PATH LOCAL foundDlg AS LONG LOCAL i AS LONG REDIM fd_wList(5000) REDIM dlgList(5000) fd_iResult = EnumWindows(CODEPTR(ParentCallback), 0&) REDIM PRESERVE fd_wList(fd_iCount) REDIM PRESERVE dlgList(fd_iCount) FOR i = 0 TO UBOUND(fd_wList) fd_iResult = GetWindowText(fd_wList(i).hwnd, szText, SIZEOF(szText)) SELECT CASE LEFT$(UCASE$(filter),4) CASE "CAP:" ' "CAP:All-Or-Part-Of-Caption" IF INSTR(LCASE$(szText), "cmd.exe - " + LCASE$(EXE.NAME$)) = 0 _ AND INSTR(LCASE$(szText), LCASE$(MID$(filter,5))) > 0 THEN fdM_AddToFoundDlg END IF CASE "HND:" ' "HND:12345" IF VAL(MID$(filter,5)) = fd_wList(i).hwnd THEN fdM_AddToFoundDlg END IF END SELECT NEXT i REDIM PRESERVE dlgList(foundDlg-1) FUNCTION = foundDlg END FUNCTION '-------------------------------------------------------------------------------------------- '-------------------------------------------------------------------------------------------- FUNCTION ChildCallback (BYVAL hWndChild AS LONG, lRaram AS LONG) AS LONG INCR fd_iCount fd_wList(fd_iCount).hWnd = hWndChild FUNCTION = 1 END FUNCTION '-------------------------------------------------------------------------------------------- '-------------------------------------------------------------------------------------------- FUNCTION ParentCallback (BYVAL hWndChild AS LONG, lRaram AS LONG) AS LONG LOCAL szParentClass AS ASCIIZ * %Max_Path fd_iResult = GetClassName(hWndChild, szParentClass, SIZEOF(szParentClass)) INCR fd_iCount fd_wList(fd_iCount).PARENT = 1 fd_wList(fd_iCount).hWnd = hWndChild SELECT CASE szParentClass CASE "COMBOBOX", "COMBOBOXEX32", "SYSIPADDRESS32", "SYSLISTVIEW32", _ "SYSTABCONTROL32", "SYSDATATIMEPICK32" 'do nothing CASE ELSE IF IsWindowVisible(hWndChild) THEN fd_iResult = EnumChildWindows(hWndChild, CODEPTR(ChildCallback), 0&) END IF END SELECT FUNCTION = 1 END FUNCTION '--------------------------------------------------------------------------------------------