|
I converted a dozen or so projects and never had this particular problem. So I'd check the basics.
1) does the BEGIN_MESSAGE_MAP() have the proper chain of derived and parent classes.
2) does the IDCs of the controls you are expecting map properly to the controls in the dialog you are displaying? I have seen things work by accident because older versions of Visual Studio allowed duplicate IDCs in separate dialogs but the code didn't expect that. Verify then against Resource.h.
3) are controls subclassed properly with DDX (if doing that)
There are a lot of things that need to be stitched together properly for the magic to work.
|
|
|
|
|
Chuck O'Toole wrote: 1) does the BEGIN_MESSAGE_MAP() have the proper chain of derived and parent
classes.
These are OK - or at least, they haven't changed.
Chuck O'Toole wrote: 2) does the IDCs of the controls you are expecting map properly to the controls
in the dialog you are displaying? I have seen things work by accident because
older versions of Visual Studio allowed duplicate IDCs in separate dialogs but
the code didn't expect that. Verify then against Resource.h.
I don't think this is it, I have no duplicate IDs.
Chuck O'Toole wrote: 3) are controls subclassed properly with DDX (if doing that)
I'm not doing this!
This[^] exactly describes my symptoms, but doesn't give a solution (for me anyway).
The only other relevant thing is that I moved all my resources to a DLL (for reasons of internationalisation!). But they all still have the same IDs etc.
Thoughts (and thanks!)?
|
|
|
|
|
The suggestions on that forum page you referenced were pretty good. Especially the part about checking the actual .rc file to make sure all the symbols line up for the control in question.
It also suggested a place to put a breakpoint in the windows dispatch / search routine where it actually tries to match up your MESSAGE_MAP entry (IDC) with the IDC of the control that was clicked (RC file).
Lastly, and it's always a good suggestion, do a clean / complete rebuild to force a recompile of all the resource and source files to make sure everybody's using the same files. That may not have happened if you did a "convert in place" from the old to the new project.
Me, I'd do the full rebuild and the debug from the AFX dispatch to see where it's looking for MESSAGE_MAP entries and why it can't find yours.
|
|
|
|
|
Thanks for your help. I have found a way to fix it - but I wonder if this is a change required by VS2010, or if something deeper is wrong.
Lets say I'm on dialog A, which is a kind of dialog B. Currently, in A.cpp:
BEGIN_MESSAGE_MAP(A_Dlg, B_Dlg)
END_MESSAGE_MAP()
and in B.cpp:
BEGIN_MESSAGE_MAP(B_Dlg, C_Dlg)
ON_BN_CLICKED(IDC_MYBUTTON, OnMyButton)
END_MESSAGE_MAP()
This previously worked fine and allowed me to use IDC_MYBUTTON on all "B" dialogs to give me a generic B-dialog function.
If I add ON_BN_CLICKED(IDC_MYBUTTON, OnMyButton) to the A-dialog message map, the routing works. But why is this necessary? I added the function to the "B" base class so I WOULDN'T have to do this sort of thing.
|
|
|
|
|
I certainly don't do it that way. But if you think of it, if the button is in the "A" dialog, then the MESSAGE_MAP for "A" should be the place for it. I don't think polymorphism applies to controls.
It may be accidental that the RTLs for the older VS didn't check "ownership" where the newer RTLs do. Might even have been a bugfix for someone complaining that what you relied on was, in fact, a bug deserving of a fix.
Anyway, you've got the root problem figured out.
|
|
|
|
|
The documentation on processing message maps seems to support your concept of "virtual action routines" passing from derived window to parent/base class. So, I'd verify your hierarchy is correct first, then ask Microsoft if it's broken but I wouldn't hold up my application for a fix.
http://msdn.microsoft.com/en-us/library/6kc2tzde(v=VS.100).aspx[^]
The first argument names the class to which the message map belongs. The second argument provides a connection with the immediate base class — CView here — so the framework can search its message map, too.
The message handlers provided in a base class are thus inherited by the derived class. This is very similar to normal virtual member functions without needing to make all handler member functions virtual.
If no handler is found in any of the base-class message maps, default processing of the message is performed. If the message is a command, the framework routes it to the next command target. If it is a standard Windows message, the message is passed to the appropriate default window procedure.
|
|
|
|
|
Yeah, I created a little test MFC app to check, and it works fine there!
|
|
|
|
|
It gets stranger and stranger!
I was paraphrasing my code before, it's more like:
BEGIN_MESSAGE_MAP(B_Dlg, C_Dlg)
ON_BN_CLICKED(IDC_ONE, OnFunctionA)
ON_BN_CLICKED(IDC_TWO, OnFunctionA)
ON_BN_CLICKED(IDC_THREE, OnFunctionA)
ON_BN_CLICKED(IDC_FOUR, OnFunctionB)
ON_BN_CLICKED(IDC_FIVE, OnFunctionC)
END_MESSAGE_MAP()
The message map IS actually working, but only for the first entry in the map! If I change the order, I can change what works and what doesn't...
|
|
|
|
|
Check to make sure that the IDC_ numbers aren't messed up in the resource file. If they're somehow the same, that would cause this behavior you're seeing.
|
|
|
|
|
I'm not 100% sure but I strongly suspect this is caused by changes to the message map macros.
Check out BEGIN_MESSAGE_MAP etc. in:
C:\Program Files\Microsoft Visual Studio\VC98\MFC\Include\AFXWIN.H
and compare with:
C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxwin.h
|
|
|
|
|
It just occurred to me that if they changed how the macros generate the map tables, there'd be corresponding changes to the RTL to support it. So make sure the project conversion didn't leave some old libraries that you link with. You might have an explicit link in the project that should be updated for VS2010. Since you have both installed (I assume), you wouldn't get link errors but you'd see runtime oddities.
|
|
|
|
|
You may need to change whats being passed in the message map macros:
ON_BN_CLICKED(IDC_MYBUTTON, OnMyButton)
would become:
ON_BN_CLICKED(IDC_MYBUTTON, &CYourClass::OnMyButton)
If you vote me down, my score will only get lower
|
|
|
|
|
Ok ages ago in my conversion process I was trying to get rid of all the:
warning C4407: cast between different pointer to member representations, compiler may generate incorrect code
warnings from my dialog code. I added /vmg /vmv and forgot about it.
This caused all my function pointers in the dialog message maps to be 16 bytes long instead of 4, breaking everything while complaining about nothing!
|
|
|
|
|
wow, nice find. How'd you ever figure that out?
|
|
|
|
|
I replaced the BEGIN_MESSAGE_MAP macro with its expanded form and stepped through the population of the message map array. It was then easy to compare the (apparent) size of the AFX_MESSAGE_ENTRY structure with the amount of info being poked in at the memory location.
|
|
|
|
|
When we upgraded to VC10 from VC6 we did this exact same thing and everythng broke also.
If you vote me down, my score will only get lower
|
|
|
|
|
Hello Friends
I am reading a xml file(suppose A.xml) using MSXML::IXMLDOMDocumentPtr and all related classes of MSXML.
Now,I want to create another xml file with new data and want to replace with A.xml.
Both xml will be having same Nodes but their child nodes can be different.
Now,My question is
Is there any way that I can store all the data in DomDocumentPtr object and then replace with it existing xml file Dom Pointer?
Or do i need to create another xml on disc and then i have to replace one file with another file.
Which way i can achieve this?
Thanks and Regards
Yogesh sikri
|
|
|
|
|
XmlDocument::ImportNode does the job, It states and i quote:
"The ImportNode method is the mechanism by which a node or entire node subtree is copied from one XmlDocument to another. The node returned from the call is a copy of the node from the source document, including attribute values, the node name, node type, and all namespace-related attributes such as the prefix, local name, and namespace Uniform Resource Identifier (URI). The source document is not changed. "
more from MSDN..
Code from MSDN:
#using <System.Xml.dll>
using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
XmlDocument^ doc = gcnew XmlDocument;
doc->LoadXml( "<bookstore><book genre='novel' ISBN='1-861001-57-5'><title>Pride And Prejudice</title></book></bookstore>" );
XmlDocument^ doc2 = gcnew XmlDocument;
doc2->Load( "books.xml" );
XmlNode^ newBook = doc->ImportNode( doc2->DocumentElement->LastChild, true );
doc->DocumentElement->AppendChild( newBook );
Console::WriteLine( "Display the modified XML..." );
doc->Save( Console::Out );
}
|
|
|
|
|
Hi all,
I want to learn embedded systems, and looking some reading materials which explain from the basic concepts. About PIC programming, designing simple circuit and so on.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
This is the same guy who said "debugging is the oposite of programming".
My advice is to stop wasting our time with silly questions like this. If you had ANY intention of actually becoming an embedded programmer than you would already have books on the various processors used, ARM, Siemens etc and commonly used hardware such as PICs and FPGAs.
==============================
Nothing to say.
|
|
|
|
|
Erudite__Eric wrote: This is the same guy who said "debugging is the oposite of programming".
Yes I am.
Erudite__Eric wrote: My advice is to stop wasting our time with silly questions like this.
I wonder that this is the way experienced members in code project helping others. It may be silly question to you, but not for me. I have an interesting to learn embedded systems, and that is why I ask it openly. Since I have experienced in C/C++ a lot, I decide to plan something beyond that, yet relevant. That is why I ask my question in C/C++ forum too.
If you have any solution please let know. If not don't say anything to discourage others. If you really want to do that, show me the pros and cons I have.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Your question is too broad, too unfocused, not specific.
Your previous question about assembler, trying to turn a led on and off, what hardware were you running it on? Was it a test board, or some real bit of hardware you got hold of? How were you loading your code onto the hardware?
See what I mean?
If you want to learn embedded programming then get yourself some test/development hardware that you can practice on. Look on google. OSR used to do one I seem to recall.
==============================
Nothing to say.
|
|
|
|
|
Now I see your point. Sorry for the confusion.
May be that is because of I haven't much knowledge related with Embedded systems, pic and so on. So I have no clear picture in my mind about the stuff. You guys can guide me on to the relevant track. Basically I want to use my knowledge of C/C++ in hardware stuff, like PIC and so on. I have only my own interest, nothing to do with my job.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
CodingLover wrote: If you have any solution please let know.
Solution to what? You say you want to learn programming on embedded systesms, PIC etc., have you tried the obvious starting point[^]?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Of course I tried mate. Already collect some stuff. But most of them are too complex to understand at once, because of the lack of knowledge on the basis.
I appreciate your help all the time...
CodingLover
|
|
|
|