|
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.
|
|
|
|
|
ok u can delete
the
.ncp,.opt.aps,.clw files from the workspace they dunno affect r workspace...and this may be done whenever the classview shows some errors for eg:one or more of ur clasess are disappeared from the clasview tab..
Renjith The True CP ian
|
|
|
|
|
Hi friends
Anybody can explain the better and effective way to copy the resources(all type of ) from many workspaces into one...
i can do it presently well..but i didint satisfiy with it..
R_Renjith The True CP ian
|
|
|
|
|
I Would simply edit the resource files by hand. I don't know what method you have tried but that is the fastest thing that I can think of.
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!
|
|
|
|
|
hi friend
Many Many thanks for your replay..
The method i follow is open the souce resouce file from the target workspace and drag and drop the resource from source to target...and the corresponding Dialog class.cpp and .h files are copied from source and add in to the targhet workspace and add that filesin to the target project...
i think there was some efficient and easy way than this..but i dunno how...if any one know just respond .....
Renjith The True CP ian
|
|
|
|
|
look at the resource.h and <projectname>.rc files.
Copy the pertinent pieces. The files are pretty clear about which parts do what. This will allow you to move/copy many controls/resources at a time.
One thing to remember, is you will have to make each resource Id unique, in the final project. Also at the bottom of the resource.h file are some constants used by the resource editor to assign resource ids. These must be set to the next largest unused number.
|
|
|
|
|
Problem with reading a string from the registry (example windows version).
I tryed this and it worked fine:
char* text;
//unsigned long* buffer;
DWORD* buffer;
unsigned long PerServer;
unsigned long Per1_0Server;
CRegKey reg;
reg.Open(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings");
reg.QueryValue(PerServer,"MaxConnectionsPerServer");
but when i try to read a string (the windows version name) with:
reg.Open(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion");
reg.QueryValue(text,"ProductName",buffer);
i get an assertation error on the line "pdwCount!=null;" (in CRegKey) if i change buffer to anything using "buffer=(unsigned long*)999;" i dont get the error but i get no data.
Am i being stupid? I cant see where im going wrong.
An Expert is somone who has previously made ALL the Mistakes, I dream of this day. - Lucky
|
|
|
|
|
To use the CRegKey::QueryValue(LPTSTR szValue, LPCTSTR lpszValueName, DWORD* pdwCount) overload,
you'll have to have an allocated (or static) buffer for szValue and the size of the buffer in a variable pointed to by pdwCount before calling QueryValue()
<br />
#define TEXTLENGTH 120<br />
<br />
char text[TEXTLENGTH]; <br />
<br />
DWORD textlength;<br />
<br />
CRegKey reg;<br />
<br />
(... snip ...)<br />
<br />
textlength = TEXTLENGTH;<br />
<br />
reg.QueryValue(text, "ProductName", &textlength);<br />
<br />
|
|
|
|