Re: getting the text of an edit control (edit box)



I suspect you are still trying to learn this stuff piecemeal, rather
than taking time to really learn it. Very dangerous and a likely waste
of time in the long run. But I answered some of your questions below.


On Tue, 21 Jun 2005 23:28:13 +0200, "Matthias Heise" <nagilo@xxxxxx>
wrote:

>Thanks for this important help.
>
>I was blind. I'm getting the text over the network from a normal machine and

I think "big" Windows is a generally accepted term for 9x/NT/2K/XP.
Not a great term, but about as good as any I've seen.


>put it into the edit box. For this step I used mbstowcs. It's logically that
>I have to use wcstombs in return.
>
>One question for understanding: Normal windows machines are using characters
>with 4 bytes and WinCE only 2 bytes?

"Big" Windows _applications_ use non-Unicode by default. That means
char, which is 2 byte. But many applications choose to use UNICODE.
Windows CE always uses UNICODE, with limited support for char. That
means WCHAR, which is 4 byte. If you are using the same source code
for both, you should use TCHAR, which switches. You can definitely
find good descriptions of this using google.


>
>Thanks
>
>Matthias
>
>_________________
>The code is as follows:
>
>unsigned short* str = (unsigned short*)malloc(512);

Why are you using unsigned short, rather than WCHAR?


>char *text = (char *)malloc(256);
>
>// conversion of multibyte characters to WinCE used wide characters
>mbstowcs((unsigned
>short*)str,currentElementValue,strlen(currentElementValue)+1); //
>currentElementID is given as char*
>SendMessage (hWndTextbox, WM_SETTEXT, 256, (LPARAM) (unsigned short*) str);
>// set the correct text in the edit box

Why the cast to unsigned short?


>
>SendMessage (hWndTextbox, WM_GETTEXT, 256, (LPARAM) textBuffer); // gets
>the text from the edit box (after the user edit)

I suggest using SetWindowText, rather than SendMessage so the compiler
can do proper type checking.


>
>// reconversion of wide characters to multibyte characters
>wcstombs(text, (unsigned short*) &textBuffer, 256);

Why are you working so hard to convert strings back and forth, rather
than using them in "native" form?


>
>free(str);
>free(text);
>

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com
.



Relevant Pages

  • Re: Greatest strengths
    ... My unit is probably a chapter and as they are short I summarise ... action or the words but the idea flow if you like. ... I think that's still true even in edit - you might ... contains (ideas I had before I knew the characters well). ...
    (rec.arts.sf.composition)
  • Re: Wave 3 makes the Hotmail UI as convenient as punch cards
    ... Only by whatever code is implemented within an e-mail client. ... use vertical bar characters if it wanted to. ... But what happens is that when you try to edit ... Maybe you should consider using the Bcc field if your recipients are to ...
    (microsoft.public.internet.mail)
  • Re: limiting edit box characters
    ... > controls on the page and they all have different characters they can ... > looked for an event for edit box that tells when a new character is ... Derive a class from CEdit. ... class for your edit controls. ...
    (microsoft.public.vc.language)
  • Re: Bringing things to a close - suggestions?
    ... I'm also practising by writing a book - it's a first novel attempt set on an alternative world. ... Before I started writing I'd planned out the storyline, but now I'm seven chapters into the first draft and the characters have taken over the writing process completely and there's no way I can see to get from where I am now to where I intended the storyline to go when I was planning the book. ... Eventually you'll get a feel for it and be able to either move the characters into the plot you need, or find a new plot in their actions that satisfies you. ... Then be prepared to revise, redraft, edit, slaughter deathless prose, and kill your favorite character if you have to. ...
    (rec.arts.sf.composition)
  • Re: getting the text of an edit control (edit box)
    ... I'm getting the text over the network from a normal machine and ... put it into the edit box. ... Normal windows machines are using characters ... // conversion of multibyte characters to WinCE used wide characters ...
    (microsoft.public.pocketpc.developer)