Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7912787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:41:36+00:00 2026-06-03T13:41:36+00:00

I’m referring to msdn article Hosting a Windows Form User Control in an MFC

  • 0

I’m referring to msdn article “Hosting a Windows Form User Control in an MFC Dialog Box” [link] (http://msdn.microsoft.com/en-us/library/94t3ebxz.aspx), to reuse windows form user controls in MFC legacy application. With the fancy DDX_ManagedControl utility, I’m able to see the control (MyPanel class) right embedded into the dialog, even tabs through works 100%.

Then I move forward to make the hosting dialog a child of another modal dialog, then the problem comes when one of the textboxes on my WinForms panel gets the keyboard focus and I switch to another application window (different process) to deactivate current dialog, next time when I activate the MFC dialog again, it’s not responding any more.

Some code to clarify the issue:
//in my MFC child dialog
CWinFormsControl m_ctrl1;

void CMyWinFormControlTab::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    DDX_ManagedControl(pDX, IDC_MYPANEL_STATIC, m_ctrl1);
}

//in my out-most modal dialog
BOOL CMFCAppTestDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    CDialog *pNewTab = new CMyWinFormControlTab();
    pNewTab->Create(IDD_MYWINFORMTAB, this);
    pNewTab->ShowWindow(SW_SHOW);
}

Some observations:

  1. In the case aforementioned, if I use Spy++ to monitor all WM_ACTIVATEXXX message in current process, I found no WM_ACTIVATE or WM_ACTIVATEAPP messages captured when the problematic deactivation and re-activation happens, neither any other messages, i.e. message pump is dead.
  2. By contrast, for normal MFC child dialog with MFC controls only, when deactivation and reactivation occur after one textbox gets focus, it’s still responding and I can see all WM_ACTIVATEXXX messages.
  3. If i directly host my WinForms control into a modal MFC dialog, the problem is gone. However, I need a interim modaless dialog, for in my case I use TreeView in which each tree node will load a different modaless dialog.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:41:37+00:00Added an answer on June 3, 2026 at 1:41 pm

    today I managed to overcome this problem by adding a ON_WM_ACTIVATE macro and a blank message handler with correct signature to the modal dialog. FYI

    //in header
    afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
    
    //in implementation cpp
    BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
        //{{AFX_MSG_MAP(CMyDialog)
        ON_WM_ACTIVATE()
        //}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    
    void CMyDialog::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
    {
        //you can leave it blank
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.