FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

"Windows hung" issue - assistance requested

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Tue Oct 25, 2005 12:29 am    Post subject: "Windows hung" issue - assistance requested Reply with quote

As noted in the bugs section of DFL, Windows may slip your DFL program into an infinite loop when doing certain things with nested controls (e.g. TabControl's TabPage`s). Several times I have attempted to fix this, but each time I do, the solution branches out all over the place and becomes exceedingly difficult to fix. So, I'm going to explain the problem as best as I can from what I understand of it. Hopefully we can come up with a better solution.

When a user presses TAB or some Alt+X mnemonic, the default dialog handling in Windows has to loop through most of the controls on the window to figure out for what control or menu it is intended.

While looping, Windows keeps a variable to store the window handle for the control it started on, because it needs to start where the user is focused, and that variable is used to check when to stop looping if it cannot find the next control that fits the criteria. For example, if you have a few labels and a text box on your form and you press TAB while focused in the text box, Windows stores the handle to the text box, starts looping across those other labels until it comes back to the text box's handle and stops there since it did not find another control to TAB to (since labels do not have tab stops. i.e. do not have the window style WS_TABSTOP).

If one of those controls is disabled, invisible or does not contain the extended window style WS_EX_CONTROLPARENT, Windows will not loop over its children and will instead go to the next sibling.

But say you were focused on a control nested on a control that does not have WS_EX_CONTROLPARENT? Windows will get stuck in an infinite loop trying to find that starting point, since it is skipping over the one without WS_EX_CONTROLPARENT, the one the focused control is nested on; hence it cannot find the control it started on.

I have added WS_EX_CONTROLPARENT to all DFL controls that can nest child controls, yet the infinite loop still happens. The solution I have tried was to not let Windows handle the events where the infinite loop can occur, but to write my own code to do it, but there are just too many cases to cover.

Parts of Windows API that may be involved:
GetNextDlgTabItem() - Probably is one function that slips into this loop.
WM_NEXTDLGCTL - Probably calls GetNextDlgTabItem().
WM_GETDLGCODE - Sent to each control while looping.
WS_EX_CONTROLPARENT - Allows the user to navigate among the child windows of the window by using the TAB key.
WS_TABSTOP - Specifies a control that can receive the keyboard focus when the user presses the TAB key. Pressing the TAB key changes the keyboard focus to the next control with the WS_TABSTOP style.
WM_SYSCHAR - Sent when the user presses an Alt+X mnemonic.
WM_KEYDOWN - Sent when the user presses TAB.
DS_CONTROL - Creates a dialog box that works well as a child window of another dialog box, much like a page in a property sheet. This style allows the user to tab among the control windows of a child dialog box, use its accelerator keys, and so on. Probably only pertains to dialogs created with CreateDialog*() and DialogBox*(), neither of which DFL use.

This is one problem that I just can't seem to solve, so if anyone can provide some help, it would be greatly appreciated!

For an example of this bug, run the tabs.d example provided with DFL, click on the 2nd tab and press Alt+X (or any mnemonic not handled).

You can recompile DFL with -debug=SHOW_MESSAGE_INFO to see each window message printed to the console as they are received. It can be added to makelib.bat on the line "set dfl_flags=".

If you need help figuring out how DFL handles things, you are welcome to ask your questions here. Or let me know if there's anything else I can provide.

Thanks!
- Chris
Back to top
View user's profile Send private message
un_guru



Joined: 14 Sep 2005
Posts: 32

PostPosted: Sat Nov 26, 2005 8:33 am    Post subject: Reply with quote

I hava a mdi application with two forms as mdi childs. Every thing goes well unless I click buttons. Menemonics are ok, clicking other controls it's also ok, but I got Windows hung errors clicking buttons(the same button executes fine when using menmonics ...)

well, that's all I can help Rolling Eyes
Back to top
View user's profile Send private message
sanotto



Joined: 28 Nov 2005
Posts: 1

PostPosted: Mon Nov 28, 2005 2:25 pm    Post subject: Reply with quote

Hi... wen i've found DFL i fell in love almost inmediately with it.. until i got stuck with this nasty bug....
I'm not a experienced WINAPI32 programmer so ... i can not help but i want to know ... have you made any progress ?
Because i like dfl and this bug is a real show stopper...
Back to top
View user's profile Send private message
un_guru



Joined: 14 Sep 2005
Posts: 32

PostPosted: Tue Nov 29, 2005 3:24 am    Post subject: Reply with quote

http://support.microsoft.com/default.aspx?scid=kb?3Ben-us?3B149501

I can't tell if it's the same problem or not, but I hope this can help.
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Tue Dec 06, 2005 11:26 pm    Post subject: Reply with quote

un_guru wrote:
I hava a mdi application with two forms as mdi childs. Every thing goes well unless I click buttons.

Ah, I wasn't aware of this instance.

sanotto wrote:
Hi... wen i've found DFL i fell in love almost inmediately with it.. until i got stuck with this nasty bug....
I'm not a experienced WINAPI32 programmer so ... i can not help but i want to know ... have you made any progress ?
Because i like dfl and this bug is a real show stopper...
Sorry, I haven't made much progress on this. I've already spent many hours trying to track it down without much luck.

un_guru wrote:
http://support.microsoft.com/default.aspx?scid=kb?3Ben-us?3B149501

I can't tell if it's the same problem or not, but I hope this can help.
Maybe; I've been to many similar sites, but still I cannot resolve it. Here are a few more sites that might be relevant,
http://lists.wxwidgets.org/archive/wx-dev/msg34515.html
http://www.codeguru.com/forum/showthread.php?t=347870
http://www.extremetech.com/article2/0,1697,1168910,00.asp
http://www.powerbasic.com/support/forums/Forum4/HTML/005904.html
http://groups.yahoo.com/group/wtl/message/5137?viscount=100

- Chris
Back to top
View user's profile Send private message
rhosking



Joined: 21 Aug 2006
Posts: 14
Location: UK

PostPosted: Mon Aug 21, 2006 7:05 am    Post subject: Reply with quote

Did you ever solve this? I cannot seem to reproduce this on WinXP (home) SP2.

Compiled tabs.d...

dfl tabs.d

Executed it, clicked the second tab and did ALT+X. Nothing happens (as expected as there are no controls) but the app does not appear to hang for me. I can click another tab and the message dialog popups up and once Ok'd I can carry on navigating through the tabs.

PS: This (DFL) is excellent though Very Happy
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Mon Aug 21, 2006 10:12 pm    Post subject: Reply with quote

rhosking wrote:
Did you ever solve this? I cannot seem to reproduce this on WinXP (home) SP2.

No, not solved. It still happens to me with the tabs example (try 3rd tab). I spent way too much time trying to fix this problem and nothing ever seemed to fix it; the current workaround helps in many cases though (enabled by default).

Quote:
PS: This (DFL) is excellent though Very Happy
Thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group