Search code examples
mfcafx

MFC: _AFXWIN_INLINE give me "no overloaded function takes 6 arguments"


In an MFC application I am trying to move a console window I have added for debug purposes.

    /*  Put here just for reference
        _AFXWIN_INLINE void CWnd::MoveWindow(LPCRECT lpRect, BOOL bRepaint)
        { MoveWindow(lpRect->left, lpRect->top, lpRect->right - lpRect->left,
        lpRect->bottom - lpRect->top, bRepaint); }
    */
        HANDLE hh;
        bool oo = CWnd::MoveWindow( hh, 100, 0, 300, 300, true );

I get this error:

Error   C2661   'CWnd::MoveWindow': no overloaded function takes 6 arguments    
G:\proj\repos\EnterDG\EnterDGDlg.cpp    201

The strange thing is that if I put the mouse pointer at the "MoveWindow"" I get the expected prototype. But if I use "goto definition" I get the definition you see in the first lines( greyed out ).

I have tried to "#undef _AFXWIN_INLINE"


Solution

  • CWnd::MoveWindow has two overloads, one taking 5 arguments, the other taking 2 arguments. As the error indicates, there is no overload that takes 6 arguments.

    It looks like you are trying to call the Windows API function MoveWindow instead. This is a free function, so you need to drop the CWnd:: scope resolution. Using a global namespace resolution prefix is always safe, e.g.: ::MoveWindow(...);.