Prev: Warning: Cannot load CRuntimeMap from archive. Class not defined.
Next: Manually set the row height of CListCtrl
From: GT on 22 Nov 2006 07:11 I have a number of old projects last compiled in VC++6. Most of them compile in VS2002 C++, but some of them won't compile. Most of the errors are minor compiler changes - declaring variables inside for() brackets etc. Not a problem, but there are 3 problems which I am struggling with: 6 of my environments have a number of dialogs and the afx_msg OnApply has been coded with a bool return type. In the OnOK() I do: if (OnApply()) CDialog::OnOK(); I get the error: d:\Tassc\Product\Code\team\dlgTeam.cpp(66): error C2440: 'static_cast' : cannot convert from 'bool (__thiscall dlgTeam::* )(void)' to 'AFX_PMSG' reading through the base class and CPropertyPage::OnAypply() itself returns a bool, so when I call it at the end of my OnApply(), it will fail if I have a different return type. what do I do?!? Do I really have to go through everything and make these methods into a void return type, then add a class member variable, set it true at the end of a successful OnApply, then test it in OnOK()? Second problem: 1 of my 21 environments will not build - "fatal error LNK1104: cannot open file mfc42d.dll" Obviously, it won't find mfc42d.dll because mfc is on verson 7.0 in this version of VS, but I can't find any reference to mfc42 anywhere in the code or project files - how do I get round this?!? Thanks
From: Mihajlo Cvetanovi? on 22 Nov 2006 07:40 GT wrote: > Do I really have to go through everything and make these methods into a void > return type, then add a class member variable, set it true at the end of a > successful OnApply, then test it in OnOK()? Yes, that's one way of doing it. Your code is flawed as it is now, it makes obscure and untraceable crashes in release build. > Second problem: > 1 of my 21 environments will not build - "fatal error LNK1104: cannot open > file mfc42d.dll" Obviously, it won't find mfc42d.dll because mfc is on > verson 7.0 in this version of VS, but I can't find any reference to mfc42 > anywhere in the code or project files - how do I get round this?!? Maybe the project uses some 3rd party lib that relies on mfc42d.dll. You can't work your way around that, either use updated lib, or don't use it at all.
From: GT on 22 Nov 2006 10:45 "Mihajlo Cvetanovi?" <mac(a)RnEeMtOsVeEt.co.yu> wrote in message news:%238zJsLjDHHA.2356(a)TK2MSFTNGP03.phx.gbl... > GT wrote: >> Do I really have to go through everything and make these methods into a >> void return type, then add a class member variable, set it true at the >> end of a successful OnApply, then test it in OnOK()? > > Yes, that's one way of doing it. Your code is flawed as it is now, it > makes obscure and untraceable crashes in release build. The code doesn't crash in release or debug mode at the moment! But How come the parent (MFC) classes use a bool return type in their OnApply methods? > >> Second problem: >> 1 of my 21 environments will not build - "fatal error LNK1104: cannot >> open file mfc42d.dll" Obviously, it won't find mfc42d.dll because mfc is >> on verson 7.0 in this version of VS, but I can't find any reference to >> mfc42 anywhere in the code or project files - how do I get round this?!? > > Maybe the project uses some 3rd party lib that relies on mfc42d.dll. You > can't work your way around that, either use updated lib, or don't use it > at all. Ahh - we do use a third party graphics library in this tool - that must be what is causing the problem. Is there a way I can still use the third party library? Our code is tide to it, but it is no longer supported.
From: Mihajlo Cvetanovi? on 22 Nov 2006 11:41 GT wrote: > The code doesn't crash in release or debug mode at the moment! But How come > the parent (MFC) classes use a bool return type in their OnApply methods? Sorry, I haven't read your post thoroughly, and only the static_cast compiler error caught my eye. You mentioned dialogs and property pages in the same context. My comment refers to wrongly formed dialog message handlers (mapped between BEGIN_MESSAGE_MAP and END_MESSAGE_MAP macros). Because of C-style cast these wrongly formed handlers were OK by VC6 compiler, and because of static_cast they aren't OK by VC7 compiler (and in the code compiled by VC6 they actually caused strange crashes in release builds). OnApply function is virtual function of CPropertyPage and not a message handler, so now I'm confused about your problem. Could it be that you have OnApply message handler that just happens to have the same name as OnApply virtual function of CPropertyPage? >>> Second problem: > Ahh - we do use a third party graphics library in this tool - that must be > what is causing the problem. Is there a way I can still use the third party > library? Our code is tide to it, but it is no longer supported. You can use non-debug version of that lib, or copy by hand mfc42d.dll in system32 folder (not quite legal, since debug dll's are non redistributable, but it appears you did it before).
From: Doug Harrison [MVP] on 22 Nov 2006 12:15
On Wed, 22 Nov 2006 12:11:40 -0000, "GT" <ContactGT_remove_(a)hotmail.com> wrote: >I have a number of old projects last compiled in VC++6. Most of them compile >in VS2002 C++, but some of them won't compile. Most of the errors are minor >compiler changes - declaring variables inside for() brackets etc. Not a >problem, but there are 3 problems which I am struggling with: > >6 of my environments have a number of dialogs and the afx_msg OnApply has >been coded with a bool return type. In the OnOK() I do: > >if (OnApply()) > CDialog::OnOK(); > >I get the error: >d:\Tassc\Product\Code\team\dlgTeam.cpp(66): error C2440: 'static_cast' : >cannot convert from 'bool (__thiscall dlgTeam::* )(void)' to 'AFX_PMSG' > >reading through the base class and CPropertyPage::OnAypply() itself returns >a bool, so when I call it at the end of my OnApply(), it will fail if I have >a different return type. what do I do?!? It returns BOOL, not bool. The former is a Windows typedef for int, while the latter is a native C++ type.[*] >Do I really have to go through everything and make these methods into a void >return type, then add a class member variable, set it true at the end of a >successful OnApply, then test it in OnOK()? Change your functions to return BOOL, and you should be fine. [*] Note that OnApply is one of the few message handlers that is virtual and is thus safe to call directly. Non-virtual message handlers won't get polymorphic resolution if called directly; you must call them with SendMessage if you want them to behave polymorphically, because this will engage MFC's message map, and it is though the message map that MFC achieves polymorphism for ordinary, non-virtual message handlers. -- Doug Harrison Visual C++ MVP |