|
instead of dtY it is 'drResult'
sorry for the typo
|
|
|
|
|
grr dtResult ofcourse
(still morning)
|
|
|
|
|
Back at work now
the number of days can be like 60days or even more.
So sometimes something like this:
CTimeSpan dtDiff(70,0,0,0);
But now i see @ MSDN that the maximum number of days only can be '25 000'. So this won't be a problem
anywayz, how to solve this problem and how can i know what went wrong with the ctime or the ctimespan object?
|
|
|
|
|
JensB,
I have just quickly built a console version of your program above and it seems to be OK? I had to add an extra parameter at the construction of your CTimeSpan, dtDiff (it takes four parameters).
<br />
CTimeSpan dtDiff(60,0,0,0);<br />
CTime timeNow(1999,3,23,7,34,12);
CTime dtResult = timeNow - dtDiff;<br />
char szMsg[256];<br />
<br />
wsprintf(szMsg, "%02d/%02d/%04d", dtResult.GetDay(), dtResult.GetMonth(), dtResult.GetYear());<br />
The only thing that have noticed is that the MSDN says that the time classes will assert if any of the time conponents are invalid or out of range. Maybe this is what you are experiencing...
I Dream of Absolute Zero
|
|
|
|
|
Well, i have just find out there was something wrong with filling the time to 'timenow'.
I've replaced it with timenow = CTime::GetCurrentTime();
and now it works great.
Thanks for the efforts
|
|
|
|
|
Hi all. Have 2 Q's.
First, I am using a console app in VC++ to launch IE. I then need for the console to monitor how long the app is open by presenteng dots accross the console screnn. My problem is that I can do this, but cannot see the dots UNTILL I have killed the app. How do I give the spotlight to the console WITH the app open and have the console progressively indicate (one dot per second) the time its open??
Partial code is as follws:
if( !CreateProcess( NULL,"C:\\Program Files\\Internet Explorer\iexplore.exe",NULL,NULL,FALSE,0,NULL,NULL,&si,&pi))
{
cout <<"CreateProcess failed.\n";
}
else
cout<
|
|
|
|
|
It sounds like cout is doing some buffering. How about:
while (WaitForSingleObject(pi.hProcess, 1000))
{
cout << "." << flush;
}
|
|
|
|
|
Yep, that would do it! I actually ended up using cerr, as I believe that this is
cout and flush combined as cerr doest use a buffer at all.
Will play around with both a see what I get.
Cheers for the help!!
|
|
|
|
|
Hi all,I'm creating a memory management class, that is fairly basic, so you can easily set the size of a block of memory. I have based it in mind for use in arrays and have setup a template class to do it so I could use it to manage the memory of any object. The trouble I'm getting occurs when trying to store the contents of another template container because malloc does not initialise the contents. ZeroMemory doesn't work either because the __vfptr gets initialised to zero instead of the associated virtual functions pointer associated with the class of type T (which means cleaning up causing problems such as crashing cos its in effect calling a NULL pointer function). How then, can I properly initialise something (i.e. call its constructor) when I'm working with pointers to (possibly an array) of type T? I'm using malloc((void*)m_pItem, alloc_length); to allocate enough space for the object m_pItem which is of type T, could I have m_pItem[0] = new T? or would this be inefficient to scan through the newly allocated areas of memory? Some ideas guys if you please ,
Alan.
|
|
|
|
|
Why do you use malloc, use new and more precise the placement new functionality. just search for "placement new" on google for examples on how to use it.
Magnus
|
|
|
|
|
There's a not-so-known C++ construct designed just to solve this, it is called placement new:
new (static_cast<void*>(m_pItem)) T; This is a variation of the standard new in which you provide a void * where the object is to be laid out. The effect is equivalente to calling the constructor of the class for an object at the memory position indicated.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for the response guys, placement new huh, didn't realise it existed. I was using malloc because it gives slightly less overhead than new, but I suppose thats cos it doesn't initialise any of its data which I want it to. Thanks people, very helpful.
Alan.
|
|
|
|
|
Dear All,
I am developing an application in MFC VC++ Version 6.0 for Windows 2000.
How can we can one exec from another exe. ie. want to call another exe on click of a button.
Is there any Shell level api available ??? (excluding WinExec)
Feel free to ask any further queries in this regards,
Thanks
Rohit Dhamija
|
|
|
|
|
If you mean to start another program when you click a button, then you use the CreateProcess API.
If you really must use the Shell API, then its ShellExecuteEx you will need. But I would recommend that you use CreateProcess.
Magnus
|
|
|
|
|
Is it possible to detect whether the process has finished with either of these API's (CreateProcess / ShellExecute) ?
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
|
Thanks Nish (& everyone else). That seemed to solve the prob
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
you can use WaitForSingleObject or WaitForMultipleObjects
|
|
|
|
|
You can use WaitForSingleObject on the handle that is returned in PROCESS_INFORMATION::hProcess.
Or you can poll with GetExitCodeProcess
Magnus
|
|
|
|
|
|
I am building an ActiveX control using MFC.
I wonder how can I update the property window when I change a property of type IUnknown from the property page?
I did the following but it is not working with IUnknown property:
In the DoDataExchange of the property page I called a function that sets a new value for the property as follows:
In the property page file:
void CMyPropertyPage::DoDataExchange(CDataExchange* pDX)
{
// NOTE: ClassWizard will add DDP, DDX, and DDV calls here
// DO NOT EDIT what you see in these blocks of generated code !
//{{AFX_DATA_MAP(CPowerListPpgData)
.
.
//}}AFX_DATA_MAP
DDP_PostProcessing(pDX);
if (pDX->m_bSaveAndValidate)
SaveValue();
}
BOOL CMyPropertyPage::SaveValue(IUnknown* lpPropValue, LPCTSTR lpstrPropName)
{
USES_CONVERSION;
COleDispatchDriver PropDispDriver;
ULONG ulObjects;
LPDISPATCH *ppDisp = GetObjectArray(&ulObjects);
DISPID dwDispID;
LPCOLESTR lpOleStr = T2COLE(lpstrPropName);
for(ULONG i = 0; i < ulObjects; i++)
{
if(SUCCEEDED(ppDisp[i]->GetIDsOfNames(IID_NULL, (LPOLESTR*)&lpOleStr, 1, 0, &dwDispID)))
{
PropDispDriver.AttachDispatch(ppDisp[i], FALSE);
PropDispDriver.SetProperty(dwDispID, VT_UNKNOWN, lpPropValue);
PropDispDriver.DetachDispatch();
}
else
return FALSE;
}
return TRUE;
}
In the CTL file:
void CMyCtrl::SetMyProperty(LPUNKNOWN newValue)
{
.
BoundPropertyChanged(dispidMyProperty);
SetModifiedFlag();
}
Is there special case for the proeprties of type IUnknown?
|
|
|
|
|
Hello, Sir:
Maybe i want to catch some exception where my program? Has somebody a class of catching and managing exception? Can you help me?
Thanks in advance.
|
|
|
|
|
HansonDavid wrote:
Maybe i want to catch some exception where my program? Has somebody a class of catching and managing exception?
C++ has exception handling in the language. eg.
try
{
...
}
catch( some_exception e )
{
}
and Windows has Structured Exception Handling - SEH. There are a number of good articles here on CP on Exception handling which should help you get started.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Thanks Sir. Maybe I want a class of catching and managing exception. Because i am working a program . The programe need some FPU instruction. I am afraid of these FPU instrucrions generating some exception error. And i want to catch these exception and manage these exception. I think jusut a class maybe is better.
|
|
|
|
|
what do you want to do ?
maybe have a look at "wizard" type dialogs sequence ...
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|