|
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??
|
|
|
|
|
piul wrote: Does the list re-arrange itself to fill that gap??
Yes and no. The good thing from a List vs an array is (in grosso modo): that every node is pointing to next and previous node. So when you delete one position, you dont have to rearrange anything, just modify 2 pointers the "next" in the previous node and the "previous" in the next node. Then the node in the middle is not in the list anymore and can be just deleted without problems.
piul wrote: Does it have to be done manually, remove a node, and then shift the rest of elements one position??
You dont have to move anything, a list is not an array.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
thanksfully it does, hey !!!
do you write classes letting the user manage its content himself ?
BTW, why don't you test it ?
|
|
|
|
|
Thankfully it is a list and not an array. Therefore, no shifting of elements is required for a delete operation. It is just changing where a single 'next' pointer is pointing to. For example, if you delete the 3rd element, what internally happens is, the next pointer of the second element points to the 4th element and so the 3rd one is 'dropped'.
A 'C++' question asked in the Visual C++ forum:
Title: please stomuch me
if i have
string s[7];
s[1]="hello"
...
s[7]="how are you"
can i trace s[1] by loop and select specified item as example i, want to select e from s[1]="hello"..... the question is : this process possible or impossible!? I hope help me.......thanks - sofia_111
|
|
|
|
|
Rajesh R Subramanian wrote: A 'C++' question asked in the Visual C++ forum:
Title: please stomuch me
if i have
string s[7];
s[1]="hello"
...
s[7]="how are you"
can i trace s[1] by loop and select specified item as example i, want to select e from s[1]="hello"..... the question is : this process possible or impossible!? I hope help me.......thanks - sofia_111
You're really a bad guy.
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
|
|
|
|
|
Bug crossing answers in other posts? or just abussing another time? :P
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
No abuz sir:
Rajesh mocks the poor newbie lady (I suppose), he's really bad.
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
|
|
|
|
|
CPallini wrote: You're really a bad guy.
You're really a bad guy. - CPallini
|
|
|
|
|
I think it's definitely time to restore your charming wavy sign.
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
|
|
|
|