Best type for text in Win32 API

Hi
I'm having real problems with lines of text, getting 'can't convert errors' when passing text to SendMessage functions and problems with converting when passing to other functions. I have tried wstring and TCHAR but both give problems when converting to LPARAM (and other way around) for SendMessage.

What would be the best format to use? Should I use Unicode character set or not (maybe it would be better without it because it sometimes gave me chinese characters but without it I'm having problems with 'converting errors')? And in what type of format should I hald the text?

To give an idea of my program. It takes a text file (takes strings and puts them into a vector. I don't know its the right thing to do?) and displays it in a listbox(I have buttons to delete lines from the listbox and send lines over USB). I also have functions to send messages to another listbox for debugging purposes.
Should I convert text I get from SendMessage to char or string? Or should I leave it as LPARAM.
In the end, I plan to send text from the listbox over USB to a LIN modem (not started hat part yet). What would be the best text type to use for my purposes?

Thanks
if you don't need to use UNICODE, I suggest that you don't do it.

look at the project settings:

http://msdn.microsoft.com/en-us/library/669zx6zc%28v=vs.71%29.aspx
http://msdn.microsoft.com/en-us/library/8x480de8%28v=vs.71%29.aspx

The entry Character Set: Coose multibyte.

what exactly is the 'convert error'?
It shouldn't be problem to cast like so: (LPARAM) str.c_str()
OK, will try multibyte. At the moment I still get some conversion errors because I tried a lot of solutions and some need changing.

But what format shold I use for the vector tha takes the lines from .txt file? (currently use std:string)
std:string is ok.

Whenever the api requires a string (like the famous LPCSTR) you can use the c_str() member function of std:string
I don't think I really get the L... formats. I'm tring to take a line from one listbox and put it to another but I only get a long line og strange symbols(similar to G).

1
2
3
WCHAR* chBuffer[MAX_PATH];
SendMessage(hhListBox, LB_GETTEXT, selec, (LPARAM)(chBuffer));
SendMessage(hListBoxPrint, LB_ADDSTRING, 0, (LPARAM)(chBuffer));


No idea why the normal text doesn't show up.
And how would I convert chBuffer to string so that I could write it into a .txt file?
WCHAR is still UNICODE. Better use TCHAR instead.

your problem is that you provide a pointer to the buffer not the buffer itself. Change it to
1
2
3
TCHAR chBuffer[MAX_PATH]; // Note: NO *
SendMessage(hhListBox, LB_GETTEXT, selec, (LPARAM)(chBuffer));
SendMessage(hListBoxPrint, LB_ADDSTRING, 0, (LPARAM)(chBuffer));


Read this:
http://msdn.microsoft.com/en-us/library/aa932875.aspx
Still only get a line of 'ΔΆ' symbol
I don't know why but it works when I do it all in 'LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)' function.
I have no idea why it wouldn't work call another function (send listbox HWND and item nr to it). Any ideas?
Topic archived. No new replies allowed.