send continuos data to an edit control for display
-
I have an edit control that takes up the majority of space on my app. I am receiving continuos data from a port and would like to display each message separated by "\r\n". I tried using the control variable and the value variable for my edit control to display these items. No matter what i try , it only displays the first item and not the rest. I have used the method "SetWindowText" I also use UpdateData(FALSE) to update the screen How does one use these vars to display the continuos data in an edit control?
-
I have an edit control that takes up the majority of space on my app. I am receiving continuos data from a port and would like to display each message separated by "\r\n". I tried using the control variable and the value variable for my edit control to display these items. No matter what i try , it only displays the first item and not the rest. I have used the method "SetWindowText" I also use UpdateData(FALSE) to update the screen How does one use these vars to display the continuos data in an edit control?
Isn't a list control (a list box or a list view ) more appropriate, is it? :)
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.
[my articles] -
I have an edit control that takes up the majority of space on my app. I am receiving continuos data from a port and would like to display each message separated by "\r\n". I tried using the control variable and the value variable for my edit control to display these items. No matter what i try , it only displays the first item and not the rest. I have used the method "SetWindowText" I also use UpdateData(FALSE) to update the screen How does one use these vars to display the continuos data in an edit control?
LCI wrote:
I tried using the control variable and the value variable for my edit control to display these items. No matter what i try , it only displays the first item and not the rest. I have used the method "SetWindowText"
How are you doing this?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
I have an edit control that takes up the majority of space on my app. I am receiving continuos data from a port and would like to display each message separated by "\r\n". I tried using the control variable and the value variable for my edit control to display these items. No matter what i try , it only displays the first item and not the rest. I have used the method "SetWindowText" I also use UpdateData(FALSE) to update the screen How does one use these vars to display the continuos data in an edit control?
LCI wrote:
it only displays the first item
Do you have the textbox set to multiline? Or use a listbox as was mentioned.
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns
-
I have an edit control that takes up the majority of space on my app. I am receiving continuos data from a port and would like to display each message separated by "\r\n". I tried using the control variable and the value variable for my edit control to display these items. No matter what i try , it only displays the first item and not the rest. I have used the method "SetWindowText" I also use UpdateData(FALSE) to update the screen How does one use these vars to display the continuos data in an edit control?
From MSDN (here[^]): So, set the current selection (SetCell) to the last character and then replace the current selection by the new text (ReplaceSel). This way, you don't erase what was there previously.
Cédric Moonen Software developer
Charting control [v1.2]modified on Tuesday, January 22, 2008 10:50:29 AM
-
LCI wrote:
it only displays the first item
Do you have the textbox set to multiline? Or use a listbox as was mentioned.
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns
-
LCI wrote:
I tried using the control variable and the value variable for my edit control to display these items. No matter what i try , it only displays the first item and not the rest. I have used the method "SetWindowText"
How are you doing this?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
I simply have a control variable for my edit control call it m_Control. I have a string variable for that same edit control. call it m_strValue. I do something like //using the string var for (int lop=1; ;lop<100;lop++) { m_strValue = data[lop]; UpdateData(FALSE); } ///////OR for (int lop=1; ;lop<100;lop++) { m_Control.SetWindowText((LPCSTR)data[lop]); UpdateData(FALSE); }
-
I simply have a control variable for my edit control call it m_Control. I have a string variable for that same edit control. call it m_strValue. I do something like //using the string var for (int lop=1; ;lop<100;lop++) { m_strValue = data[lop]; UpdateData(FALSE); } ///////OR for (int lop=1; ;lop<100;lop++) { m_Control.SetWindowText((LPCSTR)data[lop]); UpdateData(FALSE); }
Neither of these will preserve what is currently in the edit control.
LCI wrote:
m_Control.SetWindowText((LPCSTR)data[lop]); UpdateData(FALSE);
When using a
CEdit
control, or any other time for that matter,UpdateData()
is not necessary. You can do something like:for (int lop = 1; lop < 100; lop++)
{
CString str;
m_Control.GetWindowText(str);
str += data[lop];
m_Control.SetWindowText(str);
}Or you could just continually add to the end of the edit control as has already been suggested.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
I simply have a control variable for my edit control call it m_Control. I have a string variable for that same edit control. call it m_strValue. I do something like //using the string var for (int lop=1; ;lop<100;lop++) { m_strValue = data[lop]; UpdateData(FALSE); } ///////OR for (int lop=1; ;lop<100;lop++) { m_Control.SetWindowText((LPCSTR)data[lop]); UpdateData(FALSE); }
Since you are trying to update a window while you are in a tight loop, you need to realize that the window will not process any messages until the loop completes. The UpdateData puts a message in the queue to be processed, but it isn't processed immediately. To overcome this, try
for (int lop=1; ;lop<100;lop++)
{
m_Control.SetWindowText((LPCSTR)data[lop]);
UpdateData(FALSE);
m_Control.UpdateWindow();
}The call to UpdateWindow bypasses the normal message queue and causes the window to repaint immediately. Hope that helps.
Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193