How to set tab order correct in a C# userControl hosted in an MFC


G

Guest

I´m hosting a C# userControl with lots of other controls on it in an MFC
dialog.
The problem is the tab order. I set it up correctly for the userControl in
the designer and it appears to be set correctly after the call to
initializeComponent() in the userControl as well, but it still does not tab
around in the correct order.
I´m using VS2005 and .NET 2.0

Does anybody know what the problem is?
I´d greatly appreciate any help as it is a really annoying problem!

-Marina-
 
Ad

Advertisements

L

Linda Liu [MSFT]

Hi Marina,

You have mentioned MFC application. Do you create the MFC application by
Visual C++ -> MFC -> MFC Application using VS2005?

Perhaps the 'tab orders' of the controls on the UserControl is changed
somewhere in the MFC dialog.

I found a KB article discussing how to host a WinForm user control as a
dialog in an MFC application. You may visit the following link for more
information.

'WinFormIntegration Sample: Demonstrates Hosting a WinForms User Control in
an MFC Application '
http://msdn2.microsoft.com/en-us/library/ms239718(VS.80).aspx

Hope this helps.
If you have any question, please feel free to let us know.

BTW, I will be on a long vacation from the next Monday to Friday. During my
leave, my team mates will follow up to you and it may not in time. Sorry
for the inconvenience it may bring to you!


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Marina,

Since my colleague Linda is on vacation this week, I will continue to work
with you.

How about this issue now? Does Linda's reply make sense to you? If you
still need any help, please feel free to feedback, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Hi.
The application containing the GUI framework is an old MFC application
created using Visual Studio 6.0. It is not compiled with the /CLR option.
It then loads the MFX extension DLL containing my troublesome MFC dialog
hosting a user control. The latter is created using VS2005, but only has the
/CLR option set for the class that creates the user control, hence I cannot
use the approach described in the article from Linda as it uses afxwinforms.h
and Microsoft::VisualC::MFC::CWinFormsControl in the dialog class.
My problem remains unresolved.

Best regards,
Marina
 
J

Jeffrey Tan[MSFT]

Hi Marina,

Sorry for the late response, I am out of office yesterday.

Do you mean the MFC dialog is created using VS2005 or the C# usercontrol is
created using VS2005? Based on my experience, the supported containers for
Winform usercontrol are very limited. For example, the VC6 version of MFC
is not a supported container for Winform usercontrol, please see the KB
below:
"ActiveX control containers that support .NET controls"
http://support.microsoft.com/default.aspx?scid=KB;EN-US;311334

If you used an unsupported container, there may be some strange behavior in
the application.

Additionally, the .Net Winform code internally implement the tab navigation
key internally without using the Win32 GUI tab key processing model.
However, MFC still leverages the Win32 dialog tab key processing code. This
may also be a potential problem.

Anyway, if you think your problem is not the unsupported scenario, is it
possible for you to create a little sample project to help us reproduce
this problem? Once we can give it a local reproduce, we may understand it
much better. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
L

Linda Liu [MSFT]

Hi Marina,

I am back from my vocation.

How about the problem now?

If the problem is still not resolved, you may send me a sample project that
could just reproduce the problem. To get my actual email address, remove
'online' from my displayed email address.

Sincerely,
Linda Liu
Microsoft Online Community Support
 
Ad

Advertisements

G

Guest

Going back to basics...
I abandoned the way we tried to do the MFC/.Net integration as I came to
realize that it was not a safe way to handle it.
I´m now trying from scratch in the way described in the link you gave me.
(http://msdn2.microsoft.com/en-us/library/ms239718(VS.80).aspx)

And i actually made it work! :)

BUT, I have another problem now...
The application uses almost 100% CPU and appear to "freeze" when you move
the focus away from the application, and this problem I have been able to
reproduce.

Receipt for disaster is as follows:
1. Use VS2005 and Create an MFC application.
2. Add a dialog to the MFC app.
2. Enable /CLR for the new project.
3. Add a C# project to the same solution.
4. Add a UserControl to the C# project.
5. Add a tab control and a button to the user control. (Button must be on
user control, but outside the tab control!)
6. Add a text box to one of the pages in the tab control.
7. Now use CWinFormsControl<typenamne TManagedControl> to host the user
control in the MFC dialog.
8. Compile and run application.
9. Open MFC dialog
10. Click in text box to give it focus.
11. Move focus away from the MFC application
12. Voila...the MFC application now chumps away at your CPU.

The strange thing is that this does not happen if you remove the button, or
just move it inside the pages of the tab control.
If you have troble reproducing the problem I have a sample application I can
e-mail you.
I hope there is a solution to this problem.

Sincerely,
Marina Strand
 
L

Linda Liu [MSFT]

Hi Marina,

Sorry for my delayed response. I am quite busy these days.

This is a quick note to let you know that I am performing research on your
problem, and will get back to you ASAP. I appreciate your patience.

Sincerely,
Linda Liu
Microsoft Online Community Support
 
L

Linda Liu [MSFT]

Hi Marina,

I performed a test based on your steps and did reproduce the problem on my
machine.

I think the problem is related to the TabControl control in .NET. I found
that if I remove the TabControl from the UserControl, the problem
disappeared.

It's known that the TabControl does has the problem of comsuming more
memory than other standard controls, e.g. TextBox, Button and etc, when it
is used.

It seems to me like a limitation of TabControl. I have searched in our
inner database, but I didn't find a similar issue in it.

I suggest that you use GroupBox or Panel, instead of TabControl in the
UserControl.

Thank you for reporting this to us! If you have any other question, please
feel free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support
 
L

Linda Liu [MSFT]

Hi Marina,

How about the problem now?

If you have any question, please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Support Service!


Sincerely,
Linda Liu
Microsoft Online Community Support
 
Ad

Advertisements

Joined
Mar 24, 2015
Messages
1
Reaction score
0
Hi Team
I am facing similar problem. I am hosting c# user control in MCF but I am using group box and that group box has 5 buttons.
I have observed that index is working in reverse order , means I have added 5 buttons ( button1 to button5 ) . so button 5 is getting focus first then button4 and finally its coming to button1 .

Kindly help.

Thanks & Regards,
Milind
 
Ad

Advertisements


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