Re: getting the text of an edit control (edit box)
- From: r_z_aret@xxxxxxxxxxxx
- Date: Wed, 22 Jun 2005 12:19:41 -0400
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
.
- Follow-Ups:
- Re: getting the text of an edit control (edit box)
- From: Virgilio Alexandre Fornazin
- Re: getting the text of an edit control (edit box)
- References:
- getting the text of an edit control (edit box)
- From: Matthias Heise
- Re: getting the text of an edit control (edit box)
- From: r_z_aret
- Re: getting the text of an edit control (edit box)
- From: Matthias Heise
- getting the text of an edit control (edit box)
- Prev by Date: Re: Combo loading problem
- Next by Date: Re: Set password with CAB file
- Previous by thread: Re: getting the text of an edit control (edit box)
- Next by thread: Re: getting the text of an edit control (edit box)
- Index(es):
Relevant Pages
|