Convert DWORD to CString
-
Hi Need to convert a DWORD to a CString and a CString to a DWORD type. Hope someone knows :) Greetings Jens
Hi, converting a CString into DWORD means, u are going to covert integer to char here is example. #define HELLO 100 DWORD dwrd=HELLO; CString str1; char str[10]; str1=itoa(HELLO,str,10); //CString str1=str; AfxMessageBox(str1); this will convert the DWORD into CString,but it is not wise.You can't get CString value like "HELLO". it is not possible i think.you can get 100 as a CString value. yakkalas
-
Hi Need to convert a DWORD to a CString and a CString to a DWORD type. Hope someone knows :) Greetings Jens
DWORD is also an unsigned integer,trying to convert it into CString means converting integer to char. Here I am sending simple Ex. DWORD dwrd=HELLO; CString str1; char str[10]; str1=::itoa(HELLO,str,10); //CString str1=str; AfxMessageBox(str1); This simple code will show u 100 not HELLO.So as I am thinking,it is not possible. You mean to try to get CString value as HELLO?:confused: if so it is not possible as per my knowledge. yakkalas.
-
Hi Need to convert a DWORD to a CString and a CString to a DWORD type. Hope someone knows :) Greetings Jens
DWORD is also an unsigned integer,trying to convert it into CString means converting integer to char. Here I am sending simple Ex. #define HELLO 100 DWORD dwrd=HELLO; CString str1; char str[10]; str1=::itoa(HELLO,str,10); //CString str1=str; AfxMessageBox(str1); This simple code will show u 100 not HELLO.So as I am thinking,it is not possible. You mean to try to get CString value as HELLO?:confused: if so it is not possible as per my knowledge. yakkalas.
-
Hi Need to convert a DWORD to a CString and a CString to a DWORD type. Hope someone knows :) Greetings Jens
-
DWORD is also an unsigned integer,trying to convert it into CString means converting integer to char. Here I am sending simple Ex. #define HELLO 100 DWORD dwrd=HELLO; CString str1; char str[10]; str1=::itoa(HELLO,str,10); //CString str1=str; AfxMessageBox(str1); This simple code will show u 100 not HELLO.So as I am thinking,it is not possible. You mean to try to get CString value as HELLO?:confused: if so it is not possible as per my knowledge. yakkalas.
-
Well, it's like this i wanted: I got a CString strValue = "5"; But i got a function which only accepts DWORD values; so instead of CString strValue = "5"; It need to be converted to: DWORD dvalue = 5; that's all to it actually.
-
DWORD d; CString str; d=3; str.Format("%i",d); str="3"; d=atol(str.operator LPCTSSTR()); If this does not work, have a look at http://www.codeproject.com/cpp/cppforumfaq.asp#cpp_atoi[^] ~RaGE();
ok thanks for your help all. I fixed the problem like this: //CString -> long integer CString strBurnr = m_listbur.GetItemText(1,2); DWORD burnr = atol(strBurnr); //Long Integer -> CString char* szTemp; ltoa(burnr, szTemp,10); CString strTemp; strTemp = (CString) szTemp; Thanks, all works fine. :) and btw (this isn't about conversions: does anyone of you guys know how to put a button in a field (in CListView) at every row?) Greetings Jens
-
ok thanks for your help all. I fixed the problem like this: //CString -> long integer CString strBurnr = m_listbur.GetItemText(1,2); DWORD burnr = atol(strBurnr); //Long Integer -> CString char* szTemp; ltoa(burnr, szTemp,10); CString strTemp; strTemp = (CString) szTemp; Thanks, all works fine. :) and btw (this isn't about conversions: does anyone of you guys know how to put a button in a field (in CListView) at every row?) Greetings Jens
JensB wrote: char* szTemp; ltoa(burnr, szTemp,10); This can't work. You've allocated no memory for szTemp. It's just a pointer pointing to who knows where! To get a number, whether its an int, long, etc, into a CString object, just use CString::Format() as in:
DWORD dwNumber = 123;
CString strTemp;
strTemp.Format("%lu", dwNumber); -
JensB wrote: char* szTemp; ltoa(burnr, szTemp,10); This can't work. You've allocated no memory for szTemp. It's just a pointer pointing to who knows where! To get a number, whether its an int, long, etc, into a CString object, just use CString::Format() as in:
DWORD dwNumber = 123;
CString strTemp;
strTemp.Format("%lu", dwNumber); -
Hi Need to convert a DWORD to a CString and a CString to a DWORD type. Hope someone knows :) Greetings Jens
DWORD-STRING itoa() STRING-DWORD atoi()
[ It is possible to represent everything in this universe by using 0 and 1 ]