Re: simple serial string display help
- From: "benkokes@xxxxxxxxxxx" <benkokes@xxxxxxxxx>
- Date: 4 Oct 2006 16:58:51 -0700
Paul, thats exactly what I needed to know! Thank you.
Now, just one more piece of help, if you dont mind. The WM_PAINT will
just pull in the value of the serial stream at the time of starting the
application. I figure there is some sort of API message that will
check when there is new data, that will allow me to "repaint" the
screen, but I dont exactly know what to look for... I was thinking of
WM_SOCKET_NOTIFY, but I dont think thats quite the correct direction.
Would you happen to know if there is some sort of "message" that will
allow me to check for new serial data? If not, I am going to have to do
some sort of timer, which would not be as desireable...
Thank you,
-Ben
Paul G. Tobey [eMVP] wrote:
Well, application programming for Win32 is too big a topic for a newsgroup.
I'll give you a skeletal set of steps and you'll have to figure out the rest
or be more specific about what the problem is.
1. Use the New Project wizard in eVC to generate the Hello, world
application (which seems to have been done).
2. Look at the handling of the WM_PAINT message in the main window's window
procedure (just search the code for "WM_PAINT"). What that does is a) start
the paint process, b) get the client (drawable), area of the main window (a
rectangle), c) load a static string which is in the resources for the
application (defined in the .rc file and built into the .exe by eVC), d)
draw the string in the middle of the client rectangle, and e) complete the
paint process.
3. So, what you need to do is get the serial character that you want to
display and use the same code as in the default WM_PAINT, *except* drawing a
string consisting of just that one character. I'll assume that you're
right, that you do know how to get serial data, and that you've stored the
character in a global variable called g_lastSerialChar. In WM_PAINT, then,
you don't need the LoadString call any more. You can comment that out.
Instead, you need to put the g_lastSerialChar in the first character
position of szHello and make sure that the next character is 0, to terminate
the string.
Here we get into a long discourse on Unicode. Windows CE programs are *all*
Unicode based. This is different than the desktop, standard C, etc.
programs that you're likely to see. Pretty nearly every string that you'll
use in Windows CE, other than serial port data, file data, and network data,
is expressed in Unicode characters, *not* of standard C data type 'char'.
Each Unicode character is 16 bits, unsigned short or wchar_t, long. So, we
have a single char, but we need to pass DrawText a Unicode string. In this
case, for a single character, it's pretty easy, since the serial data is
presumably 7-bit ASCII, you can just assign the characters:
szHello[0] = g_lastSerialChar;
szHello[1] = 0;
DrawText(...);
For more complicated strings, you'll want to use a conversion functions
(which will also allow you to handle non-English languages). Those are,
amongst others:
MultiByteToWideChar()
WideCharToMultiByte()
They're in the help.
Paul T.
"benkokes@xxxxxxxxxxx" <benkokes@xxxxxxxxx> wrote in message
news:1159999651.810316.298780@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hey all,
So I would like to make a very small WinCE 2.11 application that would
take a serial stream and display the incoming 8-bit word on the screen.
Basically I would like to take the default "Hello World" applicaiton
and replace the words Hello World with a character (whatever ascii
character gets transmitted over the serial line) on the display. Just
one character, I dont want it to scroll, or move.
I cant think that it would be all that hard, but the Hello World
example in eVC 3.0 has it pointing to a .rc file and I have never dealt
with those before.
I think I understand how to setup the serial comms part of the code,
but I dont quite understand how to update the display of the character
on the screen.
I bought the Windows CE developers Kit which contains the books, but
its all still a hair convoluted...
Any help would be appreciated.
Thanks!
-Ben
.
- Follow-Ups:
- Re: simple serial string display help
- From: Paul G. Tobey [eMVP]
- Re: simple serial string display help
- From: <ctacke/>
- Re: simple serial string display help
- References:
- simple serial string display help
- From: benkokes@xxxxxxxxxxx
- Re: simple serial string display help
- From: Paul G. Tobey [eMVP]
- simple serial string display help
- Prev by Date: Re: simple serial string display help
- Next by Date: Re: simple serial string display help
- Previous by thread: Re: simple serial string display help
- Next by thread: Re: simple serial string display help
- Index(es):
Relevant Pages
|
Loading