|
Haven't you tried CreateThread[^].
But be careful to terminate thread. For that you can see this[^].
Do not trust a computer...
Always check what computer is doing
regards,
Divyang Mithaiwala
Software Engineer
|
|
|
|
|
I am using MFC.I think I should not use createThread.
|
|
|
|
|
You can use createThread method.There is no matter of MFC.
Do not trust a computer...
Always check what computer is doing
regards,
Divyang Mithaiwala
Software Engineer
|
|
|
|
|
Divyang Mithaiwala wrote: You can use createThread method.There is no matter of MFC.
Actually, there is. Please read the docs[^]
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: Actually, there is. Please read the docs[^]
Good reference
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
You are correct, you should NOT be using the CreateThread()[^] Win API version if you are using MFC (Again, look at the remarks section of CWinThread class to know why).
But, if you want that kind of functionality (which you may need with UI threads), you can then create a CMyThread object and then call CMyThread::CreateThread() when you want the thread to start execution. (CMyThread is a CWinThread derivative.)
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
hemlat wrote: UINT CTestcycleDlg::pfnThreadProc(LPVOID pParam )
Your method which will work as thread & belong to class then it must be define static . But is method is not belong to any class then it is no matter to have static.
hemlat wrote: AfxBeginThread( CRuntimeClass* pfnThreadProc,LPVOID pParam,
When you pass pointer/name of method use CTestcycleDlg::pfnThreadProc .
I hope this will work for your code.
Do not trust a computer...
Always check what computer is doing
regards,
Divyang Mithaiwala
Software Engineer
|
|
|
|
|
Here is an UI thread tutorial: UI threads[^]
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
hemlat wrote: AfxBeginThread( CRuntimeClass* pfnThreadProc,LPVOID pParam, int nPriority = THREAD_PRIORITY_NORMAL,UINT nStackSize = 0, DWORD dwCreateFlags = 0,LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL);
What is this? Are you trying to call AfxBeginThread() , or just duplicate the prototype?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Actually I dont know how to create thread.I have tried with above code.I am seaching the code for thread creation.
|
|
|
|
|
hemlat wrote: I am seaching the code for thread creation.
Quote Selected Text
Still?! Are you kidding me?
I gave you link to an excellent UI thread tutorial yesterday. Did you read it or not? Why are you "searching" for code, BTW? You're supposed to write code if you are a programmer of any kind.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Thanks for your reply.Just now I have started working.Morning I was busy with some other task.Just I replyed to his message he was asking me what I was doing.I started working on Link which u hv sent.
|
|
|
|
|
I need to create worker thread.Because I need to put my functionality in thread function. Can you suggest any link which will show how to create worker thread
|
|
|
|
|
Bookmark the MVP Tips[^] page. There's plenty of good essays there.
Look for "Using Worker Threads" essay for your purpose.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
thanks for your reply.I have created thread.I got article in Codeproject.Sorry for late
reply.
|
|
|
|
|
hemlat wrote: Can you suggest any link which will show how to create worker thread
Did you even bother to read the article that Rajesh provided? If you had, you would have noticied a link to this.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
hemlat wrote: UINT CTestcycleDlg::pfnThreadProc(LPVOID pParam )
i think you forget to make function static
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hello,
I am dealing with a problem and I would need your help.
I have two top most windows, and i want to always have one of the windows in front of the other. The solution that makes one of the windows a child of the other cannot be applied in my case.
Thank you for your help.
|
|
|
|
|
You could use the topmost style (See SetWindowPos) for the Upper window, but it's not a very scalable solution (2 works, 3 would not)
I'd have another look to see why making one a child of the other would not work first before you kludge it.
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Thank you Iain for your answer. The solution with one child of the other works perfectly, but the reason why i was searching for another solution was that the number of windows involved isn't in fact 2, it could be bigger, so i will need to change dinamically the parent of my "upper" window. You said to use the topmost style, both of the windows are made TopMost using the SetWindowPos method. You mean maybe the WS_TOPMOST style.
|
|
|
|
|
I meant ::SetWindowPos (hWnd, HWND_TOPMOST, ...), but was being sloppy about it.
If it's N, then you'll have to get over your aversion to windows being children of other windows...
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
OK, thank you, i guess i will have to try to solve it this way
|
|
|
|
|
Hi,
I have some powerpoint addins which are to be added to powerpoint programmatically.The problem in the below code is it always says power application object cannot be created while running the program. but powerpoint application object will create during debugging the program.
hence I am not able to figure out the problem. Could any one help me please?
void InstallPptAddins(LPCTSTR strAddinPath)
{
CFileFind m_fileFind;
CString strAddin;
PowerPoint::_Application Ppt;
PowerPoint::AddIns m_pptAddIns;
PowerPoint::AddIn m_pptAddIn;
if(!Ppt.CreateDispatch("PowerPoint.Application"))
{
Log("Error:fn::InstallPptAddins() Couldn't open Powerpoint Application\n");
return;
}
try
{
if(Ppt.GetVersion()=="12.0")
{
PowerPoint::Presentations m_Sets(Ppt.GetPresentations());
PowerPoint::_Presentation m_Set(m_Sets.Add(TRUE));
strAddin = strAddinPath;
strAddin += "DSAFO5PP.ppa";
if(m_fileFind.FindFile(strAddin))
{
m_pptAddIns = Ppt.GetAddIns();
m_pptAddIn = m_pptAddIns.Add(strAddin);
m_pptAddIn.SetLoaded(FALSE);
m_pptAddIn.SetAutoLoad(FALSE);
m_pptAddIn.SetRegistered(FALSE);
m_pptAddIn.SetLoaded(TRUE);
m_pptAddIn.SetAutoLoad(TRUE);
m_pptAddIn.SetRegistered(TRUE);
Log("AFO Powerpoint add-in is added.\n");
}
else
Log("Couldn't find Powerpoint add-in %s\n",strAddin);
}
catch(...)
{
Log("Error::Couldn't install Powerpoint add-ins.Please add it manually\n\n");
}
Ppt.Quit();
}
|
|
|
|
|
missing closing curly braces for
if(Ppt.GetVersion()=="12.0")
{
|
|
|
|
|
may be missed out during caopying the code.It is proper on my machine.But that is not the reason.It is compiling with no error.
|
|
|
|