SetWindowText Error
-
Hi, I have long value i am want to show in the dlg i used below code but its giveing error can any one help me with this.. long n; n=INDX.total_words; status->m_TOTAL_WORDS.SetWindowText(n); --------------- Error --------------- error C2664: 'SetWindowTextA' : cannot convert parameter 1 from 'long' to 'const char *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast ---------------------------------------- Regards, Parichay.
-
Hi, I have long value i am want to show in the dlg i used below code but its giveing error can any one help me with this.. long n; n=INDX.total_words; status->m_TOTAL_WORDS.SetWindowText(n); --------------- Error --------------- error C2664: 'SetWindowTextA' : cannot convert parameter 1 from 'long' to 'const char *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast ---------------------------------------- Regards, Parichay.
The function SetWindowText expect a char array, not a long. So use sprintf to convert this value into a char array:
char szBuff[50];
sprintf(szBuff,"%l",n);
status->m_TOTAL_WORDS.SetWindowText(szBuff);
Cédric Moonen Software developer
Charting control -
Hi, I have long value i am want to show in the dlg i used below code but its giveing error can any one help me with this.. long n; n=INDX.total_words; status->m_TOTAL_WORDS.SetWindowText(n); --------------- Error --------------- error C2664: 'SetWindowTextA' : cannot convert parameter 1 from 'long' to 'const char *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast ---------------------------------------- Regards, Parichay.
TCHAR buffer[50]; long a=20; _ltoa(a,buffer,10); status->m_TOTAL_WORDS.SetWindowText(buffer);_**
**_
whitesky
-
The function SetWindowText expect a char array, not a long. So use sprintf to convert this value into a char array:
char szBuff[50];
sprintf(szBuff,"%l",n);
status->m_TOTAL_WORDS.SetWindowText(szBuff);
Cédric Moonen Software developer
Charting controlHi Cedric Moonen, Thanks for the reply, I used the code as u have said error has gone, but the value is nt displayed in the dialog, what will be the cause ?? I used F5 and checked the n value its getting the the value correctly 72986 but its nt displaying. IDC_TOTAL_WORDS with member of type CEdit m_TOTAL_WORDS
-
TCHAR buffer[50]; long a=20; _ltoa(a,buffer,10); status->m_TOTAL_WORDS.SetWindowText(buffer);_**
**_
whitesky
-
TCHAR buffer[50]; long a=20; _ltoa(a,buffer,10); status->m_TOTAL_WORDS.SetWindowText(buffer);_**
**_
whitesky
-
Hi WhiteSky, Can u please also tell me how to change it int to char ?? TCHAR buffer1[50]; int f=INDX.getTotalFiles(); _ltoa(f,buffer,10); status->m_TOTAL_FILES.SetWindowText(buffer1);
very simple _ltoa(f,buffer,10); to itoa(f,buffer,10);_**
**_
whitesky
-
Hi WhiteSky, Can u please also tell me how to change it int to char ?? TCHAR buffer1[50]; int f=INDX.getTotalFiles(); _ltoa(f,buffer,10); status->m_TOTAL_FILES.SetWindowText(buffer1);
vinaycool wrote:
Can u please also tell me how to change it int to char ??
_ltoa
--[V]--
-
vinaycool wrote:
Can u please also tell me how to change it int to char ??
_ltoa
--[V]--
Hi VuNic _ltoa or itoa_**
**_
whitesky
-
vinaycool wrote:
Can u please also tell me how to change it int to char ??
_ltoa
--[V]--
_ltoa - Convert a long integer to a string. _itoa - Convert an integer to a string Knock out 'T' from CAN'T , You 'CAN' if you think you 'CAN' :cool:
-
very simple _ltoa(f,buffer,10); to itoa(f,buffer,10);_**
**_
whitesky
-
Hi VuNic _ltoa or itoa_**
**_
whitesky
Can u please also tell me how to change it int to char ?? TCHAR buffer1[50]; int f=INDX.getTotalFiles(); _ltoa(f,buffer,10); status->m_TOTAL_FILES.SetWindowText(buffer1); Oops, I misunderstood his question. I thought he was asking about the line that does the conversion.
--[V]--
-
_ltoa - Convert a long integer to a string. _itoa - Convert an integer to a string Knock out 'T' from CAN'T , You 'CAN' if you think you 'CAN' :cool:
pleast look at my reply to whitesky. And Btw, you can still use ltoa for converting ints to chars. int is not something totally different from long. but Only the size ;)
--[V]--
-
pleast look at my reply to whitesky. And Btw, you can still use ltoa for converting ints to chars. int is not something totally different from long. but Only the size ;)
--[V]--
Due to the differences in size of long and int C++ provides the seperate functions :) Knock out 'T' from CAN'T , You 'CAN' if you think you 'CAN' :cool:
-
Due to the differences in size of long and int C++ provides the seperate functions :) Knock out 'T' from CAN'T , You 'CAN' if you think you 'CAN' :cool:
-
Can u please also tell me how to change it int to char ?? TCHAR buffer1[50]; int f=INDX.getTotalFiles(); _ltoa(f,buffer,10); status->m_TOTAL_FILES.SetWindowText(buffer1); Oops, I misunderstood his question. I thought he was asking about the line that does the conversion.
--[V]--
yes:)_**
**_
whitesky