|
Hi all,
I'm wondering is there an API that could be used to test for whether a thread has ended(signaled in other words). WaitForSingleObject is blocking wait for the thread to signaled, but I want nonblocking wait.
Thanks,
|
|
|
|
|
reading the documentation on WaitForSingleObject would not be a waste of time.
|
|
|
|
|
Yeah, you're right, I should have read it with more attention. My bad!
IGNORE(#define IGNORE 0) should be used instead of INFINITE.
Thanks!
|
|
|
|
|
You can use the GetExitCodeThread() function. If the thread has not ended, the the termination status returned is STILL_ACTIVE.
|
|
|
|
|
Thanks! I think that works too!
|
|
|
|
|
From MSDN:
Therefore, an application should not use STILL_ACTIVE (259) as an error code. If a thread happens to return STILL_ACTIVE (259) as an error code, applications that test for this value could interpret it to mean that the thread is still running and continue to test for the completion of the thread after the thread has terminated, which could put the application into an infinite loop.
It's best to avoid GetExitCodeThread for this purpose (checking if a thread has finished) IMHO.
Steve
|
|
|
|
|
I have developed an application using MFC. It has been brought to my attention that when the application is opened repeatedly, the FormView screen gradually moves across and down the screen. How do I fix the position of the FormView display?
|
|
|
|
|
In the application's main window class, add a handler for WM_CREATE.
In OnCreate(), you can use MoveWindow() to resize/reposition the window
the way you want it. You could store the size and position in the registry
or some other place so the window always opens the way the user last left it.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Developers,
I am writing a template class. In template class - class is declared and defined in the same header file..i.e. there is no need to include .cpp file.
So when i first declare the class and then define it within the same header file and include it in a test (Main) file. Then i get this many LNK2019 error
Whereas if i directly define the class without first declaring it then it works perfectly fine. or if i remove the test (main) file then also i do not get any LNK2019 error. What could be the problem here ?
Any help would be greatly appreciated.
Ta
James
|
|
|
|
|
I tried the same thing but didn't got any error. Thus, if you can please share the code snippet, we may provide some inputs.
|
|
|
|
|
I use ::new and ::delete to alloc and dealloc GDI+ objects in vc6,
because of DEBUG_NEW. Will there be any problem?
modified on Sunday, December 16, 2007 12:52:18 PM
|
|
|
|
|
followait wrote: I use ::new and ::delete to alloc and dealloc GDI+ objects in vc6,
because of DEBUG_NEW
I don't understand the rationale behind this.
Could you explain?
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.
|
|
|
|
|
There will at least be a problem if you use any GDI+
methods that return pointers to newly allocated objects
(e.g. Graphics::FromHDC()). Those pointers shouldn't be deleted
with ::delete for sure.
It may be safe to use ::new and ::delete, but I personally wouldn't.
To ensure GDI+ is using its new operator, and still use DEBUG_NEW,
you can wrap your GDI+ "new" calls something like this:
#pragma push_macro("new")
#undef new
CClientDC dc(this);
Graphics *pGraphics = new Graphics(dc); <font color="#008800">
#pragma pop_macro("new")
Mark
Mark Salsbery
Microsoft MVP - Visual C++
modified on Sunday, December 16, 2007 2:00:01 PM
|
|
|
|
|
Thanks for your help before; however, the indicated page http://msdn2.microsoft.com/en-us/library/bwea7by5%28VS.80%29.aspx was not very clear. Basically:
If in my computer is an image file C:\diving\scubadiver.jpg
how would I tell Windows (without using class modes) to read in this image from the file and store it as plain decoded bits in an HBITMAP object whose handle is 'imagehandle'?
Ditto to write a bitmap image object to a file in .JPG mode, and how to specify the image quality parameter?
Ditto .GIF etc?
|
|
|
|
|
Anthony Appleyard wrote: Thanks for your help before; however, the indicated page http://msdn2.microsoft.com/en-us/library/bwea7by5%28VS.80%29.aspx was not very clear.
That is MFC.
Anthony Appleyard wrote: If in my computer is an image file C:\diving\scubadiver.jpg
how would I tell Windows (without using class modes) to read in this image from the file and store it as plain decoded bits in an HBITMAP object whose handle is 'imagehandle'?
I think there is no Win32 direct support for loading JEPG images. You can either search for a free JPEG library or use GDI+ (whose class Bitmap is able to load a JPEG and to return an HBITMAP ).
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.
|
|
|
|
|
Please, what is GDI+ and where do I get it and use it?
|
|
|
|
|
Windows Vista must be able to read JPG images, because its directory explorer can display thumbnails of them and say their image widths and heights.
|
|
|
|
|
Anthony Appleyard wrote: Windows Vista must be able to read JPG images
Of course.
I'm also quite sure that Vista is able to do a lot of other things.
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.
|
|
|
|
|
Specially if you know how to get ride of them :P
But atm... all what I have heard about Vista is not nice at all.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Nelek wrote: But atm... all what I have heard about Vista is not nice at all.
Oops, is the same that I heard about.
Maybe we have the same informer?
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.
|
|
|
|
|
It comes with the OS, starting with XP, and can also be
installed on OSs back to 98...
GDI+[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
See CXImage article on the codeproject I think it will be helpful for you.
|
|
|
|
|
Hello everyone,
In a class T, if there is a conversion opeator G, we always define it like this,
operator G()
without return type. So the implicit return type is G or G&? I can not find it in the C++ programming language book.
thanks in advance,
George
|
|
|
|
|
George_George wrote: In a class T, if there is a conversion opeator G, we always define it like this,
operator G()
The above is not true, you can do, as well
operator G &(){...}
of course the return type will be G in the former case, G& in the latter one.
BTW what book have you?
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.
|
|
|
|