|
The CTime object doesn't have a CString constructor. So you will need to do the following:
<br />
CString strTime = "13:30";
CTime tm = CTime(1970, 1, 1, atoi(strTime.Left(2)), atoi(strTime.Right(2)), 1);<br />
I haven't tested this, so let me know if it works ...
Dylan Kenneally
London, UK
|
|
|
|
|
Thanx for the help..
It worked..
|
|
|
|
|
HI All,
Im using Microsoft SAPI Speech development etc etc...
Having a big prob, im watching for Viseme events,
switch(eventItem.eEventId )
{
case SPEI_VISEME :
What do I put next to identify which viseme it is??
Cheers to you all
ADam
|
|
|
|
|
Hi,
i use Vc++6.0, i have a doc/view project and i have a problem with thread synchronization, here is my code :
void CMyAppView::OnStart()
{
...
HANDLE hThreads[12];
....
for(int i=0;i<=Range;i++)
{
int handl=0;// used to increment Handles table index
if (m_sc.m_b1)
{
m_nThreadsNbr += 2;
m_pThread1 = (CThread1*)AfxBeginThread(RUNTIME_CLASS(CThread1), THREAD_PRIORITY_NORMAL, 0, 0);
m_p31Thread->SetOwner(this);
hThreads[handl++] = m_p31Thread->m_hThread;
m_pThread = (CThread*)AfxBeginThread(RUNTIME_CLASS(CThread), THREAD_PRIORITY_NORMAL, 0, 0);
m_pThread->SetOwner(this);
hThreads[handl++] = m_pThread->m_hThread;
}//if
if (m_sc.m_b2)
{
m_nThreadsNbr += 2;
m_pThread2 = (CThread2*)AfxBeginThread(RUNTIME_CLASS(CThread2), THREAD_PRIORITY_NORMAL, 0, 0);
m_pThread2->SetOwner(this);
hThreads[handl++] = m_pThread2->m_hThread;
m_pThread = (CThread*)AfxBeginThread(RUNTIME_CLASS(CThread), THREAD_PRIORITY_NORMAL, 0, 0);
m_pThread->SetOwner(this);
hThreads[handl++] = m_pThread->m_hThread;
}//if
DWORD dw = WaitForMultipleObjects(m_nThreadsNbr, hThreads, TRUE, 5000);
switch (dw) {
case WAIT_FAILED: // Bad call to function (invalid handle?)
AfxMessageBox("Wait failed");
break;
case WAIT_TIMEOUT: // None of the objects became signaled within 5000 milliseconds.
AfxMessageBox("None of the objects became signaled");
break;
case WAIT_OBJECT_0 + 0: // The process identified by hThread[0] terminated.
AfxMessageBox("thread 1 terminated");
break;
case WAIT_OBJECT_0 + 1: // The process identified by hThread[1]terminated.
AfxMessageBox("thread 2 terminated");
break;
case WAIT_OBJECT_0 + 2: // The process identified by hThread[2] terminated.
AfxMessageBox(" thrread3 terminated");
break;
}//switch
}//for
All my threads are UI threads
thread1 and thread 2 are synchronized by a mutex .i.e :
CThread1::Run()
{
CSingleLock sLock(&(m_pOwner->m_mutex));
sLock.Lock();
......
sLock.Unlock();
}
CThread2::Run()
{
CSingleLock sLock(&(m_pOwner->m_mutex));
sLock.Lock();
......
sLock.Unlock();
}
CThread::Run()
{
CSingleLock sLock(&(m_pOwner->m_mutex2));
//becarefull it is another mutex object m_mutex2
sLock.Lock();
......
sLock.Unlock();
}
The PROBLEM is that WaitForMultipleObject return WAIT_FAILED or WAIT_TIMEOUT, but i am sure that the threads terminate within 5000 ms, if a make an INFINITE timeout my application remain Busy.
Can u help me ?
Thank's.
|
|
|
|
|
Have you checked what GetLastError() returns?
/Magnus
|
|
|
|
|
|
To see what the reason is that it returns WAIT_FAILED.
/Magnus
|
|
|
|
|
kortebi wrote:
The PROBLEM is that WaitForMultipleObject return WAIT_FAILED or WAIT_TIMEOUT, but i am sure that the threads terminate within 5000 ms, if a make an INFINITE timeout my application remain Busy.
They can't have terminated within 5 seconds because if they have then using INFINITE wouldn't hang on WaitForMultipleObjects().
UI threads are a pain the behind in MFC and you can easily get into a deadlock. Have you tried #ifdefing out all of the code inside the thread functions and see if WaitForMultipleObjects() behaves as you expect?
Also add TRACE statements at the end of the thread functions so you can see when they finish.
Threads in MFC are the bain of my life.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Neville Franks wrote:
Also add TRACE statements at the end of the thread functions so you can see when they finish.
I did it.
|
|
|
|
|
m_pThread1 = (CThread1*)AfxBeginThread(RUNTIME_CLASS(CThread1), THREAD_PRIORITY_NORMAL, 0, 0);
m_p31Thread->SetOwner(this);
hThreads[handl++] = m_p31Thread->m_hThread; Seems like you're launching the thread m_pThread1 but yet it is m_p31Thread 's handle that is inserted into hThreads (and possibly this handle is invalid at the time of insertion.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Nicely spotted Joaquín. I must say that I found the reuse of m_pThread confusing. Looks like it should be a class member at all. And he shouldn't be using old style C casts.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Within your for loop you increment the m_nThreadsNbr with two every time
you start two threads. This should work for the first iteration but during your second iteration the value of m_nThreadsNbr is the number of threads started during BOTH iterations but the handle array only contains the thread handles from the last iteration.
Replace the
DWORD dw = WaitForMultipleObjects(m_nThreadsNbr, hThreads, TRUE, 5000);
with
DWORD dw = WaitForMultipleObjects(handl, hThreads, TRUE, 5000);
or reset the m_nThreadsNbr to zero in the begining of the for iteration.
In your switch you test the return value from WaitForMultipleObjects against
WAIT_OBJECT_0 + 0, WAIT_OBJECT_0 + 1 and WAIT_OBJECT_0 + 2 in order to see which thread that has terminated BUT when you call the WaitForMultipleObjects you set the bWaitForAll parameter to TRUE which will result in that when WaitForMultipleObjects returns WAIT_OBJECT_0 this means that all threads are terminated. WAIT_OBJECT_0 + 1 and WAIT_OBJECT_0 + 2 will never be returned from WaitForMultipleObjects as long as bWaitForAll is TRUE.
|
|
|
|
|
I want to know what's the type of a MSOffice file (Word, Excel, Access, PowerPoint, ...). How can i do ?
Thanks.
Aziz Rajim
|
|
|
|
|
They have their own file formats, different from one another. There is some stuff on CP, I know Excel exposes it's via COM to allow some work with it, I believe it includes loading & saving.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
you'll need to get at the underlying com objects
which one ar eyou wanting to get at?
bryce
|
|
|
|
|
Hi,
My application run Ms Word Automated and then I insert some data there, the main problem comes when I have to insert formated tables, then it goes damn slow, some minutes to generate a medium size table ( I guess if the user will type it manually faster XDDDDD ).
Is there any way to speed that process up ? ( I've tried disabling the output screen til it is finished, but that doesn´t help much ).
Is it better to use Adobe Acrobat format than Ms Word for real issues ?
Thanks in advance, Greetings
Braulio
|
|
|
|
|
The way to improve the performance (assuming your code is ok), is to reduce the number of calls you make to the Word object. Try inserting the text in one piece, convert it to a table, then format it.
Adobe and word do completely different things. They are certainly not interchangeable. If what you want to do can be done in Acrobat, Word is probably the wrong program. (and vice versa)
Hope this helps,
Bill
|
|
|
|
|
Thanks for the tip,
I will try to reduce the number of calls, and do it all as compact as possible.
I've been searching, and found two interesting things:
1. Instead of using Word, just do the tables using RTF ( not so pretty nice looking but...), copy it to the clipboard and paste it in the Word instance, that goes incredibly faster than the automation solution ( but is a pain in the ass to try to make pretty layouts with that... ).
2. I found one article that tells you the problems that has Word 200 with the tables, and some workarounds, you can find it in:
"Maximising the performance of Word tables" at
http://www.mvps.org/word/FAQs/TblsFldsFms/FastTables.htm
What I miss is a way to pass the table in XML format to Word, and then he could handle the XML data to convert it to the specific Table format of word.
Thanks for your help, greetings
Braulio
|
|
|
|
|
How can I change size of DateTimePicker Controls at runtime ?
These are not members of COleDateTime:
m_StartTime.GetClientRect( rect);
m_StartTime.MoveWindow( rect);
Cheers
Hans
|
|
|
|
|
I´d like to change window font styles at runtime. I created a dialog with a few DateTimePicker controls but I cannot change their fonts. All other controls ( ListBox etc. ) support this:
GetFont()->GetLogFont(&LogFont);
LogFont.lfHeight = 16;
NewFont.CreateFontIndirect(&LogFont);
// Set Font Size
m_MyControl.SetFont(&NewFont);
But what about DateTimePicker controls ?
Cheers
Hans
|
|
|
|
|
|
Hi Friends
I am writing a profile string using WriteProfileString , I can read it using getProfileString,
Problem is I want to know were it is written in system registry, Platfrom is windows 2000 server.
Thanks
Gau
Gaurika Wijeratne // www.gaurika.com //
|
|
|
|
|
I think:
HKEY_CURRENT_USER\Software\MyCompany\MyApp\Settings
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
I think this is correct:
HKEY_CURRENT_USER\Software\MyCompany\MyApp\Local AppWizard-Generated Applications
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
I've seen couple of messages here that discuss the VC.NET and Managed C++. What I understod I can't programm in VC.NET without using Managed C++??
I don't know a s*** about Managed C++ and don't know what it is too...
Will I survive VC.NET without any knowledge in Managed C++???
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|