Relation: [ WinApi ] ID: [ 000400 ] I suggest that you do as follows. Please make shure that in the compiler options you select smart callbacks ON. Or use the compiler directive as I included it here.
function FWC(P: integer; C: String; I: integer): integer; function EnumChildProc(HWnd: integer; lParam: longint): Boolean; function Left(inString : String; numChars : Byte) : String;
implementation
var Counter : integer; Cnt : Integer; FWCWnd : integer; CMatch : array[0..254] of char;
function EnumChildProc(HWnd: Integer; lParam: longint): Boolean; export; { must be declared export } var ClsName : array[0..31] of char; ClsLen : Integer; begin GetClassName(HWnd, ClsName, 31); If strcomp(ClsName, CMatch) = 0 then Counter := Counter + 1; Result := Counter <> cnt; if not result then FWCWnd := HWnd; end;
function FWC(P: integer; C: string; I: integer): integer; begin FWCWnd := 0; strpcopy(CMatch, C); { convert from string to ASCIIZ } Cnt := I; EnumChildWindows(P, @EnumChildProc, 0); { no need for makeprocinstance! } FWC := FWCWnd; end;