1

For almost 20 year I've been developing an MFC MDI application. It has worked on Windows 98, Windows XP and Windows 7. But it fails on Windows 10... Any ideas, why? Here is the code:

class CEdytorDocFrame : public CMDIChildWnd
{
    DECLARE_DYNCREATE(CEdytorDocFrame)

public:
    CSplitterWnd m_wndSplitter;
    CSplitterWnd m_wndSplitter2;
    CStatusBar  m_wndStatusBar;

}
IMPLEMENT_DYNCREATE(CEdytorDocFrame, CMDIChildWnd)

CEdytorDocFrame::CEdytorDocFrame() :
    m_nOldCY(0),
    m_nOldEditH(1),
    m_nOldViewH(1),
    m_nOldEditMinH(0),
    m_nOldViewMinH(0)
{
} // CEdytorDocFrame::CEdytorDocFrame()

BOOL CEdytorDocFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
    CDebug::WriteLog("CEdytorDocFrame::OnCreateClient(), enter");
    /*
    ** Create status bar
    */
    if(!m_wndStatusBar.CreateEx(this, SBT_TOOLTIPS | SBARS_SIZEGRIP) ||
        !m_wndStatusBar.SetIndicators(indicators, countof(indicators)))
    {
        TRACE0("Failed to create status bar\n");
        return FALSE;
    }
    CDebug::WriteLog("CEdytorDocFrame::OnCreateClient(), status bar created");

    /*
    ** Calculate heights and widths
    */
    int wndW, wndH, treeW, treeH, viewW, editW;
    wndW = lpcs->cx;
    m_nOldCY = wndH = lpcs->cy;
    // Set tree pane to be 1/4 of total width and maximum height
    treeW = wndW/4;
    treeH = 0;
    // Set edit pane to be 4/7 height of edit window and maximum width
    m_nOldEditH = MulDiv(wndH, 4, 7);
    editW = 0;
    // Set preview pane to be 3/7 height of edit window and maximum width
    m_nOldViewH = wndH-m_nOldEditH;
    viewW = 0;
    CDebug::WriteLog("CEdytorDocFrame::OnCreateClient() wndW=%d, wndH=%d, treeW=%d, treeH=%d, viewW=%d, editW=%d",
                        wndW, wndH, treeW, treeH, viewW, editW);

    // Create panels
    if(!m_wndSplitter.CreateStatic(this, 1, 2))
    {
        TRACE0("Failed to create static splitter\n");
        return FALSE;
    }
    CDebug::WriteLog("CEdytorDocFrame::OnCreateClient(), 1st splitter created");

Last WriteLog() does not get executed, so I suspect some problem with CreateStatic()... But why on Windows 10 only?

milet
  • 81
  • 1
  • 3
  • I take it you don't have a 10 machine to debug on, that is tough. I'm still developing on 7 and use `CreateStatic` for a splitter. And, I create the splitter dynamically at run time. I'm running on scores of 10 machines and it works. So probably something other than the `CSplitterWnd ` itself. – lakeweb Oct 16 '19 at 01:09
  • Ok, problem solved. Turns out `ON_WM_SIZING()` or `ON_WM_SIZE()` were being called before `OnCreateClient()`. This does not raise my confidence in Windows 10... – milet Oct 16 '19 at 08:05
  • Ok, and I use it in a `CSplitterView` that I've created. In my handler I have: `if( ! GetSafeHwnd( ) || ! splitter.GetSafeHwnd( ) )return;` But that was there before 10, don't remember why. – lakeweb Oct 17 '19 at 16:58

0 Answers0