|
Is there a way to trim part of the string?
(I want to read part of the string and then trim that part..)
For instance,after I find where the ":" is located, I want to trim the right most part of the string, and so forth for the other parts of the string...
|
|
|
|
|
SWDevil wrote: For instance,after I find where the ":" is located, I want to trim the right most part of the string...
CString str = "00:11.2";
int nIndex = str.Find(':');
str = str.Left(nIndex);
or
str = str.Mid(0, nIndex + 1);
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
sscanf(...) and its variants were designed for that kind of thing...
Read up on them to see how easy it would be to extract the components of the string.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hi All,
The problem I seem to be having is that events seem to be disappearing (i.e. no-one gets them). I have essentially 3 threads in a console application. The "control" class creates a number of events like:
m_stSyncEvents.m_hSyncRxStart = ::CreateEvent (NULL, FALSE, FALSE, NULL);
Later on, the code creates two threads. These threads then do a ::SetEvent (m_stSyncEvents.m_hSyncRxStart) when they finished their initialisation. The threads themselves have a common thead function and use the fastdelegate code to call back into the class. After the threads are created I do a:
::WaitForMultipleObjects (2, ahThreadSync, TRUE, INFINITE);
with ahThreadSync being handles to the event handles per thread.
The problem now comes that the second task that is created is not sending events or receiving them 100%. 2 /10 times it works perfectly. However the other times, the second thread does not send the event (but SetEvent is not failing) or it does not receive the abort event from the control class, which is created in a similar way except it is in manual reset mode. In each case the thread is running.
Any Ideas??
regards,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
Are you suggesting BOTH of the 'alternate' threads are each setting m_stSyncEvents.m_hSyncRxStart? If so, you need two separate events. Each of those worker threads should set its own private event, and the waiting thread needs to wait on both of those separate events.
I would also have each thread own it own abort event.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
Blake Miller wrote: Are you suggesting BOTH of the 'alternate' threads are each setting m_stSyncEvents.m_hSyncRxStart?
No. Each thread has its own event. There is a separate event created per thread object.
Blake Miller wrote: I would also have each thread own it own abort event.
The design was for a simplified exit mechanism. The threads wait on multiple events depending on what it is currently upto. Having a single 'abort' event that could trigger all threads to exit, was the reason for this.
"Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
if a error occur in a function ,return false or handle it inside of function.
for example:
void fun()
{
bool isFail = openfile(...);
if(isFail)
{
::MessageBox(0,"open file fail",0,0);
exit(0);
}
}
bool fun()
{
bool isFail = openfile(...);
if(isFail)
{
return false;
}
........
return true;
}
|
|
|
|
|
|
sorry ,the question :
which error handle is right and commmon?
|
|
|
|
|
I wrappered a class to play video using DirectShow, almost following the sample "playwnd", but i found it cannot destroy the media window by the destructor, unless I destroy the parent window. I checked the state of the player window, it was stopped, but I could still saw it was running after the destructor invoked... Following list the destructor, what is the problem?
<br />
CMediaPlay::~CMediaPlay(void) {<br />
HRESULT hr;<br />
<br />
if (m_pMediaControl)<br />
{<br />
LIF( m_pMediaControl->Stop());<br />
OAFilterState fs;<br />
LIF( m_pMediaControl->GetState(200L, &fs));<br />
if (fs == State_Stopped)<br />
Msg(_T("Successfully stopped the filter run"));<br />
}<br />
<br />
if(m_pVideoWindow)<br />
{<br />
LIF(m_pVideoWindow->put_Visible(OAFALSE));<br />
LIF(m_pVideoWindow->put_Owner(NULL));<br />
}<br />
<br />
if (m_pMediaEventEx)<br />
LIF(m_pMediaEventEx->SetNotifyWindow((OAHWND)NULL, 0, 0));<br />
<br />
#ifdef REGISTER_FILTERGRAPH<br />
if (g_dwGraphRegister)<br />
{<br />
RemoveGraphFromRot(g_dwGraphRegister);<br />
g_dwGraphRegister = 0;<br />
}<br />
#endif<br />
<br />
SAFE_RELEASE(m_pFileSource );<br />
SAFE_RELEASE(m_pVideoDecoder );<br />
SAFE_RELEASE(m_pAVISplitter );<br />
SAFE_RELEASE(m_pSourceReader );<br />
<br />
SAFE_RELEASE(m_pMediaEventEx );<br />
SAFE_RELEASE(m_pMediaSeeking );<br />
SAFE_RELEASE(m_pVideoFrameStep );<br />
SAFE_RELEASE(m_pMediaControl );<br />
SAFE_RELEASE(m_pBasicAudio );<br />
SAFE_RELEASE(m_pBasicVideo );<br />
SAFE_RELEASE(m_pVideoWindow );<br />
SAFE_RELEASE(m_pGraphBuilder );<br />
}<br />
<font=sans-serif>|-|3llo Wo|2ld
|
|
|
|
|
My application was developed under Visual C++ 6.0, ATL, MFC & PlatformSDK Feb2003 (the last VC6 compatible version).
I am wondering if PlatformSDK Feb2003 is compatible with Visual Studio.NET 2003? I am having major problems trying to port/build my application under Visual Studio.NET 2003 using the unmanaged/native C++ compiler.
I was told that Visual Studio.NET 2003 had native C++ compiler support. I am aware about the new C++ 1999 changes (eg. #include <iostream>, using namespace std; etc). However my errors seem to be related to the PlatformSDK Feb2003. eg:
<br />
<br />
<br />
error C2039: 'Delete' : is not a member of 'CCommandEx<TAccessor>' with [TAccessor=ATL::CManualAccessor]<br />
<br />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
error C2065: 'AFX_OLE_DATETIME_ERROR' : undeclared identifier<br />
<br />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
error C2143: syntax error : missing ',' before '<'<br />
<br />
NOTE: what is this issue about templates??? my templates are like:<br />
<br />
(code snip)<br />
template <class TAccessor = CNoAccessor, template <typename T> class TRowset = CRowset><br />
class CAccessorRowset :<br />
public TAccessor,<br />
public TRowset<TAccessor>
{<br />
(code snip>)<br />
<br />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
error C2440: 'type cast' : cannot convert from 'CFile' to 'HFILE'<br />
<br />
(code snip)<br />
if ((HFILE)File==CFile::hFileNull)<br />
(code snip)<br />
<br />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
error C2475: 'CDouble::GetDoubleValue' : forming a pointer-to-member requires explicit use of the address-of operator ('&') and a qualified name<br />
<br />
(code snip)<br />
if(Value.GetDoubleValue != 0)<br />
(code snip)<br />
<br />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
error C2516: 'TRowset' : is not a legal base class<br />
<br />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
and there's more. What was wrong with Visual C++ 6.0? and why is there so many errors when trying to compile under Visual Studio.NET 2003? Does anyone know a quick conversion script?
-- modified at 9:07 Monday 6th March, 2006
|
|
|
|
|
Hmm, now that you asked am not sure myself.
I just installed Visual Studio.NET 2003 on another PC and copied my Visual C++ 6.0 entire project over. Then I double-clicked on the .dsw (Visual C++ 6.0 Workspace... solution/collection of projects).
It loaded saying it has to convert the projects into VS.NET 2003 projects. I said yes to all.
Question: But where do I find out whether my solution is building on unmanaged or managed C++?
|
|
|
|
|
Thanks. I manage to fix some of these errors. There's still some errors that
buffle me.
1. DLL creation:
HGBaseu.def(76): fatal error LNK1118: syntax error in '70' statement
(points to)
?CreateThreadProcessor@CGeneralTimerThreadQueue@@MAEPAVCGeneralTimerThread@@V<br />
<br />
CHGVoidCall@@J@Z 70 NONAME
2. Originally it said ostream cannot be inline so I commented that out.
However I don't understand the errors:
GUID.h(54): error C2143: syntax error : missing ';' before '&'<br />
GUID.h(54): error C2501: 'ostream' : missing storage-class or type specifiers<br />
GUID.h(54): error C2065: 'strm' : undeclared identifier<br />
GUID.h(54): error C2065: 'ID' : undeclared identifier<br />
GUID.h(54): error C2275: 'CGUID' : illegal use of this type as an expression<br />
GUID.h(54): error C2501: 'operator`<<'' : missing storage-class or type <br />
<br />
specifiers<br />
GUID.h(54): error C2365: 'operator`<<'' : redefinition; previous definition <br />
<br />
was a 'member function'<br />
GUID.h(54): error C2078: too many initializers<br />
GUID.h(55): error C2143: syntax error : missing ';' before '{'<br />
GUID.h(55): error C2447: '{' : missing function header (old-style formal <br />
<br />
list?)
(all points to)
ostream& operator<<(ostream& strm,CGUID& ID)<br />
{<br />
return strm<< (CString)ID;<br />
}
3. Some problems with namespaces:
SortedArray2.h(75): error C2039: '[]' : is not a member of 'operator``global <br />
<br />
namespace'''
(points to)
inline TYPE& CSortedArray2<TYPE>::operator[](int nIndex)<br />
{<br />
return m_InternalArray[nIndex];<br />
}
I get a lot of repeated errors of the above 3 plus lots of template errors. I
believe Visual C++ 6.0 didn't comply with the C++ standards on how to define
templates right?
-- modified at 11:56 Monday 6th March, 2006
|
|
|
|
|
Often when programs start (i.e. MS Word), there is a small window that shows the program icon, program info, registration info, etc... This window then disappears when the application loads in full. How do I programatically create the small start-up window that lasts until the full program loads?
Thanks,
Blitz
|
|
|
|
|
It's called a "splash screen" or "splash window."
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Thanks, I appreciate the info.
|
|
|
|
|
|
Thanks, I really appreciate the info.
|
|
|
|
|
I want to change the color of the controls like buttons, static etc in a dialog box in MFC.
Can you please tell how to do that?
Thanks in advance.
|
|
|
|
|
There is a brief example of this here, in the Extras section.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
|
if a .h file contain many lib declaration.and no source .
how to locate a function ?
|
|
|
|
|
intellisense tell you in which file the declaration of your function is on (VS.NET 2003 +),
and msdn tells also at the bottom of a function doc which header is to include to have this function working.
for example, for the cos()[^] cosine function, msdn tells us that the required header is <math.h> , and the function is defined in all the C run-time libs[^]libs are
|
|
|
|
|
I mean 3nd part lib but that has no docment and source.
for dll, I can use depends to work out.
for static lib, which tool can solve it?
|
|
|
|
|
i don't understand. if you know the function you are using, and you know it comes from a 3rd part library, how don't you know the right lib it is embedded in ?
|
|
|
|