Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CString and Windows programming

Status
Not open for further replies.

MinnisotaFreezing

Programmer
Jun 21, 2001
120
KR
Hello, I'm strying to use CString with my windows programming, specifically

CString myString = "This is a test";
{CODE}
SendMessage (hwndLstBox, LB_ADDSTRING, 1, (LPARAM) myString);

Doesn't work, can't convert from CString to long.

Am I using it wrong, or whats the point in using CString if I can't pass it to windows procedures?

An LPARAM is a 32 bit value, and a CString can be substituted for LPCTSTR, which is a 32 bit pointer. Isn't a 32 bit pointer a value? Yes, it is pointing to something else, but that pointer has a value, and it occupies 32 bits. I understand it doesn't work, I don't know exactly why.

I guess the bottom line is, is there a way I can pass CStrings to windows procedures like SendMessage?
 
Well it's suficient to write something like this:

SendMessage (hwndLstBox, LB_ADDSTRING, 1, (LPARAM)((LPCSTR) myString));


Ciao,



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top