|
The class for showing the dialog is CFileDialog .
You can use the following sample code -
char szFilters [] = "Text Files (*.text)|*.txt|";
CFileDialog FileDialog (TRUE, "txt", "", OFN_FILEMUSTEXIST, szFilters, this);
CString FileName;
if (FileDialog.DoModal () == IDOK)
{
FileName = FileDialog.GetPathName ();
}
|
|
|
|
|
Hi,
I have list control whose property is set to
"List1",IDC_CmdResp,"SysListView32",LVS_REPORT |
WS_BORDER | WS_TABSTOP,293,37,146,214,
WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_RIGHT |
WS_EX_STATICEDGE
Am displaying the data read from the serial port in the list control but there is lot of filckering.Below is the code to display the data in list control.Is there any thing am missing in the code.Why there is flickering?More flickering starts when i start deleting the data.If i don't delete i get assert error that maybe due to memory overflow of the list control.Plz help me out.
void CNgpptDialog::ReadSerialData(CString sIn)
{
CString pressure_data;
ptrCmdResp->SetRedraw(false);
pressure_data=sIn;
int counter = ptrCmdResp->GetItemCount();
ptrCmdResp->InsertItem(counter, "");// to insert a row
ptrCmdResp->SetItemText(counter, 0, pressure_data);// column0
ptrCmdResp->EnsureVisible(counter, FALSE); // Scrolls downwords.
if(counter > 150)// I start deleting first data when the number of items in the list control is > 150
{
ptrCmdResp->DeleteItem(0);
}
ptrCmdResp->SetRedraw(true);
int nIndex = ptrCmdResp->GetItemCount();
ptrCmdResp->RedrawItems(nIndex,nIndex);
}
}
Thanks in advance
|
|
|
|
|
With one post is enough... at least you could change your text and explain yourself in another way. Maybe is not clear what you mind (i.e. I don't know the word flickering)
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
|
|
|
|
|
K Got it.
The actual issue is
When i place the data in List Ctrl the data is unsteady.As am placing data continuously(120 samples/ sec)and i have run the s/w for many days continuously, i need to delete the data in List Ctrl otherwise buffer of the List Ctrl will overflow.After displaying 150 samples in Ctrllist am starting to delete at this moment data is unsteady.
Thanks
|
|
|
|
|
Well, I reset tmy ListCttrlView everytime the OnDraw is called to empty all datas and then I write the newest values.
void CMyTabView::OnDraw(CDC* pDC)
{ if (m_bJustOpened)
InitializeView ();
if (m_bListRedraw)
DrawViewElements ();
return;
}
In initialize views I configure the number of columns (may be variable from 8 up to 32). Write the name of columns and so on...
By DrawViewElements (); my FIRST line is: m_clcRuleList.DeleteAllItems ();
and then I write them down another time.
And with that you can call the OnDraw easily with an pDoc->UpdateAllViews (NULL); in a Timer with the interval you desire
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
|
|
|
|
|
shir_k wrote: int nIndex = ptrCmdResp->GetItemCount();
ptrCmdResp->RedrawItems(nIndex,nIndex);
Comment out these two statements and see what happens.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
There is no difference
Thanks
|
|
|
|
|
So if all you are ever going to show is 150 items, why not store those in a fast container of some sort, and populate the list control from that container instead. Doing I/O on such a container would be way faster than the same I/O on a UI control. Make sense?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all,
I am having an issue converting this
string pRetVal;
if ((PROP_TYPE_MASK & PropertyID) != PT_STRING8)
{
return 0;
}
redmap::mapi::FoundProperty prop = m_Message->FindProperty(PropertyID);
if (prop.second)
{
pRetVal = _bstr_t(prop.first.lpszW);
return (pRetVal);
}
else
{
pRetVal = ("");
return (pRetVal);
}
There is something wrong in how I am converting prop.first.lpszW because the out put I am getting is instead of "text here" I am getting "????????"
originally this is a COM made snippet
BSTR* pRetVal;
if ((PROP_TYPE_MASK & PropertyID) != PT_STRING8)
{
Error("Invalid property type");
return E_FAIL;
}
redmap::mapi::FoundProperty prop = m_Message->FindProperty(PropertyID);
if (prop.second)
{
ATL::CComBSTR bstr (prop.first.lpszA);
return bstr.CopyTo(pRetVal);
}
else
{
ATL::CComBSTR bstr (L"");
return bstr.CopyTo(pRetVal);
}
Now what is wrong with my conversion? What is the right thing to do?
Thank you all,
Jj
|
|
|
|
|
I got it know I didn't notice I was using lpszW instead of lpszA.
|
|
|
|
|
Hi... this is a bit philosophical ... I noticed a class attributed getting corrupted *on return* of a function... BUT when I step INTO the function, no memory corruption even when debugger pointing at *last* line (return statement) of the function. It wasn't until [the moment] debugger stepped *out* of the function when the class attributed is corrupted.
I'm looking for general idea/approach to such problem:
<br />
class CSomeClass { <br />
void MethodA(...) <br />
{ <br />
... <br />
MethodA1(...);<br />
MethodA2(...); <br />
MethodA3(...); << Boom!! m_attrib corrupted the moment MethodA3 returned debugger still pointing at this line *after*MethodA3 executed/return (I know from Watch Window) <br />
MethodA4(...); <br />
MethodA5(...); <br />
... <br />
} <br />
<br />
int MethodA3(...) <br />
{ <br />
... code ... <br />
return id; << m_attrib still okay but this is last statement of the method! <br />
} <br />
<br />
static SomeAttrib m_attrib; <br />
<br />
};
Note that the attribute "m_attrib" is static. And I don't think this section of the code is multi-threadedn (i.e. I don't see any AfxBeginThread or anything similar within the process boundary).
I guess the question is, what happenned between last statement (return id) within MethodA3, and immediately after debugger step out of MethodA3.
Thanks!
REF:
http://www.eventhelix.com/RealtimeM...are_crashes.htm[^]
http://www.eventhelix.com/RealtimeM...#Using%20assert[^]
-- modified at 23:20 Wednesday 19th September, 2007
|
|
|
|
|
I would hazard a guess that the problem you are encounterring isnt happening where you think it is, and that this is in fact a classic stack corruption problem. Examine carefully the code in MethodA3() for buffer overrun conditions.
FYI, Both of the links given in REF: are broken.
|
|
|
|
|
The corrupted variable was allocated on heap..
thanks though...
|
|
|
|
|
Hi all,
Do need a favour here. I would like to monitor an application and kill it if it is hang and regenerate it. However, not able to find relevant code.
I'm able to get the kernel and user time by "getprocesstime". But not able to monitor the CPU usage (not able to get idle time) to kill the hang program.Understand that some programmer use "GetSystemTimes" function. But it does not work in my PC.
Any suggestion or free code to share? Thanks a lot!
-- modified at 23:29 Wednesday 19th September, 2007
|
|
|
|
|
littlecheer wrote: Do need a favour here. I would like to monitor an application and kill it if it is hang and regenerate it. However, not able to find relevant code.
I'm able to get the kernel and user time by "getprocesstime". But not able to monitor the CPU usage (not able to get idle time) to kill the hang program.Understand that some programmer use "GetSystemTimes" function. But it does not work in my PC.
Any suggestion or free code to share? Thanks a lot!
There are lots of ways for a program to hang. For instance, I've had just the user interface fail and the program keep running in the background. If you control the code for this program, you could have it periodically signal your monitor program that it's still working. If not, your problem is a lot more dificult.
Nathan
|
|
|
|
|
I see. Based on my understanding, the hang program will reflect very high CPU usage (program in a loop) or usertime and kerneltime unchange (deadlock). Is it possible to trace the particular application's CPU usage? Thanks a lot!
|
|
|
|
|
one idea: use Sysinternals' pslist -
(1) have another periodically run pslist<br />
(2) pipe the output the a flat file, <br />
(3) then your *other* application to parse the file for CPU usage<br />
(4) If ProcessA.CPU>30 Then killtask<br />
<br />
|
|
|
|
|
devvvy wrote: 4) If ProcessA.CPU>30 Then killtask
many of myserver application are so cpu savvy , it runs on 30-40% i.e. when acquring data from hardware at 20hz( i.e. 20 record per second). that will help ful atleast in my case!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
well change 30 to any number you like
|
|
|
|
|
My current monitoring application is written in C++ console. Is it possible to use C++ coding to solve this problem? Thanks a million.
|
|
|
|
|
|
|
|
if you file get deleted.when you download the file!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hello 2 everyone interested!
I am developing an application using a GPS receiver for PPC. I am using threads in my code, one of them deals with the GPS's functionality. I have 2 buttons on the dialog (using MFC, by the way) - GPS>on and GPS>off. If I start the gps, at some point stop it and in a matter of up to 5 seconds (or so) I start it again, I get an error and the application crashes.
If I wait more than those 5 seconds, everything works fine. I have started logging my application's steps after hitting GPS>off and discovered that it reaches to ending the thread after .. right... those aprox.5 seconds.
So, for now, I only start the thread if a flag is set (I set it just before ending the thread).
Because I don`t want it to just ignore the push of the button, I did
do {}while(flagThreadStopped!=true)
so now, everything stops if the user starts the gps in those critical 5 seconds. It resumes, after the flag gets set, but I think if there could be another solution.
It's not a critical problem now, as I'm developing the concept, but... later on, it could be. Ideas ?
Thanks
|
|
|
|