Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 803
  • Last Modified:

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
0
madonion87
Asked:
madonion87
1 Solution
 
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
 
madonion87Author Commented:
yea that works, thanks
but i've found another problem lol
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now