Icemanind
Icemanind

Reputation: 48686

Dialog Box loses focus in Windows XP

I am having a strange problem. I have a C# .NET 2.0 application and a context menu. When you right click on the application, the context menu shows up and one of the items on the menu is Options. When you click options, I have an OptionsDialog form that shows up (using ShowDialog() method). The problem is, on Windows XP, the focus keeps going away. If I click on the options form, its gains focus for a second, but then loses it again! I have tried everything. On the Deactivate event, I call this.Focus() but that doesn't seem to make a difference. I also tried making the window topmost, but still doesn't work.

Another wierd thing is that this problem only seems to happen on XP. I tried it with Vista and Windows 7 and it works perfect. XP is doing something wierd though. Anyone have any thoughts on how to solve this?

Upvotes: 1

Views: 1127

Answers (2)

VVS
VVS

Reputation: 19604

If you find out which window has the focus afterwards, maybe it gives you a clue what's going on.

This little demo app from 1997 will help you: http://www.microsoft.com/msj/0397/Win32/Win320397.aspx

Upvotes: 0

Alain
Alain

Reputation: 27220

A person here seems to have the same problem: http://forums.devshed.com/c-programming-42/c-form-won-t-focus-on-control-535596.html

Is that anything like what's going wrong with you? If you have a default button or a control that is the first tabStop value that also happens to be disabled when the form starts up, it could be the cause of the problem.

Check any disabled controls on the form, and make sure the default button and the first tab stop controls are both enabled. (Hint: Default button should usually be 'Cancel' on a modal form, and it should always be enabled.)

Upvotes: 1

Related Questions