working with richedit controls

hi

i'm using win32 api to make a program thats similar to a notepad, it have to accept and save characters of different languages. atm i have the richedit control created but i tried to use EM_GETTEXTRANGE msg to get the stuff in the control to save it but i cant convert wchar_t (which is the type my buffer used to store the stuff) to LPSTR
basically whats happening now is that i created a TEXTRANGE object which consist of 2 part, 1 is a CHARRANGE and the other is a pointer to a string where i'm going to store the stuff. then the TEXTRANGE pointer that i created will be passed to SendMessage with parameter (editbox, EM_GETTEXTRANGE, 0, (LPARAM) textrange)
this should store the stuff that is typed in the edit control to the wchar_t buffer.

code:
buff = new wchar_t[length];
 LPWSTR wstr = buff;
                                          
CHARRANGE charrange;
charrange.cpMin = 0;
charrange.cpMax = -1;

TEXTRANGE *textrange = new TEXTRANGE;
textrange->chrg = charrange;
textrange->lpstrText = wstr;

SendMessage(editbox, EM_GETTEXTRANGE, 0, (LPARAM) textrange);

any help is very appreciated
madonion87Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nonubikCommented:
buff = new wchar_t[length];
 char lpstr[length];

wcstombs(lpstr, buff, length-1);
                                   
CHARRANGE charrange;
charrange.cpMin = 0;
charrange.cpMax = -1;

TEXTRANGE *textrange = new TEXTRANGE;
textrange->chrg = charrange;
textrange->lpstrText = lpstr;

SendMessage(editbox, EM_GETTEXTRANGE, 0, (LPARAM) textrange);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
madonion87Author Commented:
yea that works, thanks
but i've found another problem lol
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.