|
The array was allocated dynamically...wud that be the reason why, when I click the + sign, it shows only the first element and not all of them ?
|
|
|
|
|
Yes, that would be the problem. The debugger is not quite sure how long your buffer is. In that case you can qualify your data by placing a comma (,) after the name of your pointer, and the number of elements that you want to watch.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
yeah, use format specifiers. e.g.
"20x" will show 20 elements in hex
"20d" will show 20 elements in decimal
"20m" will dump 20 bytes of memory
experiment!
also check "r" for structs
HTH,
|
|
|
|
|
For a dynamically allocated array, you can put in
Pointer_name,#
Where # is the number of elements you want to watch.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
I have a CObject based class which supports serialization, but am having problems with classes derived from that.
Basically I have the main object which contains all the data, and a serialization function that works fine for that object, and a set of various classes that are all derived from that base class, which provide slightly different functionality, but all work off the data members in the base class.
The data structure builds up as a tree of objects (each object has a pointer to the next item in the list, and also a child)
Now the problem is that these children are all of different types (but all derived from the original base class).
I serialize the code like this
rxArchive >> m_pxNextEvent;
rxArchive >> m_pxFirstSubEvent;
(same for saving but with <<s)
each derived="" class="" has="" its="" own="" serialize="" function="" which="" simply="" calls="" the="" main="" class's="" serialize.
when="" i="" store="" data,="" correct="" functions="" get="" called,="" but="" when="" loading="" back="" in="" only="" base="" seems="" to="" used,="" and="" an="" error="" message="" saying="" "<filename>="" contained="" invalid="" object"
any="" ideas?=""
--
help="" me!="" i'm="" turning="" into="" a="" <a="" href="http://www.grapefruitopia.com">grapefruit!
|
|
|
|
|
No stead fast solution for this, because you dont know
what object's data you are going to read next and the object
might not exist in the program till then and has to be created.
What i would do is read in thru the base and then check for the
type of object based on the information just read in and then
create the derived class object.
You could have a member which would store a code which signifies
which class type does it belongs to!
|
|
|
|
|
See this article.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
From the symptoms that you described, I think that you probably need to change the IMPLEMENT_SERIAL for the derived classes.
When you have a base class and multiple derived classes, you need to specify the parent class in the IMPLEMENT_SERIAL of the derived classes, and not CObject.
For instance, if you have a class called Base derived from CObject and 2 derived classes called Der1 and Der2 derived from Base, you would need the following:
IMPLEMENT_SERIAL( Base, CObject, 1 )
IMPLEMENT_SERIAL( Der1, Base, 1 )
IMPLEMENT_SERIAL( Der2, Base, 1 )
Best regards,
John
|
|
|
|
|
Hmm, that could be the problem. I'd put CObject as the base for everything (the MSDN docs aren't too clear, since technically CObject is the base class of the derived classes )
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
Yup, that fixed it. It's now working wonderfully
Thanks!
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
does anyone know how to make a thread to run a function in a class?
==================================================
Homepage: www.onyeyiri.co.uk
Email: theeclypse@hotmail.com
"I'm not any old Eclypse, i'm TheEclypse..get it, got it, good!"
|
|
|
|
|
This is a two step process. Generally you create a static function in the class which is initially called when you create the thread. The parameter you pass through is a pointer to the object that you want to run the thread in. In the static function you cast the pointer to your object type and call the function in the class you want to use.
AfxBeginThread(YourClass::SteppingStone, (LPVOID)pObject) ;
UINT YourClass::SteppingStone(LPVOID lpv)
{
YourClass *pObject = (YourClass*)lpv ;
int ret = pObject->YourFunction() ;
return ret ;
}
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
where did you get (LPVOID)pObject) ; from, because its not workin for me.
==================================================
Homepage: www.onyeyiri.co.uk
Email: theeclypse@hotmail.com
"I'm not any old Eclypse, i'm TheEclypse..get it, got it, good!"
|
|
|
|
|
Let's say you have:
CYourObject* pObject = new CYourObject;
... Roger suggestions goes here ...
or if inside of your class use this pointer instead of pObject
of course, the thread function is static .
One good thing about getting older, you don't lose the ages you've been!
|
|
|
|
|
when i use this code i get this error:-
D:\SpeakIt\SpeakItDlg.cpp(184) : error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'void (void)'
Is there something else im missing?
==================================================
Homepage: www.onyeyiri.co.uk
Email: theeclypse@hotmail.com
"I'm not any old Eclypse, i'm TheEclypse..get it, got it, good!"
|
|
|
|
|
Parameter 1 is the pointer of thread function.
UINT MyControllingFunction( LPVOID pParam );
This function can be static if you use a member function of a class
or it can be a global function.
If you use a global function, remove YourClass::MyControllingFunction .
Only the second parameter is a void pointer. You may want to take a look
a Michael Dunn C++ Faq: http://www.codeproject.com/cpp/cppforumfaq.asp.
One good thing about getting older, you don't lose the ages you've been!
|
|
|
|
|
Use LPVOID or void * not void for second parameter.
|
|
|
|
|
Make the function static ??
|
|
|
|
|
sometimes i need to determine a list control has how many columns at run time,
one way is to remember the count of InsertColumn,
or :CHeaderCtrl* pHeader = (CHeaderCtrl*) GetDlgItem(0);
int nColumnCount = pHeader->GetItemCount();
anybody can tell me how to get the count in another way?
thanks !
|
|
|
|
|
Seems like you know the answer already!
One good thing about getting older, you don't lose the ages you've been!
|
|
|
|
|
I tend to just get a pointer to the Header Control and use GetItemCount.
Not sure why you'd want another way (of if there is one)
Michael
Errata 1: p. 154, section 'Defusing'. For 'red wire' read 'blue wire'.
|
|
|
|
|
How can I instantiate an Acrobat Writer application, please ?.
Thanks.
Aziz Rajim
|
|
|
|
|
Take a look at ShellExecute. You can specify an executable, or a data file. If you specify a data file, it will open the application designated for that type of file.
No generalization is 100% true.
Not even this one.
|
|
|
|
|
... what do they do really...?
I'm using CVS and it's really annoying to be forced to commit ncb and opt files since they are modified/created over and over.
Can somebody shed some light on this?
Thx,
/Tommy
|
|
|
|
|
.OPT
The workspace options file, which stores information about the physical layout and characterisitics you’ve determined for Visual C++, such as window layout. In terms of source control, the .OPT file is not shareable.
NCB -- Parser information file:
This file contains information generated by the parser used by the class view and component gallery. If the file is accidentally or deliberately deleted, it is automatically regenerated.
You really don´t need them to cvs.
|
|
|
|