home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / QBAS / FINDAP.ZIP / FINDAPP.PAS < prev    next >
Pascal/Delphi Source File  |  1991-08-10  |  2KB  |  63 lines

  1. library WNDFIND;
  2.  
  3. {These are the units used}
  4. uses Strings, WinTypes;
  5.  
  6. {These are global variables to the DLL}
  7. var
  8.     VBhWnd:hWnd;
  9.    ThWnd:Integer;
  10.       Capt:Array[0..255] of Char;
  11.  
  12.  
  13. {These are the API functions used}
  14. procedure GetWindowText (Wnd:hWnd; Buff:PChar; BufSize:word); far;
  15.     External 'USER' index 36;
  16. procedure SendMessage (Wnd, Msg, wParam:word;lParam:PChar); far;
  17.     External 'USER' index 111;
  18. procedure EnumWindows (Func:TFarProc; lParam:PChar);far;
  19.     External 'USER' index 54;
  20.  
  21.  
  22. {This is the call-back function that is sent the hWnd of every window}
  23. function EnumFunc (hWnd:hWnd; Search:PChar):Bool;export;
  24.     Begin
  25.       {First retrieve the caption of the Window}
  26.           GetWindowText (hWnd, @Capt, 256);
  27.       {StrPos is identical to Instr. We cap both strings to be insensitive}
  28.        if StrPos (StrUpper (@Capt), Search) <> Nil then
  29.               Begin
  30.              {List1.AddLine Caption$}
  31.                  SendMessage (VBhWnd, LB_AddString, 0, @Capt);
  32.             {ThWnd = ThWnd + 1}
  33.                Inc (ThWnd);
  34.          end;
  35.              EnumFunc := TRUE;
  36.    End;
  37.  
  38. function FindCaptions (Wnd:hWnd; Search:PChar):Integer;export;
  39.     Begin
  40.        {Set the global variable so EnumFunc can find it}
  41.          VBhWnd := Wnd;
  42.       {Set counter to zero}
  43.       ThWnd := 0;
  44.       {Clear the list box}
  45.       SendMessage (Wnd, LB_ResetContent, 0, StrUpper(Search));
  46.       {Tell Windows to start sending hWnds to EnumFunc}
  47.       EnumWindows (@EnumFunc, Search);
  48.       {When all windows have been examined, return total to VB}
  49.       FindCaptions := ThWnd;
  50.    end;
  51.  
  52.  
  53.  
  54. Exports
  55.    EnumFunc,
  56.    {The resident keyword makes access from VB quicker}
  57.     FindCaptions resident;
  58.  
  59.  
  60. {No startup code but we need the empty routine anyway}
  61. Begin
  62. End.
  63.