PictureBox that Receives and Shows Input Focus

B

Bruce

I am trying to create a control which is basically a PictureBox than
can receive and show focus. I have created a UserControl descendant
that simply contains a PictureBox control. The PictureBox control
automatically sizes to whatever size is selected for the control. To
show focus, I am overriding the OnEnter and OnLeave methods of the
derived controi to change the BorderStyle property of the PictureBox
control.

The problem I am having is in handling click and double-click mouse
events. It appears that when the user clicks on the control, it is the
PictureBox that receives the mouse events. Since I want to be able to
set event handlers for mouse events external to the control, I have
declared event handlers for MouseUp, MouseDown, Click and DoubleClick
for the PictureBox control that simply pass these events to the
underlying control.

The behavior I am looking for is for a single click to give focus to
the control, and a double-click to fire the control's DoubleClick
event. This works except for the case where the control does not have
focus and the user double-clicks on it. In this case, it seems the
first click is consumed to give focus to the control, and it never
sees the double-click.

How can I get the desired behavior?

--Bruce
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top