|
Actually, ThreadProcB is calling ThreadRunB() which is a member function of CMyClass ( sorry, i just simplified my class to show out here ).
I passed this pointer to ThreadProcB(), and call the function as pThis->ThreadRunB() in ThreadProcB.
In my cass the m_Vector's should be created in the "main" thread when MyClass is instantiated. Then I created another thread with Thread function ThreadProcB, in turns calling ThreadRunB.
Is it exceed the limit of using STL containers ?
ie. Create in one thread, access in another thread. Any special thing I've to do about threading issue ?
|
|
|
|
|
Hi everybody out there!
Is there any chance to use the implement dynamic macro in the MFC with
mutiple inherited classes?
Do I have to rewrite the macro?
Thanks for bothering,
Lars
|
|
|
|
|
Don't think it's possible - remember that existing MFC classes are compiled with 'normal' IMPLEMENT_DYNAMIC. Of course, you could try to change the MFC sources and recompile, but this would be major PITA. What are you trying to achieve? Maybe there's easier way than re-implementing macros?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi,
I need to save/open files with 8 different extensions with one Document, but I only can set one DocString (extension, file filter for Open/Save Dlg,...).
How can I change the file filter and extension used in the Open/Save Dlg at runtime according which filetype I want to save?
Thank you!
Zoltan
|
|
|
|
|
CDocTemplate::GetDocString is virtual - just create your own class derived from CSingleDocTemplate or CMultiDocTemplate and override GetDocString.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thank you!
Zoltan
|
|
|
|
|
I'm currently working on a project that would benefit from being able to move those icons and drawing them myself (I'm currently working on a skinning project...). Is it even possible???
Andreas Philipson
|
|
|
|
|
If you are going to make skining project may be better to organize your own controls.
But the standart buttons on the captions you can draw using
API function DrawFrameControl
|
|
|
|
|
Probably, if this was only for one project but I'm planning on making this code as reusable as possible. I'd also like it if I could apply these skins on an old project with minimum work.
BTW, the article "Custom Captions" (in GDI) will probably do what I want...
[update] Nope that didn't work... any ideas anyone? [/update]
Andreas Philipson
|
|
|
|
|
I want to send a message to every node in same LAN ,but i don't know the node's address. How to do?
Thanks!
QiangWang
|
|
|
|
|
|
I have a template class(my 2nd one) that I am using here the code that give me error and the error latter.
class UseClassMemebersInTemplate
{
public:
void Build(){...};
void Kill();
...
};
template<Type& T>
class TemplateClass
{
public:
TemplateClass()
{
CallAFunctionInConstructor();
}
~TemplateClass()
{
CallAnotherFunctionInConstructor();
}
void CallAFunctionInConstructor()
{
T.Build();
}
void CallAnotherFunctionInConstructor()
{
T.Kill();
}
};
...
//In Another class same header file futher to EOF
...
TemplateClass<UseClassMemebersInTemplate> NewObj;
///////////
When the above is build in VC++ 6.0
I get a couple of errors one looks like...
"missing a ';' before '.'"
At one time I had the calls to Build() and Kill() but empty template constructor and destructor. So I comment constructor and destructor bodies and I was able to build it fine.
I was looking at my 1st template class that I build a year or two ago which applied to the class above modifiy only three places in the template. Keep in mind I going back to the code that gave me the errors. Here the changes I made...
1. Added a pointer to T as a memeber to the template call. Like "T* pT;".
2. Changed both call to Build() and Kill() from "T.Build();" and "T.Kill();" to "pT->Build();" and "pT->Kill();"
And it works find. I can live with calling w/ a pointer but if anyone know why I can use "T." please let me know why not.
|
|
|
|
|
One way is this:
class UseClassMemebersInTemplate
{
public:
void Build()
{
TRACE("Build\n");
};
void Kill()
{
TRACE("Kill\n");
};
};
template< class T >
class TemplateClass : public T
{
public:
TemplateClass()
{
CallAFunctionInConstructor();
}
~TemplateClass()
{
CallAnotherFunctionInConstructor();
}
void CallAFunctionInConstructor()
{
Build();
}
void CallAnotherFunctionInConstructor()
{
Kill();
}
};
|
|
|
|
|
you need to store an instance of UseClassMembersInTemplate in your template class and refer to that, ie, rather then T.whatever(), to myTInstance.Whatever().
template <class t="">
class CTemplateClass
{
private:
T myT;
public:
// now, use the myT member to do your stuff
};
|
|
|
|
|
I see what was going on I wasn't storing UseClassMemebersInTemplate on the stack. So T when use with "T." isn't resolved to an object to call the function. When I used the pointer it work. I can see it is like using CFile::GetStatis(FileNameStr,...) so you don't need to opened the file first. The code I presented in my other post(using pointers) works for functions but I don't think it will work with varibles which I haven't worked on yet but will. I will change the declaration of the pointer to an instance of UseClassMembersInTemplate and call the functions and use varibles(when I have them) using the the stored object's instance.
Thank you for the help so I wouldn't have to post another thread call "Templates errors I found and fix. But a quest...Why the errors? - Varible Extendtion"
|
|
|
|
|
From web camera come image frames which i'd like to store in a file ( .bse i defined ).
to store received images i writed the following..
// msg structure contains head and pointer to the frame data.
RES_MSG msg;
nFrameSize = m_pCamera->ReadFrame(&msg, (char *)mFrameBuf, MAX_FRAME_BUF_SZ);
if( nFrameSize > 0 ) {
msg.u.frame_data = mFrameBuf;
m_pArchive->Write( &msg ,sizeof(RES_MSG)+ nFrameSize )
}
//
to retrieve frame i writed the following...
// m_pTempBuf buffer is enough to store data
RES_MSG * pmsg;
archive.Read( m_pTempBuf , bufsize );
pmsg = (RES_MSG *)m_pTempBuf;
pmsg->u.frame_data = (unsigned char *) ( m_pTempBuf + sizeof(RES_MSG) );
//
after all, i can get head information , but can't get frame data.
is there anything wrong ????
somebody please help me.
thanks in advance.
|
|
|
|
|
Looks like you are writing the pointer to the data, but not the actual data!
|
|
|
|
|
Hello,
I am parsing through a long string and pulling out info between two quotes.. everything works great but when I compile the program I get four
warnings..
warning C4305: 'argument' : truncation from 'const int' to 'char'
warning C4309: 'argument' : truncation of constant value
warning C4305: 'argument' : truncation from 'const int' to 'char'
warning C4309: 'argument' : truncation of constant value
Heres a sample of the code..
int nMyIndex, nFirstQuoteIndex, nSecondQuoteIndex;
nMyIndex = strSource.Find(_T("key"));
nFirstQuoteIndex = strSource.Find('""', nMyIndex);
nSecondQuoteIndex = strSource.Find('""', nFirstQuoteIndex+1);
m_strKey = strSource.Mid(nFirstQuoteIndex+1, nSecondQuoteIndex-nFirstQuoteIndex-1);
Is there a way to keep the compiler from having a fit? Should I not worrie about it?
Should I parse the string differently?
Any suggestions would be appreciated.
Thanks,
Rob Jones
|
|
|
|
|
I'm not sure why your code is searching for two double-quotes, but if your looking to find something between two quotes, you might consider something like the folowing;
nFirstQuoteIndex = strSource.Find('\"', nMyIndex);
nSecondQuoteIndex = strSource.Find('\"', nFirstQuoteIndex+1);
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
|
I am writing my first program. When I execute the program it prompts the user for a number and then returns a calculation. However, the program is displaying the result super fast and then closing the window immediately. It's impossible to even read the answer.
How can I get the program to not terminate so quickly or to say "Hit any key to continue."?
|
|
|
|
|
Are you using Visual C++? It should automatically pause after a terminal program is done executing.
If not, give getchar() a try.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Alternatively, instead of double clicking the executeable, run it from the command line (ie cmd or dosprmpt).
|
|
|
|
|
Hello, the codegurus around the world.
It seems that you're working a DOS program or the console application.
You open the dos window directed to the location of your EXE files.
C:\>whatever, and type dir/w. You will find your EXE file.
So,
C:\whatever\Your.exe
You can take a look at your result.
Maybe, there may be some way to keep opening the console application from
executing in Visual Studio.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
I am makeing a Direct Sound music player. How would I use MP3s with it.
|
|
|
|