Page 1 of 1

PostPosted: Wed Mar 17, 2004 10:57 pm
by daparty
I'm new to PocketC (2.0) and have a question about an Edit box. How do I highlight the information in an EDIT box so that the information is showing as inverse and clears itself when new information is entered. This is similar to having information in the Edit box and double tapping it to highlight what's there before entering new information. I don't want to double tap the screen, but have the program do it after I act on the input and have the old information still showing as inverse and ready to accept any new input.

I just got an HP Jornada 547 to play with and found PocketC when doing a search for information about the Jornada. Now I'm more interested in programming it then using the other programs that are already on it. From the information I've found, apparently I'm a few years past the high point of PocketC.:(

I have a 256 meg compact flash card for a digital camera that works just fine in the Jornada. I use the compact flash for MP3 files and to transfer information when I don't want to use the active sync software. When I want to use the card in the camera again, I'll just copy the card to my PC.


PostPosted: Fri Mar 19, 2004 3:06 pm
by wolfgang

I'm writing the following from memory (have to wait to get home tonight before I can check in my PocketC code base):

To highlight a portion of the text displayed in the edit box, send a message to to control ID of the edit box (MY_CTRL_ID):

sendmsg (MY_CTRL_ID, EM_SETSEL, startpos, endpos);

startpos and endpos are the first and last character position you want to highlight. The position numbering starts from 0. If your editbox contains "Hello" (length 5) and you want to highlight the whole word, set startpos to 0 and endpos to 4.

To get the length of what is in the edit box and highlight it, use:

string s;
int len;

s = editget (MY_CTRL_ID);
len = strlen (s);
sendmsg (MY_CTRL_ID, EM_SETSEL, 0, len - 1);

That was for clarity; of course you can write all that much more compact as:

sendmsg (MY_CTRL_ID, EM_SETSEL, 0, strlen (editget (MY_CTRL_ID)) - 1);

If it does not work as described above, drop me a note ( and I look it up in my code (my program MidNote uses it, so I know it works somehow).


Composing music on the PocketPC! -

PostPosted: Fri Mar 19, 2004 3:14 pm
by wolfgang
I think you also need to set the focus to the editbox after you selected the text:

guisetfocus (MY_CTRL_ID);


Composing music on the PocketPC! -

PostPosted: Fri Mar 19, 2004 11:09 pm
by daparty
Thanks Wolfgang :), thats exactly what I was looking for.

I had a little problem with EM_SETSEL since it isn't
defined in the pcheader.h file. I did a search and ended
up on Microsofts page where I found all sorts of information
on different functions. I found that EM_SETSEL is
defined as 0x00b1.

Thanks again,


PostPosted: Sat Mar 20, 2004 3:02 pm
by wolfgang
EM_SETSEL (and a lot of other constants that are useful in PocketC) is defined in the file windefs.h, which is part of PCFOrm. Download the demo version of PCForm from


Composing music on the PocketPC! -

PostPosted: Sat Mar 20, 2004 3:03 pm
by wolfgang
I checked my code at home, and it looks like the sendmsg() call is slightly different:

sendmsg (MY_CTRL_ID, EM_SETSEL, startpos, len);

i.e. for your case

sendmsg (MY_CTRL_ID, EM_SETSEL, 0, strlen(editget(MY_CTRL_ID)));

By the way, editset() can be used to change the label of any control (most important labels, command buttons and check boxes), not just the text of edit boxes.

For more information about GUI and controls go to Download the demo version of PCForm, it contains a pretty good description of all the controls and what you can do with each of them. In addition, create some small program with PCForm and look at the PocketC code it produces, that gives you some good ideas (I learned a lot by doing that), epecially regarding event handling and all the different options for the different controls.

Two files you will find helpful: windefs.h and pcheader.h (the first comes with PocketC, the second comes with PCForm). They contain (almost) all the constants for sendmsg and createctrl you can use, and I browsed them when I wanted to find some specific functions.

Composing music on the PocketPC! -