serhio
serhio

Reputation: 28586

Detect why a Form "disappears"?

In a large old application I have to fix, I have two forms, like in the image (that is a Notepad example)

enter image description here

When I leave (with mouse cursor) my small(Y) form's area, that form will "disappear", some like I'd clicked on the big form and activated it.

But I didn't click on X, neither the X caption is active, however the small Y form goes backward and is not visible anymore.

How to track the problem?

Any of Resize, Activated, Deactivate, LostFocus, GotFocus, GiveFeedback, MdiChildActivate is not tracked on any of both forms when I leave the Y area...

Upvotes: 1

Views: 234

Answers (4)

serhio
serhio

Reputation: 28586

Making multiple tests I identified the problem: The Y Form were Deactivated by the X, because on the MouseMove event on X produced a Focus() on a specific control inside the (X) form...

Thanks to everybody for help!

(PS. So, I was wrong in the initial post about the Deactivate event)

Upvotes: 1

user541686
user541686

Reputation: 210455

It's a system-wide thing as I know; I think it's called active window tracking.

Might want to try disabling it.

Upvotes: 1

real_yggdrasil
real_yggdrasil

Reputation: 1263

You might set form 'Y' TopMost property to 'True' This way it never disappears behind 'X'. (provided the 'Topmost' property of 'X' is NOT true.

Upvotes: 0

robertpnl
robertpnl

Reputation: 193

Try to override OnVisibleChanged of form Y and set a breakpoint on this. During debugging reproduce the situation and check property Form.Visible on false and check than the Call Stack.

Upvotes: 1

Related Questions