My App "Gets Stucked"

When some app stucks and I try to restore mine(which s'posed to enumerate windows on restore), mine stucks too.

How to avoind this?
(It has something to do with those rings, right?)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Has nothing to do with "rings". Does your app work fine if you remove this windows enumeration code? If yes: Show us your windows enumeration code...

Regards, Madshi.
duke_nAuthor Commented:
yes. here it is

EnumWindows( @EnumWindowsProc, integer( TaskBarWindowsList ));

//the function itself
Function EnumWindowsProc (Wnd: HWND; lb: TListbox): BOOL; stdcall;
 caption: Array [0..128] of Char;
 Result := True;
 if { skip invisible windows }
    IsWindowVisible(Wnd) and
    { only process truly top-level windows. GetWindowLong must be used, not
GetParent }
    ((GetWindowLong(Wnd, GWL_HWNDPARENT) = 0) or
     (HWND(GetWindowLong(Wnd, GWL_HWNDPARENT)) = GetDesktopWindow)) and
    { skip WS_EX_TOOLWINDOW windows }
    ((GetWindowLong(Wnd, GWL_EXSTYLE) and WS_EX_TOOLWINDOW) = 0)
 then begin
   SendMessage( Wnd, WM_GETTEXT, Sizeof( caption ), integer(@caption));
   lb.Items.AddObject( caption, TObject( Wnd ));

duke_nAuthor Commented:
Oh, and by the way, if this code is still active and some app stucks and hangs mine,              

when I close the stuck app then mine "Unfreezes", enumerates normally and continues working as it should
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

The problem is that when you call SendMessage(Window, WM_GETTEXT) you are waiting until the other application answers your request. If the other application stucks, you don't get an answer and stuck, too. So leave this WM_GETTEXT away, or use SendMessageTimeout or put it on a thread.

Regards, Madshi.
Does the API GetWindowText work? It causes WM_GETTEXT to be sent but might do it safely.

Cheers - Walter McKie

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
duke_nAuthor Commented:
GetWindowText works just fine.
gracias, muchachos
Good news, I wonder what this API does that is different.

Well, probably it uses SendMessageTimeout instead of SendMessage...   :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.