I decided to write for the first time, a program for the SmartPhone and found that there are many differences that need to be overcome compared to the Pocket PC. However there is not a lot of help so I decided to share a few of the tricks I found with you. Hopefully it will make SmartPhone development a little easier. Because of the time I have available, I will share one tip at a time.
This article deals mainly with MFC and dialog based applications. There is not a lot of help when coding using the MFC classes and dialog based applications for the SmartPhone. I also found that in VS 2005 help files, they removed a lot of the sample code.
The SmartPhone does not have a touch screen and therefore it does not natively support the Combobox. The help files tell you to use a Spin-Box. You will not find this control in the tools drop down. It has to be created using a Spin Control and a Listbox.
A Spin control must be attached to the Listbox in the code.
Here is how it is done...
First you add a listbox to your dialog. Use the following attributes:
- No Integral Height=TRUE
- Vertical Scrollbar=TRUE
and give it an ID - we will use
Then you add a Spin Control. The control attributes are:
- Arrow Keys=True
- Set Buddy Integer=TRUE
Then you need to add control variables to the listbox and spin controls, we will add
m_ctrlControl1 for the listbox and
m_ctrlSpin1 for the Spin Control.
Next you need to add a string variable for the listbox, for this demo we will assign a
Next, you will need to tie the Spin control to the list box. In the
InitDialog of your application, add the following code:
Now we are ready to populate the control:
Now you can set the text to default to the first entry like this:
There you have it... A
SpinBox control for the SmartPhone.
In my next article, we will discuss how to set the back arrow key on a Smartphone to act as a Backspace key while in a textbox.