Sample code mtmdi got problem in VS 2019?

Kaidong Ye 21 Reputation points
2021-09-17T05:56:48.403+00:00

I am studying the code VC2010Samples\MFC\advanced\mtmdi
When I run it and Open a new bounce window, I select color -> custom.... It opens a dialog box, but has no response to any mouse click or keyboard type. What is the problem?
I used Visual Studio 2019 community version to compile and link. Anything changed since 2010?

Thanks in advance
dsiyekd

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,429 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,544 questions
{count} votes

Accepted answer
  1. RLWA32 40,771 Reputation points
    2021-09-17T11:06:01.487+00:00

    I haven't spent a lot of time looking at this but I think the problem may be related to the cross-thread relationship created between the windows. If you change the code to use the desktop window as the owner of the color dialog (not recommended as a general practice) the hang seems to be resolved.

    void CBounceWnd::OnCustomColor()
    {
        CColorDialog dlgColor(m_clrBall, 0, GetDesktopWindow());
        if (dlgColor.DoModal() == IDOK)
        {
            m_clrBall = dlgColor.GetColor();
            m_nIDColor = IDM_CUSTOM;
            MakeNewBall();
            Invalidate();
        }
    }
    

0 additional answers

Sort by: Most helpful