|
I have a problem. When I want to wait for a thread to finish processing, I use the WaitForSingleObject and pass it the handle to the thread I am waiting on. However, that thread never finishes, so my program just hangs. When I step through it in the debugger, it never seems to go into the function that I am waiting to finish, but I still have a handle to the thread, so I don't believe it has finished.
Any Ideas?
|
|
|
|
|
You have to set up some kind of singnalling system to tell your thread to finish. The usual way is to use an event, which your thread perodically checks and if its singaled, exits - something like this:
ThreadFun(LPVOID theEvent)
{
HANDLE hDie = (HANDLE)theEvent;
for(a long loop)
{
do some stuff
if(::WaitForSingleObject(hDie, 0) == WAIT_OBJECT_0)
break;
}
return 0;
}
Then in your main thread where you are doing WaitForSingleObject on the thread:
SetEvent(killTheThreadEvent);
WaitForSingleObject(hTheThreadsHandle, INFINITE);
The threads handle will still be valid even when the thread has died (until you do a CloseHandle on it). To dermin if it is running or dead do WaitForSingleObject passing in 0 as the timeout - if you get WAIT_OBJECT_0 its dead, or WAIT_TIMEOUT its still running. You can also use GetExitCodeThread which will give you STILL_ACTIVE if the thread is still running - though WaitForSingleObject is generally prefered.
|
|
|
|
|
Is there an existing function that can convert text to its associated phonemes? The text could be a single word or a paragraph.
Your help is appreciated.
|
|
|
|
|
|
Thank you very much Chiew Heng Wah! I spent half day yesterday searching on Google, but missed this. 
|
|
|
|
|
hi all really this site is so powerfull i mean it
well i want to capture an image from a camera the application is a dialog based application and i am using visual c++ 6.0 i wanna the view which camera get appear first and make the position nice then a button called capture when i clicked it it capture the image which in the view then open dialog for saving
Hope anyone help me by any ideas
thanks
Gego
|
|
|
|
|
Try the following CodeProject article by Blas5
Title: Capture Sample with DirectX and .NET
Link: http://www.codeproject.com/directx/CapSample1.asp
You should also read DirectShow documentation.
Also DirectX SDK has a sample program called StillCap.exe under <DXSDK Directory>\samples\Multimedia\DirectShow\bin
|
|
|
|
|
Thanks man for replaying but wanna another question
i have read some of the article but my question is to capture a picture from a camera did i have to use directshow and PLZ some introductin of the directshow
thanks again
Gego
|
|
|
|
|
Can I safely assume you are talking about a web-camera (webcam)?
The DirectShow examples in DirectX SDK should work with the web-cam. Codes are included.
Heng Wah.
|
|
|
|
|
Hi all
thanks alot for replaying anyway i got a piece code it talking about a thing called VFW
and yeah man it will be a web cam i have got the sdk of directx but wanna to know is it easy to link it to a visual c++6
thanks anyway
byebye for now
Gego
|
|
|
|
|
Hello, My name is jason.
I am trying to write a program that will track the times and the dates that an employee has worked. I know how to hard code it but, it is the gui that i am having a problem with. Here are my main problems. When the program starts i would like a password screen to appear, where the user or the manager enters her/his password. This part I have accomplished, the password screen. I have placed 9 buttons, when the user clicks on the buttons i record or add to a string, and when the user hits okay, i read the finished string and see if there is an employee. My problem is this, I need to have to different windows, one for a manager, and another for a employee. Meaning, if a manager comes along, types his password, i would like a window appearing where he has the option of looking how has clocked in, how many employees are currently working, total hours ans so forth. When a employee comes along, enters his/her password, i would like them to see when they have started, or if they have not punched in, a punch in button, or a punch out button and so forth..
If anyone could help me out, or give me advice on how to create those two different windows and how to interact or how to dynamilcly pop up those two windows depending on who is entering a password, i would be sooooo happy.
you can email me at jdogan@hotmail.com
none
|
|
|
|
|
Hi Jason how are U man
well man u will create dialogs as u wanna and after handle the button of the manager just inside its function call the dialog which u have make for the manager and in the employee case make a different dialog when the empolyee is chosen after inserting the username and his password call the dialog of the emoplyee and in the two dialogs the one for employees and one for manager make any interface u wanna to make ur times appears
hope that will solve ur problem if ok tell us and if no also tell u
bye now
Gego
|
|
|
|
|
modeonetwo wrote:
My problem is this, I need to have to different windows, one for a manager, and another for a employee.
Sounds like you need some sort of designator that denotes manager vs. non-manager. Are you looking in some sort of file/database to verify the user id and password are correct? If so, just add another field.
You would then need to create two dialog templates: one for managers, and one for non-managers. Then in your code, you could have something like:
DisplayLoginWindow();
if (login_type == manager)
{
CManagerDlg dlg;
dlg.DoModal()
}
else
{
CEmployeeDlg dlg;
dlg.DoModal()
} Make sense?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thank you both very much, that little bit of code makes a lot of sense, i was thinking of doing just that but did not know if it was possible or smart.. I will look into that and probably do that. Thank you soo much.
none
|
|
|
|
|
Using CSplitterWnd class
I’m trying to learn how to work with CSplitterWnd class.
I create a simple SDI application using MFC Application Wizard.
Classes created are:
CMySDIApp
CMySDIDoc
CMySDIView
CMainFrame
I want to have two different views for my document. For the second view, I add a new class to my project – CMySDIView2 class is derived from CView.
I want to have static splitter with two panes. I override OnCreateClient :
CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
CCreateContext* pContext)
{
// create a splitter with 1 row, 2 columns
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
// add the first splitter pane - the default view in column 0
if (!m_wndSplitter.CreateView(0, 0,
RUNTIME_CLASS(CMySDIView), CSize(0, 0), pContext))
{
TRACE0("Failed to create first pane\n");
return FALSE;
}
// add the second splitter pane - an input view in column 1
if (!m_wndSplitter.CreateView(0, 1,
RUNTIME_CLASS(CMySDIView2), CSize(0, 0), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
return TRUE;
}
When I build the project, I get two errors:
error C2653: 'CMySDIView' : is not a class or namespace name
//RUNTIME_CLASS(CMySDIView), CSize(0, 0), pContext))
error C2653: 'CMySDIView2' : is not a class or namespace name
//RUNTIME_CLASS(CMySDIView2), CSize(0, 0), pContext))
What am I doing wrong?
Thank you for your help!
|
|
|
|
|
In order for this to work, both of your view classes must support dynamic creation.
The macro 'DECLARE_DYNCREATE' or 'DECLARE_DYNAMIC' must be found at the start of both classes header files. The parameter for the macro is the class name.
Additionally, a macro 'IMPLEMENT_DYNCREATE' or 'IMPLEMENT_DYNAMIC' must be placed near the top of your implementation file (after the headers, but before function definitions). Parameters for this macro are the class name and the name of the base class.
See the MSDN for information about the differences between these macros.
If all macros are correctly placed in your files, then see if the error is caused by missing header files. Your main frame implementation file must have the header files of both view classes. Otherwise an error is generated.
In addition, the way you create the views is a bit dangerous. A more convinient way is to add the headers into the main frame header file, then create two member variables (either static or dynamic), one of each view class. After this, you can create the views, and specify the splitter window as the parent. Using 'CSplitterWnd::IdFromRowCol' allows you to get the identifier of the pane. When you put this identifier as the id of the newly created view window, the view gets placed into inside the pane.
If you use this technique, however, you must be certain that you destroy the views when your program is closing up. You must first destroy the view windows, then destroy the splitter window, and after this, if you used dynamic variables, you can delete the reserved memory.
There is an article in the works about this method. I'm not sure when it will be out, but I bet in the next few months or so..
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Antti Keskinen wrote:
If all macros are correctly placed in your files, then see if the error is caused by missing header files.
When I add header files of both view classes to the main frame implementation file, I get another error:
MySDI\MySDIView.h(17): error C2143: syntax error : missing ';' before '*'
- this one refers to the line: CMySDIDoc* GetDocument() const;
class CMySDIView : public CView
{
DECLARE_DYNCREATE(CMySDIView)
protected: // create from serialization only
CMySDIView();
// Attributes
public:
CMySDIDoc* GetDocument() const;
...............
and there are 3 more errors that are triggerred by the first one:
MySDI\MySDIView.h(17): error C2501: 'CMySDIView::CMySDIDoc' : missing storage-class or type specifiers
MySDI\MySDIView.h(17): error C2501: 'CMySDIView::GetDocument' : missing storage-class or type specifiers
MySDI\MySDIView.h(17): warning C4183: 'GetDocument': missing return type; assumed to be a member function returning 'int'
How can I fix this?
Thank you for you help!!!!
|
|
|
|
|
At the top of the MainFrm.cpp, you probably need something like:
#include "MainFrm.h"
#include "MySDIDoc.h"
#include "LeftPaneView.h"
#include "RightPaneView.h"
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
when I do this, I get the error I described above (please, see it in the third message in this thread)

|
|
|
|
|
The compiler is telling you that CMySDIDoc is being referenced before it has been declared.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I added
#include "MySDIDoc.h"
to the MySDIView.h file and it solved the problem.
Thank you!!!
|
|
|
|
|
I'm using a CHtmlView control and I want to store the content displayed in the control in a CString object or as a string. How do I go about it?
Thanks in advance,
Vikram.
Shameless plug: http://www.geocities.com/vpunathambekar
"And above all, watch with glittering eyes the world around you because the greatest secrets are always hidden in the most unlikely places. Those who don't believe in magic will never find it." - Roald Dahl.
Mrs. Schroedinger: "Erwin, what have you been doing to the cat? It looks half-dead!"
|
|
|
|
|
|
How?
I get an error saying GetSource is not a member of this class. And MSDN says GetSource belongs to IErrorInfo.
Am I completely missing the point?
Vikram.
Shameless plug: http://www.geocities.com/vpunathambekar
"And above all, watch with glittering eyes the world around you because the greatest secrets are always hidden in the most unlikely places. Those who don't believe in magic will never find it." - Roald Dahl.
Mrs. Schroedinger: "Erwin, what have you been doing to the cat? It looks half-dead!"
|
|
|
|
|
Sorry, they added that API in VC7. This[^] link may help. Unfortunately Ehsan's articles[^] aren't available because the site is currently down.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|