|
thanks a lot for ur reply !
what things we can do with Java ? some friends talk about the power of c++ . what's i search about this is for e.g. making a simple application can remove the Password of cell phone when a user forgot it for Some Symbian OS or ...?
thanx a lot !
s_mostafa_h
|
|
|
|
|
I ran into some problems with COleDateTime.ParseDateTime that I didn't understand, so I assumed that my app was misusing/abusing them. I tried instead to write a small cmd-line app with MFC support that would explain the problem... here is the src code:
<br />
#include "stdafx.h"<br />
#include "TestDateTime3.h"<br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif<br />
<br />
<br />
CWinApp theApp;<br />
<br />
using namespace std;<br />
<br />
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])<br />
{<br />
int nRetCode = 0;<br />
<br />
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))<br />
{<br />
cerr << _T("Fatal Error: MFC initialization failed") << endl;<br />
nRetCode = 1;<br />
}<br />
else<br />
{<br />
COleDateTime *pTime = new COleDateTime();<br />
pTime->ParseDateTime(_T("1/25/1996 8:30:00"));<br />
}<br />
<br />
return nRetCode;<br />
}<br />
The interesting part is:
<br />
COleDateTime *pTime = new COleDateTime();<br />
pTime->ParseDateTime(_T("1/25/1996 8:30:00"));<br />
This always returns failure and sets the status flag to invalid. I can also try formats such as "2001/01/01" or "1/1/2007" all to the same effect.
If I run it under the debugger, and try to step into ParseDateTime, it steps into COleCurrency::ParseCurrency instead of the intended method. I do not have any idea how or why that could possibly happen.
This is on a windows 2003 server machine. Are there any ideas out there?
|
|
|
|
|
Deeper into Pandora's box, I find that running in release mode it parses correctly, but debug builds fail. I still don't understand what could trigger the difference?
|
|
|
|
|
I don't know what to say, this works in both debug and release
COleDateTime dt;
dt.ParseDateTime(_T("1/25/1996 8:30:00"));
((CStatic*)CDialog::GetDlgItem(IDC_DATETIME))->SetWindowText(dt.Format());
led mike
|
|
|
|
|
You should check the international settings for when you test this. If the date setting is 'DD/MM/YYYY', that could be causing your difficulty.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
Donate to help Conquer Cancer[ ^]
|
|
|
|
|
It is an interesting guess, but my settings are US, and hardcoding the lcid to US English doesn't help either. I never did figure it out, but I guess its not too big of a problem since the release builds work.
|
|
|
|
|
I am having a dialog box application (main dialog box in which many other child dialog boxes are created) in which I am having a closed loop function which does a series of other functions(doing some computations and updating some dialog boxes) continuously untill the user stops. For this we are using TIMERs, but using TIMERs I see there is atleast 10ms delay between the end of first TIMER to the start of next TIMER. We are trying to improve our closed loop frequency and I am not able to reduce this delay?? Is there any other better way rather than using TIMERs, like using threads (but the problem is when I tried using threads before, the interface doesnt respond anymore once the thread has started).
thanks in advance.
PKNT
|
|
|
|
|
Kiran Satish wrote: like using threads (but the problem is when I tried using threads before, the interface doesnt respond anymore once the thread has started)
That means you need to properly using threads.
How are you using timers? How did you use threads?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Yes... I know I haven't used threads in proper way in this particular application .
Well I used them in more sumple way, once the user clicks on 'Close Loop' button on one of the dialog boxes, I start a thread that does all the necessary work, but I remember it giving errors when I send/post messages to dialog boxes (but I am not sure) and the interface doesnt respnd anymore to user inputs.
Coming to TIMERs, here is how we are using currently-
<br />
void CAnalysisDlg::OnCloseloop() <br />
{<br />
CButton *ClButton;<br />
HICON icn;<br />
ClButton = (CButton *)GetDlgItem(IDB_CLOSELOOP);<br />
icn = ClButton->GetIcon();<br />
if(icn == AfxGetApp()->LoadIcon(IDI_CLOSELOOP))<br />
{<br />
ClButton->SendMessage(BM_SETIMAGE,IMAGE_ICON,(LPARAM)AfxGetApp()->LoadIcon(IDI_LOOPCLOSED));<br />
if(parent->closeLoop() == FALSE)<br />
{<br />
ClButton->SendMessage(BM_SETIMAGE,IMAGE_ICON,(LPARAM)AfxGetApp()->LoadIcon(IDI_CLOSELOOP));<br />
}<br />
}<br />
else<br />
{<br />
KillTimer(1);<br />
parent->Uncheck_Closeloop();<br />
}<br />
}<br />
BOOL CMainDlg::closeLoop()<br />
{<br />
if(OnAutoMeasure()==FALSE)<br />
return FALSE;<br />
}<br />
<br />
BOOL CMainDlg::OnAutoMeasure()<br />
{<br />
SetTimer(1,1,NULL);<br />
return TRUE;<br />
}<br />
<br />
void CMainDlg::OnTimer(UINT nIDEvent) <br />
{<br />
CButton *ClButton;<br />
HICON icn;<br />
KillTimer(1);<br />
ClButton = (CButton *)tbdisp->GetDlgItem(IDB_CLOSELOOP);<br />
icn = ClButton->GetIcon();<br />
if(icn == AfxGetApp()->LoadIcon(IDI_LOOPCLOSED))<br />
{<br />
if(closeloopsafety <= NUM_FALSE_RETURN_AUTOMEASURE)<br />
{<br />
if(OnAutoMeasure()==FALSE)<br />
Uncheck_Closeloop();<br />
}<br />
else<br />
Uncheck_Closeloop();<br />
}<br />
CDialog::OnTimer(nIDEvent);<br />
}<br />
I hope the code wont be too much of confusion . But that how its basically works now.
PKNT
|
|
|
|
|
this is NOT because of the MFC's Timer (which is in fact a wrapper to Win32), but because Windows is NOT a Real Time OS...
so you cannot expect much efficiency from there.
|
|
|
|
|
Yes.. its true. But I never had much of problems using threads in MFC, they used to work better. But well you can't compare it with other real-time OSes like Linux and other packages that you can get that makes Windows as real-time OS though .
PKNT
|
|
|
|
|
but maybe your processor is overloaded in kernel mode...
|
|
|
|
|
Good point, but I have 8 cores and I barely use one core at full clock (while running all our applications at the same time) and to say windows is not bad in scheduling processes on multi core systems and distributes evenly if not overloading .
PKNT
|
|
|
|
|
Kiran Satish wrote: other real-time OSes like Linux
FYI, Linux is not a RTOS
|
|
|
|
|
Yes... I agree, but I am not saying about those commercial Linux Distros (like Fedora, Mandrake etc), there are many RTOSes based on Linux, I meant it in the same way I said about Windows RTOS version packages.
PKNT
|
|
|
|
|
from MSDN article: How To Use QueryPerformanceCounter to Time Code
Function Units Resolution
---------------------------------------------------------------------------
Now, Time, Timer seconds 1 second
GetTickCount milliseconds approx. 10 ms
TimeGetTime milliseconds approx. 10 ms
QueryPerformanceCounter QueryPerformanceFrequency same
not so much in MFC but Win32 perhaps? your best resolution is probably 10ms
NB multicore breaks simple RDTSC approaches you may read about
my old article on timing: http://www.codeproject.com/KB/cpp/precision_timer.aspx[^]
|
|
|
|
|
How is possible to determine, if a drag'n'drop event is active between two other appliactions or processes.
I mean - catching the event globally - that in Windows is at the moment a drag'n'drop event in progress.
Thanx a lot
|
|
|
|
|
I want to copy (large)files from one location to the other but I am having problems with SHFileOperation in vista (I cannt cancel the copying operation, my app says Not Responding when i cancel the copying) but seems to work fine in XP. Is there any other way i can copy files, showing a copying progress and allowing the user to cancel the operation, so that I can avoid this problem in vista? Thanks
|
|
|
|
|
|
I want it to work in XP too. I think IFileOperation is supported only in vista.
|
|
|
|
|
itsh11 wrote: I want it to work in XP too. I think IFileOperation is supported only in vista.
So use one or the other depending on the OS.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
itsh11 wrote: Is there any other way i can copy files, showing a copying progress and allowing the user to cancel the operation, so that I can avoid this problem in vista?
What about CopyFileEx() ?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I am passing the offset in SetFilePointer(offset) that does not exist in a file but this function is succedding. If this offset is not exist, it should not succeed.
code is:
<br />
LARGE_INTEGER largeSector ={NULL};<br />
largeSector.QuadPart =ullPosition;<br />
<br />
largeSector.LowPart =SetFilePointer(m_hHandleTOLogicalDrive,largeSector.LowPart,&largeSector.HighPart,FILE_BEGIN);<br />
if ( largeSector.LowPart==INVALID_SET_FILE_POINTER && (GetLastError())!=NO_ERROR )<br />
{<br />
cout<<"unable to set pointer";<br />
return FALSE;<br />
}<br />
else<br />
return TRUE;<br />
|
|
|
|
|
From MSDN [^]:
It is not an error to set a file pointer to a position beyond the end of the file. The size of the file does not increase until you call the SetEndOfFile, WriteFile, or WriteFileEx function. A write operation increases the size of the file to the file pointer position plus the size of the buffer written, which results in the intervening bytes uninitialized.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hello!!
What happens to a CList when using RemoveAt(POSITION) . Does the list re-arrange itself to fill that gap?? If not, how do you do it to remove an internal node?
Does it have to be done manually, remove a node, and then shift the rest of elements one position??
|
|
|
|