Results 1 to 3 of 3

Thread: problem with EnumWindows(); API

  1. #1
    Blah
    Guest

    problem with EnumWindows(); API

    I had been having problems with an old app of mine it wouldnt load or show anything and ive just recently picked it up to see why all of a sudden it stopped working.

    After alot of messing around it came down to EnumWindows() freezing the app which i also used on startup tht's why it froze without showing anything.

    This is my function......


    Function WindowList(wHnd: THandle; List: TStringList): Bool; StdCall;
    Var Buffer: Array[0..255] Of Char;
    Begin
    SendMessage(wHnd, WM_GETTEXT, 255, LongInt(@Buffer[0]));
    If (Buffer <> '') And IsWindow(wHnd) AND IsWindowVisible(wHnd) Then
    Begin
    List.AddObject(Buffer, TObject(wHnd));
    End;
    Result := True; //Continue enumerations till false is returned.
    End;

    And this is what freezes my app...


    Enumwindows(@WindowList, LParam(LstWindows.Items));

    Does anybody know what the problem is it used to work but then just started freezing up im suspecting windows is being gay but maybe my code is just tempermental.

  2. #2

    problem with EnumWindows(); API

    I don't see a problem with that code. I tried the following on Windows 98 and it worked fine:

    [pascal]function Callback(Window: HWND; List: TStringList): BOOL; stdcall;
    var
    Buffer: array[0..255] of Char;
    begin
    SendMessage(Window, WM_GETTEXT, 255, LongInt(@Buffer[0]));
    if (Buffer <> '') and IsWindow(Window) and IsWindowVisible(Window) then
    begin
    List.AddObject(Buffer, TObject(Window));
    end;

    Result := True;
    end;

    procedure TForm1.Button1Click(Sender: TObject);
    var
    List: TStringList;
    begin
    List := TStringList.Create;
    try
    EnumWindows(@Callback, Integer(List));
    ShowMessage('Finished');
    Memo1.Lines.Assign(List);
    finally
    List.Free;
    end;
    end;[/pascal]
    "All paid jobs absorb and degrade the mind."
    <br />-- Aristotle

  3. #3
    Anonymous
    Guest

    problem with EnumWindows(); API

    yeh all of a suddne my app is working again it must be certain windows to enumerate or soemthing tht it cant handle not sure how i could permanently fix this though.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •