|
Use _beginthreadex instead. The CreateThread function don't initialize the CRT (C-RunTime, not Cathodic Ray Tube correctly, so this might be your problem.
Michel
If I am wrong or said something stupid, I apologize in advance
|
|
|
|
|
** OK, let's assume I don't use cout, but printf instead **
How do I use the Visual Studios so I can trace into my thread function?
|
|
|
|
|
Just set a break point in your thread routine.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I did that. It didn't go into the thread function.
|
|
|
|
|
Strange, very strange...
Maybe someone else has seen this before. Like you, since it created the handle, the thread was at least started. I would have expected some type of dialog box if it tossed an exception.
When you call CreateThread, are you having to do any type casting to get the routine to accept your routine?
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
This is my code:
DWORD WINAPI StreamHandler(LPVOID lpParam)
{
//Thread function code
printf("I am in the thread\n");
}
//Create TCP/IP Thread
sThread = CreateThread(NULL,0,StreamHandler,NULL,0,&sThreadID);
if (sThread == NULL)
cout << "Create Stream Thread Failed\n";
else
CloseHandle(sThread);
It's pretty simple, I don't know why it doesn't execute.
|
|
|
|
|
Something else is going on. I just tried that code and it worked just fine.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Hmm, are you exiting your program right after the create thread?
If so, then your thread probably doesn't even have the chance to execute.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
And where is the Wait... call here?
I vote pro drink
|
|
|
|
|
That is what I realized too. Hopefully there is more to the program than just those lines.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Yes, but he called CloseHandle right after creating the thread
I vote pro drink
|
|
|
|
|
It doesn't stop the thread. I found much evidence on groups.google.com that if you don't care about syncing on the handle, then closing it right after creation is very common.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I do end the program after I create the thread what do I do to give it time to execute? No one mentioned this when I was reading up on threads...
What should I do put a sleep in?
|
|
|
|
|
Did that work for you? I received some kind of memory leak... Does this sound familiar?
|
|
|
|
|
cout , printf , same sh*t. As a matter of fact, cout uses printf to perform its job (or at least fome function from stdio.h .
Michel
If I am wrong or said something stupid, I apologize in advance
|
|
|
|
|
Just forget CreateThread, and use _beginthreadex instead.
I vote pro drink
|
|
|
|
|
Do as he said.
Michel
If I am wrong or said something stupid, I apologize in advance
|
|
|
|
|
Hi!
I want to try and override OnPaint() of my tree ctrl. I have never done tried redrawing myself before and is new to me. Could anyone please tell me all the things that has to be taken care of while doing this? If there is site somewhere for beginners with this, do let me know.
NC
|
|
|
|
|
Are you *really* going to draw tree control yourself? The lines, +/- buttons, icons, text?
If not, you may consider custom-draw, which allows you to draw only selected parts.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
Hi!
Thanks for writing back.
This is what I want to do. I am not sure what to use - custom draw or owner draw. Maybe you can tell me what is best.
I don't have the +/- signs in my tree. I have an image list associated with the tree. Some items have icons and some don't. For those items with icons, I want to display the icon and the text a few pixels right to where the tree ctrl draws it, basically indent further.
Any ideas on how to do this?
NC
|
|
|
|
|
So all you need is extra indentation for tree items? Or you just want to display something in this extra space?
Anyway, go with custom-draw. There's no owner-draw for tree controls; you'd have to paint everything yourselft; in such case why would you need the tree control? Just for item storage?
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
Hi!
Thanks again!
Yes, all I need is extra indentation for some items.
I tried custom draw, and got the item text to be indented. But the icon is shown at the same place as it was before. And I am not sure how to redraw the icon. This is where I am struck at, right now.
How can I redraw the icon?
Thanks,
NC
|
|
|
|
|
NC wrote:
Yes, all I need is extra indentation for some items.
The extra indentation is always identical? Or varies between items?
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
Hi!
It has to be x + the current indentation. So, basically for items with icons, I need to get the current indentation of the item with respect to its parent(which is fine) and add a constant to it and indent by that much. This constant is same for all items.
Thanks,
NC
|
|
|
|
|
Before continuing with custom-draw (CTreeCtrl::GetImageList and CImageList::Draw will greatly help there) consider using item state images. Each item can have two icons; if you'll have empty state icon you can use it as simulated indent.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|