Reputation: 6627
I need to display the text on Text Box whatever data retrieve from files.
On push of particular button (IDB_SHOW_BUTTON) in windows application, I am doing as mentioned below:-
case IDB_SHOW_BUTTON:{
char buf[1000];
vReadFileFromHardisk(buf); //storing the read data of file to buffer
SendMessage(editHwnd,WM_SETTEXT,NULL,(LPARAM)buf);//Due to this, I get junk text.
}
break;
I am reading data from file and storing it into buffer. I don't understand why i am getting junk text whenever I am clicking on the button.
When I change the 4th parameter of SendMessage i.e. as mentioned below, I get the proper output on push of a particular button:-
SendMessage(editHwnd,WM_SETTEXT,NULL,(LPARAM)L"My First Edit Window");
Please let me know to how to display the proper text in case of storing data to buf and sending the same through SendMessage.
Thanks in advance.
Upvotes: 1
Views: 1111
Reputation: 34418
See the 'L' in the working example? You're passing a narrow character string into a function that expects Unicode.
You'll need to either
I strongly recommend 1 and getting used to using Unicode (a.k.a. UTF-16) throughout your program.
Upvotes: 2