开发者

Dialog Box loses focus in Windows XP

开发者 https://www.devze.com 2023-01-28 14:31 出处:网络
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

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 hav开发者_StackOverflow社区e 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?


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.)


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号