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?)
LVL 1
duke_nAsked:
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.

MadshiCommented:
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.
0
duke_nAuthor Commented:
yes. here it is

//OnbuttonClick
TaskBarWindowsList.Clear;
EnumWindows( @EnumWindowsProc, integer( TaskBarWindowsList ));


//the function itself
Function EnumWindowsProc (Wnd: HWND; lb: TListbox): BOOL; stdcall;
var
 caption: Array [0..128] of Char;
begin
 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 ));
 end;

end;
0
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
0
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.

MadshiCommented:
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.
0
wmckieCommented:
Does the API GetWindowText work? It causes WM_GETTEXT to be sent but might do it safely.

Cheers - Walter McKie
0

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
0
wmckieCommented:
Good news, I wonder what this API does that is different.

Walter
0
MadshiCommented:
Well, probably it uses SendMessageTimeout instead of SendMessage...   :-)
0
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
Delphi

From novice to tech pro — start learning today.