Two problems re-compiling an old MFC project
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Two problems re-compiling an old MFC project

  1. #1
    Join Date
    May 2012
    Posts
    9

    Two problems re-compiling an old MFC project

    1)
    Code:
    BEGIN_MESSAGE_MAP(CCoolBar, baseCCoolBar)
        //{{AFX_MSG_MAP(CCoolBar)
        ON_WM_NCHITTEST()
        ON_WM_NCLBUTTONUP()
    	ON_WM_SIZE()
    	//}}AFX_MSG_MAP
        ON_MESSAGE(WM_SETTEXT, OnSetText)
    	ON_MESSAGE(WM_NOTIFY, OnNotify)
    END_MESSAGE_MAP()
    Error 3 error C2440: 'static_cast' : cannot convert from 'BOOL (__thiscall CCoolBar::* )(WPARAM,LPARAM,LRESULT *)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' e:\exetoc_src_20050524\exe2c_gui\scbarg.cpp 57 1 exe2c_gui

    Comment(s):
    I've tried to change that prototype definition (OnNotify) to return a value of LRESULT
    But it complains about CWnd::OnNotify that it returns a different value from
    the base class (CWnd), (something like that, can't remember)

    2)
    Code:
    CRorTextView::CRorTextView()
    {
    	AFX_ZERO_INIT_OBJECT(CScrollView);
    	ResetView();
    }
    Error 4 error C2275: 'CScrollView' : illegal use of this type as an expression e:\exetoc_src_20050524\exe2c_gui\crortextview.cpp 114 1 exe2c_gui
    Error 5 error C3861: 'AFX_ZERO_INIT_OBJECT': identifier not found e:\exetoc_src_20050524\exe2c_gui\crortextview.cpp 114 1 exe2c_gui


    Comment(s):
    The macro seems to be deprecated in the new MS SDK 7.0a. What is the proper replacement for this macro?

    So please help.
    Thanks
    Jack

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,989

    Re: Two problems re-compiling an old MFC project

    1) There might be a name conflict, and therefore you have to specify class name, like following:
    Code:
        ON_MESSAGE(WM_SETTEXT, &CWnd::OnSetText)
    Best regards,
    Igor

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,414

    Re: Two problems re-compiling an old MFC project

    1. Did you ever read the TN061: ON_NOTIFY and WM_NOTIFY Messages?
    If you really wants to handle WM_NOTIFY see the section ON_NOTIFY: Handling WM_NOTIFY Messages in MFC Applications


    2. According to https://connect.microsoft.com/Visual...lous-behavior:
    The dangerous AFX_ZERO_INIT_OBJECT has been removed, and usages of it replaced with explicit initializations.
    Why do you use it?
    Victor Nijegorodov

  4. #4
    Join Date
    May 2012
    Posts
    9

    Re: Two problems re-compiling an old MFC project

    Hi Victor,
    Does Explicit Initializations mean something like this?
    Code:
    memset (&object, 0, sizeof(object));

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,414

    Re: Two problems re-compiling an old MFC project

    Why don't you want to look at the source code of CScrollView class? Just open viewscrl.cpp and search for CScrollView ctor!
    Last edited by VictorN; June 25th, 2014 at 02:43 AM.
    Victor Nijegorodov

  6. #6
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,917

    Re: Two problems re-compiling an old MFC project

    Quote Originally Posted by luckie7456969 View Post
    Hi Victor,
    Does Explicit Initializations mean something like this?
    Code:
    memset (&object, 0, sizeof(object));
    no, that's what the old macro did
    which doesn't have any name other than "really badly written code".

    Explicit initialization means that you 'call' a constructor, and the constructor takes care of initializing it's members.

  7. #7
    Join Date
    May 2012
    Posts
    9

    Re: Two problems re-compiling an old MFC project

    Wow, Explicit initialization is just as simple as that.
    Thanks OReubens.
    Jack

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center