|
Hi All,
I want to use PosstThreadMessage() function and i want to check if the thread handle is available before that, because sometimes the thread will be created and some times the the thread might not be created ...
So if the thread is not created i want the condition to fail ...
ex:
if( handle available)
{
ThreadPtr->PosstThreadMessage(MyMessage);
}
So can you tell me how to verify this .
Thanks..
Hari
|
|
|
|
|
And what happens when the thread finishes between checking for calling the CheckThreadAvailability and PostThreadMessage functions?
By it's nature such a function would be useless.
I think you need to go back to your more basic design to address this issue, rather than papering over the cracks.
With multithreading, you have to imagine that you are on a multi code spiteful processor. Anything bad that could possibly happen, will.
Keep track of the thread handles. Even when a thread finishes, the handle is still valid - you need to close it with CloseHandle too. (I think MFC will do that for you, but I don't touch MFC threading with a bargepole. I use Win32 exclusively - better documented).
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
You may use (with caveats suggested by the "Warrior Programmer") GetExitCodeThread function [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
hi,
I have to convert pdf file to tif file using C .would anyone help me providing source code .regards
Bill
|
|
|
|
|
No-one is going to give you a few lines of code to do this.
As you don't already realise this, you have a lot of learning / work ahead of you.
You need to find / pay for a pdf library that can render a PDF into a HDC.
Capture that HDC (which could be very large) into a bitmap.
Convert that bitmap into a tiff.
What about multipages? Maybe your pdf library can "print" one page at a time?
I hope that helps you with your google search terms. I know there are articles on CP for bitmap to tiff. And for simple PDF rendering.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
you can provide me code in c# also
|
|
|
|
|
Do you understand "gimme codez" doesn't work here, don't you?
Anyway, you may try: "gimme codez urgentz plz plz" or "gimme codez ASAP".
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
billcodes wrote: you can provide me code in c# also
That's extremely kind of you. My answer before was not dependent on language.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
I can haz cheeseburger?
Visual Studio is an excellent GUIIDE.
|
|
|
|
|
> As you don't already realise this, you have a lot of learning / work ahead of you.
>You need to find / pay for a pdf library that can render a PDF into a HDC.
Is it a joke ?
You should learn Win32 api, GDI+, and COM : ~25 lines of code...
|
|
|
|
|
If you are going to sledge people, you might at least take the time and trouble to sledge the right person.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
<br />
<br />
#include "stdafx.h"<br />
#include <iostream><br />
using namespace std;<br />
<br />
<br />
void copy_array(char from[], char to[])<br />
{<br />
int i = 0;<br />
while(from[i] != '\0')<br />
{<br />
to[i] = from[i];<br />
i++; <br />
}<br />
to[i] = '\0';<br />
}<br />
<br />
<br />
void copy_pointer(char *from, char *to)<br />
{<br />
while((*to++ = *from++) != '\0');<br />
}<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
char *from = "c plus plus";<br />
char *to = "oooooooooooooooo";<br />
copy_pointer(from, to);
<br />
cout << to << endl;<br />
<br />
return 0;<br />
}<br />
|
|
|
|
|
Any idea what's the problem in the following code?
int main()
{
char* str = "Hello";
str[0] = 'Y';
cout<<str;
return 0;
}
|
|
|
|
|
theCPkid wrote: Any idea what's the problem in the following code?
Apart from the fact that it will print "Yello" , nothing.
|
|
|
|
|
have you really tried it? i have the feeling that you will get write access error...
|
|
|
|
|
theCPkid wrote: i have the feeling that you will get write access error...
Yes, you're right; my apologies.
|
|
|
|
|
Loveprogramer wrote: char *from = "c plus plus";
char *to = "oooooooooooooooo";
Here "from" and "to" are constant strings exactly, so the codes below would be mistake.
"*to++ = *from++".
If you declare "from" and "to" as array of string, your program would work fine.
Just like:
char from[] = "c plus cplus";
char to[] = "oooooooooooooooooooooo";
|
|
|
|
|
carter2000 wrote: Here "from" and "to" are constant strings exactly, so the codes below would be mistake.
Not true; declaring a string as char* str or char str[] yields the same result.
|
|
|
|
|
Maybe I made something wrong, but it just works fine in my computer. My compiler is VS2008.
|
|
|
|
|
foot - mouth - brain!
I must remember brain comes first.
|
|
|
|
|
I think the problem is probably in the following statement: while((*to++ = *from++) != '\0'); . The C++ language specification for the assignment operator states "The assignment operators return the value of the object specified by the left operand after the assignment." i.e the to pointer. Thus in the above statement the comparison is done with the next element of the to array, which being longer than the from array, contains the character 'o'. The while loop is now out of control as it is copying garbage. Rework your loop so that it tests the source array element for '\0', rather than the destination.
[EDIT]Sorry, I got this wrong, the result of the expression is to before it gets incremented, hence it is correct.[/EDIT]
modified on Monday, October 12, 2009 5:45 AM
|
|
|
|
|
Well, what have you discovered for yourself?
Does that copy_pointer loop die on the first time it does something?
When it hits a NULL?
Does it die if to is a dynamically created variable?
ie,
char *buf = new char [128];
copy_pointer (from, buf);
delete [] buf;
I'm 90% sure I know what's wrong, but I'll wait for you to run these tests and see if you can find out for yourself.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Try this
char from[] = "c plus plus";
char to[] = "oooooooooooooooo";
instead of
char *from = "c plus plus";
char *to = "oooooooooooooooo";
|
|
|
|
|
Hi all!
Why this Function (http://msdn.microsoft.com/it-it/library/dd758083%28en-us,VS.85%29.aspx) return always E_FAIL?
Example of use:
ULONG eat = 4;
pUI->ParsePropertyName(_T("Size"), &fmtid, &pid, &eat);
Return E_FAIL when have to return the FMTID/PID correspondent of Property...
Please Help!
|
|
|
|
|
What is the HRESULT value that is returned?
The return value will probably give you a better idea about what is wrong.
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++)
|
|
|
|