-
June 24th, 2014, 03:58 AM
#1
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
-
June 24th, 2014, 05:06 AM
#2
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
-
June 24th, 2014, 05:24 AM
#3
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
-
June 24th, 2014, 05:42 AM
#4
Re: Two problems re-compiling an old MFC project
Hi Victor,
Does Explicit Initializations mean something like this?
Code:
memset (&object, 0, sizeof(object));
-
June 24th, 2014, 07:19 AM
#5
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
-
June 24th, 2014, 08:37 AM
#6
Re: Two problems re-compiling an old MFC project
Originally Posted by luckie7456969
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.
-
June 24th, 2014, 01:26 PM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|