How to Update Dialog values
-
Hi I'm getting streaming data to the program I'm writing and I need to update the data constantly. I'm currently just doing a switch statement to determine what needs to be updated and then after the switch I have UpdateData(false); This works but it will not allow me to enter values into over boxes in the display as it is constantly being updated. Is there a way to update just the single box value and not the whole display? Thanks Simon
-
Hi I'm getting streaming data to the program I'm writing and I need to update the data constantly. I'm currently just doing a switch statement to determine what needs to be updated and then after the switch I have UpdateData(false); This works but it will not allow me to enter values into over boxes in the display as it is constantly being updated. Is there a way to update just the single box value and not the whole display? Thanks Simon
simoncoul wrote:
Is there a way to update just the single box value and not the whole display?
Sure, just use ClassWizard (Ctrl+W) to assign a control variable to each control on the dialog. For edit, static, and button controls, use
SetWindowText()
. For listboxes and comboboxes, useAddString()
.
"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
-
simoncoul wrote:
Is there a way to update just the single box value and not the whole display?
Sure, just use ClassWizard (Ctrl+W) to assign a control variable to each control on the dialog. For edit, static, and button controls, use
SetWindowText()
. For listboxes and comboboxes, useAddString()
.
"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
-
Hey thanks for the quick reply, but the SetWindowText asks for a LPCTSTR as the argument but I need to do integers and sometimes floats. Can I just cast it? Thanks again
There are functions for appropriate conversion, for example itoa, ltoa. Or, if you are using CString: long var =12345; CString strVar; strVar.Format( "%d", var );
MS
-
Hey thanks for the quick reply, but the SetWindowText asks for a LPCTSTR as the argument but I need to do integers and sometimes floats. Can I just cast it? Thanks again
simoncoul wrote:
Can I just cast it?
No. Use:
char szData[16];
int nValue = 12345;
sprintf(szData, "%d", nValue);
...
double dValue = 987.01;
sprintf(szData, "%f", dValue);By chance are you using MFC?
"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
-
simoncoul wrote:
Can I just cast it?
No. Use:
char szData[16];
int nValue = 12345;
sprintf(szData, "%d", nValue);
...
double dValue = 987.01;
sprintf(szData, "%f", dValue);By chance are you using MFC?
"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
-
simoncoul wrote:
does that make this easier?
Not necessarily easier, but slightly more elegant and efficient:
CString strData;
int nValue = 12345;
strData.Format("%d", nValue);
...
double dValue = 987.01;
strData.Format("%f", dValue);
"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
-
simoncoul wrote:
does that make this easier?
Not necessarily easier, but slightly more elegant and efficient:
CString strData;
int nValue = 12345;
strData.Format("%d", nValue);
...
double dValue = 987.01;
strData.Format("%f", dValue);
"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
-
Hey thanks for the quick reply, but the SetWindowText asks for a LPCTSTR as the argument but I need to do integers and sometimes floats. Can I just cast it? Thanks again
simoncoul wrote:
Can I just cast it?
No. There is a routine you cann add to yotu program called boost::lexical_cast[^] which allows you to use a simple cast. (The documentation even describes what is going on under the hood) double pi = 3.14; std::string number = boost::lexical_cast( pi);
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal.
George Orwell, "Keep the Aspidistra Flying", Opening words