Hello
I'm busy working with an MDI parent and child forms. I've found that there is a discrepancy between the locations returned by DesktopLocation , Control.MousePo sition and MouseEventArgs e.Location, but I can't work out why or what exactly the discrepancy is.
My forms are all custom without title bars and thus I've had to create my own moving methods, etc. This is obviously related to the location of the mouse...
User Profile
Collapse
-
ducttape started a topic DesktopLocation vs Control.MousePosition vs e.Location (where e is MouseEventArgs)in C SharpDesktopLocation vs Control.MousePosition vs e.Location (where e is MouseEventArgs)
-
I think xpath is doing more than i need it to, it seems almost SQL-like and I'm worried about computational efficiency.
I literally just need to read each record, which contains author, title, etc, into a data structure. There must be an easy way to do this? I can do it when "record"s are the root nodes but as you can see from my xml file the actual data is stored several levels deep.
I would like to do it... -
Thanks very much, I'll check out those tutorials I havent heard of XPathNavigator before.
I have no idea what i'm doing though so I will probably be back :)Leave a comment:
-
Reading complex XML files in C#
Hi, I have been trying for several days to read XML files into my program. I have been following several good tutorials on the internet, but I am struggling because the particular XML files that I am reading have several nested fields:
<?xml version="1.0" encoding="UTF-8" ?>
<xml>
<records>
<record>
<database name="test.enl" >test</database>... -
Thanks for your patience. Everything was declared and I was not using anything. I have guard mechanisms around all of my classes. I forward declared childClass and then added a childClass variable to parentClass. In childClass, I forward declared parentClass and added a parentClass variable to childClass. So far I have not defined anything or tried to use any of its members. If simply adding a variable requires you to define the class then...Leave a comment:
-
I spoke too soon. I forgot my code example doesn't actually have a child belonging to the parent. If I try to add one, even if I forward declare childClass, I get error C2079: 'parentClass::c ' uses undefined class 'childClass'. This is from simply adding a childClass variable to parentClass, not even from instantiating it.Leave a comment:
-
It's working with the forward declaration of childClass instead of the #include childClass. Thanks so much for your patience. In retrospect I'm embarassed that I too expected psychic abilities from the compiler. It just seemed so natural.
One of the starkest differences is that Java's variables are pointers by default. To create a new instance you actually have to use the "new" keyword. It seems to me to be a much more...Leave a comment:
-
It's actually quite an interesting discussion, I always did wonder it was bad programming form on my part but I do it all the time in Java and C#: for the class that instantiates another class to pass itself through as a parameter so that the second class can refer to it as its parent. It's a really neat trick which saves bucketloads of code and I'd imagine saves bucketloads of memory. But if C++ doesn't allow it easily perhaps that's indicative...Leave a comment:
-
I read up about include guards, I found this link helpful: http://www.efnetcpp.org/wiki/Include_guards
Unfortunately it seems like it's not what I need after all becuase it doesn't solve the original problem that A needs to have B defined and B needs to have A defined.
This is really messing with my head I feel like I'm going a bit crazy thinking about it. I'm kind of coming to the conclusion that you can't have...Leave a comment:
-
Ok, that sounds like exactly what I need, I'll read up about the "guard mechanism" - is that what it's called? Perhaps you only need to put that guard around one of the classes to stop the preprocessor from going all the way down. I'll experiment and post my findings here. Thanks againLeave a comment:
-
Thanks Jos, what do you mean, protect the preprocessor from going all the way down?
I added your code, it works if I leave out the #include in one of the classes, but if I put it in (which I obviously need to) it doesn't recognise it.
I include the code here in case I'm neglecting to tell you something.
Code://parentClass.h #ifndef PARENTCLASS_H #define PARENTCLASS_H #include
Leave a comment:
-
I think I understand how headers work now. I can see the advantages and I'm going to split all my classes into seperate files from now on. So, I've split up the parent and the child class, made headers for them with their variables, and seperate .cpp files for their methods. The files all now #include each other.
The problem I'm getting now is error C1014: too many include files : depth = 1024. I figure its because class 1 includes...Leave a comment:
-
Hi Banfa, I'm getting really close, I can feel it! I actually went and implemented that conceptual code in Visual Studio 2008 and I even got it to compile. So I added a variable to pass through to test it, and drew a blank. By the way, that article convinced me using "this" in the constructor was a bad idea. Here's the code, which results in the same error (..uses undefined class..)
Code:#include "stdafx.h"
Leave a comment:
-
OK!! That's really helpful, I was assuming I was passing through a pointer just as in Java. As you may have guessed the code I posted was just a conceptual version, in the actual version the parent (a particle system) contains an array of children (particles) - I just want each child to have a pointer to its parent so it can ask it what it needs to look like when it respawns.
So, if I do something like this:
Code:class
Leave a comment:
-
Forward declaration in C++ not working
myProgram.cpp:
Code:class childClass { parentClass parent; //reference to class that created this child childClass(parentClass p) { parent = p; } }; class parentClass { childClass child(this); };
This would work fine in Java, which I'm more accustomed to,...
No activity results to display
Show More
Leave a comment: