We help IT Professionals succeed at work.
Get Started

MDI Form loses focus when custom control is active

704 Views
Last Modified: 2013-12-20
Hi All,

Using VB6 I have written a custom ctl  using the combolistbox as an intrinsic control. When used in an SDI application it works as expected. When used in an MDI application everything works except for one thing. If the control has the focus and a MsgBox is displayed the focus does not seem to go back to the custom control. I think it is because the MDI child form has lost focus. Does anyone know of a solution?  I have attempted to capture the parent form within the control itself by setting it to a form variable that has withevents to capture the form's lost focus event and then execute the form variable's setfocus method, but the lostfocus event does not seem to fire. Any ideas on a different solution or a different event to trap?  The points will be distributed across all contributors with the lion's share (200) going to the accepted answer.  

I have attached the ctl code with a test project (just remove the. txt extensions).  I hope someone can help.

Here is some additional information: To cause the problem just click in the text portion of the combobox and press the enter key. Next close the dialogue window and notice that the blinking caret does not appear in the combobox indicating that the combobox has focus. Now if you pause the running of the vb environment and then continue it the caret appears in the combobox.

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE