Page 1 of 1

Strange tab behaviour when madExcept dialog showing

PostPosted: Thu Mar 05, 2020 2:33 am
by zunzster
We had a strange report about funny chevron characters turning up in our edit controls rather than tabbing to the next control but it only happened intermittently.

We eventually tracked it down to only happening when there is a madExcept exception dialog showing which hasn't been actioned yet i.e. continue, restart, close etc. not chosen.
I'd always assumed those madExcept dialogs were modal but they aren't which makes sense since they are running on a different thread and message loop.
If I click to move the keyboard focus back to one of our controls and press tab or shift tab, I get a chevron character (how we indicate tab in strings) rather than tabbing to the next or prior control.
If I close the madExcept dialog by selecting continue, pressing tab and shift tab now work again as normal.

We use our own edit controls rather than stock Delphi TEdits and I thought it might be something we are doing, so I built a simple project with a pair of TEdits and a button which generates an Access Violation.
When the madExcept dialog is showing and I press Tab, rather than moving between the edits, I get a windows beep. So again, the control is getting a TAB keypress it doesn't expect .

I wondered if the madExcept dialog was putting in place some kind of message filter and changing the handling of WM_GETDLGCODE messages but I can't see anything so I'm at a bit of a loss.

Any ideas where else to look in the madExcept dialog code to avoid this?

Re: Strange tab behaviour when madExcept dialog showing

PostPosted: Mon Mar 09, 2020 2:03 pm
by madshi
Hmmmm... That chevron character and Windows beep thing sounds pretty weird. You don't have set "HandleMessagesInMainThread := false", have you?

Which Delphi version are we talking about?

Re: Strange tab behaviour when madExcept dialog showing

PostPosted: Mon Mar 09, 2020 10:58 pm
by zunzster
Sorry, for the slow reply. I wasn't notified of your reply which is probably my fault for not checking some button.

HandleMessagesInMainThread is True as that seems to be the default. It's Delphi 10.1 Berlin.

Re: Strange tab behaviour when madExcept dialog showing

PostPosted: Tue Mar 10, 2020 7:38 pm
by madshi
Should be fixed in this build:

http://madshi.net/madCollectionUpdate.exe

Basically madExcept replaced the main thread message loop and didn't have special handling for key messages. So I've now copied the VCL key message special handling. Hopefully doing that doesn't break anything...

Re: Strange tab behaviour when madExcept dialog showing

PostPosted: Thu Mar 12, 2020 5:24 am
by zunzster
Awesome. Did you do the change in madExcept 4.x or 5.x?
I haven't switched to 5.0 yet - it's on my todo list, but I could if needs be.

Re: Strange tab behaviour when madExcept dialog showing

PostPosted: Thu Mar 12, 2020 9:16 am
by madshi
madExcept 5, of course... :D

Re: Strange tab behaviour when madExcept dialog showing

PostPosted: Sat Mar 14, 2020 3:18 am
by zunzster
Upgraded to 5.0 and my issue is indeed fixed. I'll let you know if any regressions emerge but I'm pretty optimistic looking at the nature of the change.
Thanks a lot for your prompt attention to this, as always, Matthias.

Re: Strange tab behaviour when madExcept dialog showing

PostPosted: Sat Mar 14, 2020 8:29 am
by madshi
Happy to hear that!