Click here to Skip to main content
15,908,776 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionChange from Cstring to double in listview vc++ Pin
lolici20-Mar-17 1:31
lolici20-Mar-17 1:31 
AnswerRe: Change from Cstring to double in listview vc++ Pin
Jochen Arndt20-Mar-17 2:02
professionalJochen Arndt20-Mar-17 2:02 
A list control can not store double values without additional handling. To set the text of an item to a floating point value it must be converted. Read the documentation of the used sprintf, _sprintf_l, swprintf, _swprintf_l, __swprintf_l[^] function.
So you have to use something like
WCHAR szString[256];
swprintf(szString, sizeof(szString) / sizeof(WCHAR), L"%G", value);

But it would be better to use _snprintf_s, _snprintf_s_l, _snwprintf_s, _snwprintf_s_l[^] here:
TCHAR szString[256];
_sntprintf_t(szString, sizeof(szString) / sizeof(TCHAR), _T("%G"), value);

To get a double value back when reading the cell text use _tstof (atof, _atof_l, _wtof, _wtof_l[^]):
// double CDataDialog::GetItemText(HWND hWnd, int nItem, int nSubItem) const
double CDataDialog::GetItemDouble(HWND hWnd, int nItem, int nSubItem) const
{
    CString str = GetItemText(hWnd, nItem, nSubItem);
    return _tstof(str);
}


modified 20-Mar-17 9:01am.

GeneralRe: Change from Cstring to double in listview vc++ Pin
lolici20-Mar-17 2:56
lolici20-Mar-17 2:56 
GeneralRe: Change from Cstring to double in listview vc++ Pin
Jochen Arndt20-Mar-17 3:00
professionalJochen Arndt20-Mar-17 3:00 
GeneralRe: Change from Cstring to double in listview vc++ Pin
lolici20-Mar-17 3:32
lolici20-Mar-17 3:32 
GeneralRe: Change from Cstring to double in listview vc++ Pin
Jochen Arndt20-Mar-17 3:39
professionalJochen Arndt20-Mar-17 3:39 
GeneralRe: Change from Cstring to double in listview vc++ Pin
lolici20-Mar-17 8:02
lolici20-Mar-17 8:02 
AnswerRe: Change from Cstring to double in listview vc++ Pin
Victor Nijegorodov20-Mar-17 6:56
Victor Nijegorodov20-Mar-17 6:56 
GeneralRe: Change from Cstring to double in listview vc++ Pin
lolici20-Mar-17 7:58
lolici20-Mar-17 7:58 
QuestionRe: Change from Cstring to double in listview vc++ Pin
David Crow20-Mar-17 9:52
David Crow20-Mar-17 9:52 
QuestionCrc 32 bit Pin
yagokhan19-Mar-17 21:58
yagokhan19-Mar-17 21:58 
AnswerRe: Crc 32 bit Pin
Jochen Arndt19-Mar-17 22:15
professionalJochen Arndt19-Mar-17 22:15 
AnswerRe: Crc 32 bit Pin
yagokhan19-Mar-17 22:20
yagokhan19-Mar-17 22:20 
GeneralRe: Crc 32 bit Pin
Richard MacCutchan19-Mar-17 22:57
mveRichard MacCutchan19-Mar-17 22:57 
GeneralRe: Crc 32 bit Pin
yagokhan19-Mar-17 22:59
yagokhan19-Mar-17 22:59 
GeneralRe: Crc 32 bit Pin
Richard MacCutchan19-Mar-17 23:19
mveRichard MacCutchan19-Mar-17 23:19 
GeneralRe: Crc 32 bit Pin
yagokhan19-Mar-17 23:22
yagokhan19-Mar-17 23:22 
GeneralRe: Crc 32 bit Pin
Jochen Arndt20-Mar-17 2:36
professionalJochen Arndt20-Mar-17 2:36 
QuestionCatch double click on MDI client CMDIFrameWndEx Pin
_Flaviu16-Mar-17 22:19
_Flaviu16-Mar-17 22:19 
AnswerRe: Catch double click on MDI client CMDIFrameWndEx Pin
Richard MacCutchan16-Mar-17 23:46
mveRichard MacCutchan16-Mar-17 23:46 
GeneralRe: Catch double click on MDI client CMDIFrameWndEx Pin
_Flaviu17-Mar-17 0:02
_Flaviu17-Mar-17 0:02 
GeneralRe: Catch double click on MDI client CMDIFrameWndEx Pin
Richard MacCutchan17-Mar-17 0:26
mveRichard MacCutchan17-Mar-17 0:26 
GeneralRe: Catch double click on MDI client CMDIFrameWndEx Pin
_Flaviu17-Mar-17 0:40
_Flaviu17-Mar-17 0:40 
AnswerRe: Catch double click on MDI client CMDIFrameWndEx Pin
Victor Nijegorodov18-Mar-17 4:09
Victor Nijegorodov18-Mar-17 4:09 
QuestionHow to use a variable declared in another class in Visual C++ Pin
lolici16-Mar-17 3:17
lolici16-Mar-17 3:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.