Have to click twice to gain focus?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

We are having focus problems in an application we are working on. Basically,
when you click on a control in the app, it appears to have focus. But if you
type on the keyboard, nothing happens. If you click a second time on the
control, then you can type. This is happening all over the application.

We are using the CompositeUI Application Block from the MS Patterns &
Practices group to build this app. That may or may not have something to do
with our problem. Without going into too much detail, we basically have one
Form as our main window, and everything in it derives from the
Control/UserControl class. We have a lot of controls nested within other
controls, displaying on tabs, etc. but I don't think that should be a problem
in and of itself.

Any help is appreciated ... even if you don't know the answer, I could use
some troubleshooting tips. Can I capture Windows messages to see what is
going on? Use the spy or one of the VS2005 tools? I'm not sure where to
begin. Thanks in advance,
 
Are you setting the Capture property of any Controls in the form, by some
chance?

--
HTH,

Kevin Spencer
Microsoft MVP
Ministry of Software Development
http://unclechutney.blogspot.com

I just flew in from Chicago with
a man with a wooden leg named Smith
who shot an elephant in my pajamas.
So I bit him.
 
Thanks for your reply, Kevin. I did a search in our solution and the CAB
solution for any references to Capture. It didn't find anything. So I don't
think that is the issue. From reading in the help about the Capture
property, it only applies to mouse events. Is there a similar property or
mechanism that captures keystrokes? That might help me find the problem.
Thanks again, looking forward to a reply.

Kevin Spencer said:
Are you setting the Capture property of any Controls in the form, by some
chance?

--
HTH,

Kevin Spencer
Microsoft MVP
Ministry of Software Development
http://unclechutney.blogspot.com

I just flew in from Chicago with
a man with a wooden leg named Smith
who shot an elephant in my pajamas.
So I bit him.
 
I'm having a similar problem with the DataGridView control. If the grid
lacks focus, and I click on a row other than the selected row, I have to
click twice to get it to change to the selected row. It's like one click to
set focus and another click to change rows. That behavior may be by design,
but it's somewhat annoying to the user.
 
DaveSouthern said:
I'm having a similar problem with the DataGridView control. If the grid
lacks focus, and I click on a row other than the selected row, I have to
click twice to get it to change to the selected row. It's like one click
to
set focus and another click to change rows. That behavior may be by
design,
but it's somewhat annoying to the user.

And this can also be seen when clicking ToolStrip's buttons. First click
activates the form and the second fires the event.

-Teemu
 
It's really hard to say, Paul. A Control can capture the mouse in a number
of different ways. This sort of thing can be hard to track down. However,
here are a couple of references that may help with your diagnosis:

http://msdn2.microsoft.com/en-us/library/ms171545.aspx
http://msdn2.microsoft.com/en-us/library/ms171540.aspx

--
HTH,

Kevin Spencer
Microsoft MVP
Ministry of Software Development
http://unclechutney.blogspot.com

I just flew in from Chicago with
a man with a wooden leg named Smith
who shot an elephant in my pajamas.
So I bit him.


Paul Fountain said:
Thanks for your reply, Kevin. I did a search in our solution and the CAB
solution for any references to Capture. It didn't find anything. So I
don't
think that is the issue. From reading in the help about the Capture
property, it only applies to mouse events. Is there a similar property or
mechanism that captures keystrokes? That might help me find the problem.
Thanks again, looking forward to a reply.
 
We are having focus problems in an application we are working on. Basically,
when you click on a control in the app, it appears to have focus. But if you
type on the keyboard, nothing happens. If you click a second time on the
control, then you can type. This is happening all over the application.

We are using the CompositeUI Application Block from the MS Patterns &
Practices group to build this app. That may or may not have something to do
with our problem. Without going into too much detail, we basically have one
Form as our main window, and everything in it derives from the
Control/UserControl class. We have a lot of controls nested within other
controls, displaying on tabs, etc. but I don't think that should be a problem
in and of itself.

Any help is appreciated ... even if you don't know the answer, I could use
some troubleshooting tips. Can I capture Windows messages to see what is
going on? Use the spy or one of the VS2005 tools? I'm not sure where to
begin. Thanks in advance,

If your user has gone to another form and comes back to the form this is
standard behavior. One click to get focus on the form and another to get focus
on the control.

In your case that may not be the situation, but I feel it's worth mentioning.

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
 
Back
Top