From: Rob on
Joseph:

I use the NewMenu code in question and it works well. Also, the developer has done a nice job maintaining his code to keep up with Microsoft changes. Below is his website and a link to the NewMenu source code. He is a very nice guy and very good software engineer. Maybe you can look over his source and give him some suggestions that would make his code more robust and compliant with Micosoft standards.

http://www.podetti.com
http://www.podetti.com/NewMenu/Index.html

Best Regards,

Rob Krakora




Joseph M. Newcomer wrote:

See below...
30-Oct-08

See below...
On Thu, 30 Oct 2008 17:52:30 +0000, Paul Cheetham <Runningdeere(a)Amberkeys.co.uk> wrote:

****
It was never, in the history of MFC, sensible to define a message map as you have shown.
The orignal author was probably one of those pseudo-macho types who believed that Real
Programmers Don't Use Tools, and included macros as part of the tools. These people are
dangerous, and the obvious proof of this is that you are now a victim of their
incompetence.
****
****
You will have to make the changes to the MESSAGE_MAP macros as I indicated. There isn't
really any choice.
****
****
There are probably other fatal decisions this programmer made. Anyone dumb enough to
hand-create a message map probably made other serious errors. It will not be a fun
experience.
joe
****
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

Previous Posts In This Thread:

On Thursday, October 30, 2008 10:57 AM
Paul Cheetham wrote:

MFC Message Map Problems
I have inherited an application written in VS6 (VC) and I am attempting
to upgrade it to VS2005.
I have solved most of the issues - mainly relating to superseded
function calls etc, but there are a couple of issues that I am
struggling with:

I have the following code:


static const AFX_MSGMAP_ENTRY* GetMessageEntries()
{
static const AFX_MSGMAP_ENTRY Entries[] =
{
ON_WM_MEASUREITEM()
ON_WM_MENUCHAR()
ON_WM_INITMENUPOPUP()
ON_WM_ENTERMENULOOP()
ON_WM_EXITMENULOOP()
ON_WM_TIMER()
ON_WM_CREATE()
ON_WM_NCHITTEST()
ON_WM_DESTROY()
ON_WM_SYSCOLORCHANGE()
ON_WM_NCPAINT()
ON_WM_PAINT()
ON_WM_ACTIVATEAPP()
ON_WM_ACTIVATE()
{0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 }
};
return Entries;
}


This generates the error "error C2653: 'ThisClass' : is not a class or
namespace name" on lines 5 - 10
Looking at the definitions (declared in afxmsg.h) they are declared as
follows:
{ WM_MEASUREITEM, 0, 0, 0, AfxSig_vOWNER, \
(AFX_PMSG)(AFX_PMSGW) \
(static_cast< void (AFX_MSG_CALL CWnd::*)(int, LPMEASUREITEMSTRUCT) >
( &ThisClass :: OnMeasureItem)) },


Now I know what the error means, but this is defined in one of the
standard header files, so what do I need to do?

Thankyou.

Paul

On Thursday, October 30, 2008 11:39 AM
Scott McPhillips [MVP] wrote:

Re: MFC Message Map Problems
"Paul Cheetham" <PAC.News(a)dsl.pipex.com> wrote in message
news:%230U1u$pOJHA.3748(a)TK2MSFTNGP04.phx.gbl...

'ThisClass' is a macro argument. It is normally defined by the
BEGIN_MESSAGE_MAP (x, y)
declaration's x parameter. So it seems you may have a missing
BEGIN_MESSAGE_MAP or, at least, your code must follow that declaration in a
cpp file in order to compile.

--
Scott McPhillips [VC++ MVP]

On Thursday, October 30, 2008 12:21 PM
Joseph M. Newcomer wrote:

Re: MFC Message Map Problems
See below...
On Thu, 30 Oct 2008 14:57:18 +0000, Paul Cheetham <PAC.News(a)dsl.pipex.com> wrote:

****
Note that the code above is complete and utter nonsense. It is not a valid message map.
A *VALID* message map is achieved by doing

BEGIN_MESSAGE_MAP(CMyClass, CSuperClass)
ON_WM_MEASUREITEM()
ON_WM_MENUCHAR()
...etc
END_MESSAGE_MAP()

Any attempt to "hand write" this code is doomed, and consequently, you need to rewrite the
code to use the correct macros. This code was NEVER valid, it just happened by accident
to have worked in VS6. Get rid of all that meaningless trash above.

OnNcHitTest did change; it used to return an 'int' and now it returns an LRESULT, so this
will cause a problem.

In order to maintain backward compatibility in one case, I had to add

afx_msg int OnNcHitTest(...);
afx_msg INT_PTR OnNcHitTest(...);

int CMyClass::OnNcHitTest(...)
INT_PTR CMyClass::OnNcHitTest(...)
{
// body of code here
}

where ... represents the parameters that are there (I don't recall them at the moment)

****
****
Use the correct mechanism for creating a message map. The hand-written code was created
by someone who was, to put it mildly, totally clueless.
joe
****
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

On Thursday, October 30, 2008 1:52 PM
Paul Cheetham wrote:

Thanks for your help guys.I'll try and sort it out.
Thanks for your help guys.
I'll try and sort it out.

The problem is this is REALLY old code, I mean, I'm pretty sure it
started off in DOS and has been fiddled with for years.
I'm only upgrading it to VS2005 to make it easier to work with, as of
course VS6 will not run on Vista.

True, the guy that did this was clueless, and to make matters worse it
has been changed by someone else who was still clueless.

While I have worked in C++ and Win API a LOT, this is my first foray
into MFC (I have actively avoided it), so thanks again for your help.


Paul

On Thursday, October 30, 2008 3:32 PM
Joseph M. Newcomer wrote:

See below...
See below...
On Thu, 30 Oct 2008 17:52:30 +0000, Paul Cheetham <Runningdeere(a)Amberkeys.co.uk> wrote:

****
It was never, in the history of MFC, sensible to define a message map as you have shown.
The orignal author was probably one of those pseudo-macho types who believed that Real
Programmers Don't Use Tools, and included macros as part of the tools. These people are
dangerous, and the obvious proof of this is that you are now a victim of their
incompetence.
****
****
You will have to make the changes to the MESSAGE_MAP macros as I indicated. There isn't
really any choice.
****
****
There are probably other fatal decisions this programmer made. Anyone dumb enough to
hand-create a message map probably made other serious errors. It will not be a fun
experience.
joe
****
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm


Submitted via EggHeadCafe - Software Developer Portal of Choice
Dynamic HTTP Compression with IIS 5.0
http://www.eggheadcafe.com/tutorials/aspnet/ff6a260c-3f9d-4c6d-86c3-512799fc857e/dynamic-http-compression.aspx