|
Hopefully this question isnt too silly.
I've got a thread that I want to get the exit code from. I started it using
CWinThread* pMyThread = AfxBeginThread(ThreadProc, (LPVOID)this,0,0,CREATE_SUSPENDED), after which I set the AutoDelete to false and Resumed the thread.
Once I have the ExitCode from the thread, is calling delete pMyThread ok for cleaning up the thread that I created? Or is there something else to do or a better way of doing this?
Thanks,
Mark
|
|
|
|
|
Well, if you are sure of what you´re thread is doing at the moment when you kill it, use TerminateThread ...
~RaGE();
|
|
|
|
|
I believe TerminateThread is never recommended to use. You can try PostQuitMessage.
Best regards,
Alexandru Savescu
|
|
|
|
|
Deleting pMyThread is OK assuming that thread has finished its execution and m_bAutoDelete was set to false.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
since i pass a vector in my program i get the following message when compiling...
d:\apps\microsoft visual studio\vc98\include\xtree(396): see reference to function template instantiation 'void _Distance const_iter,const_iter,unsigned int &)' being compiled
or without stl - message - decryption:
D:\shista.cpp(1918) : see reference to class template instantiation 'std::pair<class std::_Tree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::cha
r_traits<char>,class std::allocator<char> >,struct std::set<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char
> > >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >::_Kfn,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::alloca
tor<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >::iterator,bool>' being compiled
can i savely ignore this ?? (like i do right now).. or what the hell is this about..
thanks in advance..
bernhard
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
Yes, you can safely ignore this. And if you turn to level 4 you will get hundreads of messages like this. However they fixed that in VC 7.
Best regards,
Alexandru Savescu
|
|
|
|
|
since i am using stl i've quit using level4 altough in general it is very informative..
btw.. can you explain me what this message wants me to say ?
thanks in advance
bernhard
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
Is it the only line of warning? Normally I see something above and something below the line of the warning that explains it.
|
|
|
|
|
Hello all,
I have drawn some stuff on my view [Those who have been following my GDI threads would know I am trying to decode a funny image format]
Well now I have sorta decoded it and I wanna save it as a bitmap.
Any help is hugely appreciated!
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
if i want to look at the actual code behind something like CEdit, how do i look at the actual code of that class? the way i have been doing it is deriving a class from it and then looking at the base class functions.. i know there has to be another way right?
p.s. im using .net
thanks!
-dz
|
|
|
|
|
%Program Files%\Microsoft Visual Studio.NET\Vc7\atlmfc\src\mfc
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
hrm.. no easy browser tho eh? i see the filenames aren't exactly descriptive.. i tried doing a text search in the folder for CEdit, but of the 4 files it returned none really seemed like the right thing.. im just using CEdit as an example tho.. thanks for the info!
-dz
|
|
|
|
|
The files are AfxWin.h, AfxCmn.inl, AfxWin2.inl, WinCtrl1.cpp. They containt the declaration of the class and the implementation. What exactly are you looking for.
Best regards,
Alexandru Savescu
|
|
|
|
|
CEdit inherits from CWnd, you might need to look at the CWnd source code too.
Michael
Errata 1: p. 154, section 'Defusing'. For 'red wire' read 'blue wire'.
|
|
|
|
|
You have the following browsing options in vs.net:
1) Object Browser - in View|Other Windows. This window also opens when you select 'Browse definition' from context menu invoked on class name in ClassView
2) You can open mfc.bsc file using File|Open, this will show the complete hierarchy in Object Browser window. mfc.bsc is in vc7\atlmfc\src\mfc
3) ClassView displays 'Base classes and Interfaces' for each class in your project. Just expand it and you'll see base class --and-- its base classes as well, so you'll be able to drill down from CYourEdit through CEdit, CWnd, CCmdTarget to CObject
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
CoInitialize(NULL);
ISimplePgpPtr p(__uuidof(SimplePgp));
p->EncryptFile("d:\\in.txt","d:\\a90.pgp","test@test.com");
p.Release();
CoUninitialize();
Notice how I am calling Release()
My question is this. If it's a smart pointer shouldn't it automatically call Release() in its destructor?
Nish
p.s. I tried leaving out the call to Release() and it crashed
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
because you called CoUninitialize which happens before the smart pointer falls off the stack and has it's destructor called
try this:
CoInitialize(NULL);
{
ISimplePgpPtr p(__uuidof(SimplePgp));
p->EncryptFile("d:\\in.txt","d:\\a90.pgp","test@test.com");
p.Release();
}
CoUninitialize();
|
|
|
|
|
Jim Crafton wrote:
CoInitialize(NULL);
{
ISimplePgpPtr p(__uuidof(SimplePgp));
p->EncryptFile("d:\\in.txt","d:\\a90.pgp","test@test.com");
p.Release();
}
CoUninitialize();
Thanks. That worked even when I commented out the call to Release()
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Making it a statement block (enclosed in braces { }) forces the code to execute as a block and clean up after itself.
|
|
|
|
|
First of all, Thanks to Rama, Mazy and Jason.
Here is my code now. It works by the way
ISimplePgpPtr p(__uuidof(SimplePgp));
p->EncryptFile("d:\\in.txt","d:\\a90.pgp","test@test.com");
p.Release();
CoUninitialize();
Now this is my problem. I am puzzled by the behavior of p.
When I hit a . after p and when I type a -> after p I get different drop downs from intellisense.
Can someone clear all this up?
I tried a . instead of -> for the EncryptFile but got a compile error!
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
The . shows the member of _com_ptr_t class. this class has the -> operator overloaded, which shows you the member of ISimplePgp class.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
Michel Prévost wrote:
The . shows the member of _com_ptr_t class. this class has the -> operator overloaded, which shows you the member of ISimplePgp class.
Thanks Michel. Makes sense now
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Michel is right it's just overloaded.
Extra info.
I finished a Design Patterns class last semester and the overloaded operator -> was given as an example. It's a Proxy design pattern. If you're interested here's a link.
Houston Design Patterns [same page]
It's in the Structural Patterns. Check out the C++ demo for Proxy design pattern. When you get to the source I believe it's the 3rd example.
nay
|
|
|
|
|
Hello, CPians, I have an MFC SDI application, and I want to access to CMyView from CMyApp::InitInstance(), how can I get it?
Thanks a lot in advance!
|
|
|
|
|
lucy wrote:
I want to access to CMyView from CMyApp::InitInstance(),
Have you created your main frame window? If so you can call GetActiveView on the main frame pointer.
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|