Wince development records

Source: Internet
Author: User

 

Record:
Due to the project demonstration needs in the past few days, we have to extend the original PC & settopbox-based solution to the handheld terminal, so we have received a task, the original version was transplanted to the handheld terminal in the shortest time. Since Windows Mobile was not used in the past, and considering the time problem and the PDA processing capability, a simple version was created first, however, the effect achieved today is quite dazzling. Finally, we made the first window mobile software. Today we use this document to record

 

After a simple development process and some problems (I haven't written a blog for a long time), My JXTA journey also paused for a while!

1. Since we used MFC to develop desktop programs, we also used Pocket pc mfc in Win CE this time, and found that the development process was basically the same.
2 projects on the Pocket PC can only be set to Unicode, because I have previously changed Unicode to multi-byte characters, so this development has led to many types of conversion.
1) In APIs similar to afxmessagebox () setwindowtext (), the parameters must be of the lpctstr type. If the string type is forcibly converted, garbled characters may occur. In this case, I found a simple method:
Uses_conversion;
A2w (): Convert ASCII to wide char
W2a (): Convert widechar to ASCII
This type of conversion is convenient and requires no complicated functions.
3. wince background color change problem: In MFC, you can change the dialog box color in onctlcolor (). In wince, you can also use this method, but you will find that, in change dialog box color
If (nctlcolor = ctlcolor_dlg) will tell you that ctlcolor_dlg is not identified. by viewing the header file, we find that this ctlcolor_dlg is not defined, but it is strange that others such:
# Define ctlcolor_msgbox 0
# Define ctlcolor_edit 1
# Define ctlcolor_listbox 2
# Define ctlcolor_btn 3
# Define ctlcolor_scollbar 5
# Define ctlcolor_static 6
# Define ctlcolor_max 7
There is a definition, but there is only a "4" missing. As long as the code is changed to If (nctlcolor = 4), the color of the dialog box can be changed. Why does Microsoft do this?
4 In the socket API, some setsockopt functions are not supported on WinCE. I thought the download speed was quite slow and I wanted to set the receiving buffer to a greater value. But in setsockopt (sock, sol_socket, so_rcvbuf, XX, XX), the error code 10042 is displayed. This error code does not support setting at this level or on this options. The following explanation is found:
In platform Builder 4.0, the documentation incorrectly states that setsockopt () supports the so_rcvbuf option.
In fact, support for the so_rcvbuf option was later added in Windows CE. net version 4.1. the Platform builder 4.1 documentation was updated to reflect the fact that you can use so_rcvbuf for datatesockets. it can only be set on datemedisocket. The only for datemedisockets is also described in msdn.

5 This time I didn't use the csocket ghost. It was much more comfortable, but less on multithreading. I won't encounter any inexplicable errors. I need to attach and detach on csocket, Which is annoying, on the csdn forum, I often find someone asking this question. I suggest using APIs. It's comfortable and easy to control !!

6 although the software is relatively small this time, I made a good choice with observer pattern because during TCP download, after downloading, there are two different update Methods (one is to update the tree list and the other is to enable the playing media). If you use the timer to poll the variable to confirm that the update is complete, certainly not good. So we use the Observer Pattern and use the interface observer to inherit two xxobservers. Each of them has its own update method.

In the program, you only need to use this update with Polymorphism to achieve the update effect, and the code is also easy to write, good maintenance, good and good! The Mode also makes me understand some basic object-oriented features, at least a little bit.

7. When Windows Mobile was connected to the PC through USB during the UDP multicast test of wince, udp could not be tested (I thought the code was wrong for a long time ), it is said that it is related to the port (not specific). If you want to test multicast, You need to unplug the USB to test.

8. To test TCP, you can directly simulate it through the Pocket PC simulator on the PC. Here is a brief introduction to the simulation process I understand:
1) by default, the Pocket PC simulator of vs2005 is placed under the Microsoft device emulatorfolder in the program file, with a memory dvcemumanager.exe in it. This is the tool used to manage simulation.
2) Open the simulator, right-click the device and click "Connect". The device will pop up and right-click "insert base". The device will be connected to the PC synchronously, the connection settings on the PC need to be checked with "allow connection to any of the ports"
3) at this time, the simulator is the same as your handheld device. You can copy data to each other through USB.
9 use of some basic functions:
1. Obtain the path:
Uses_conversion;
Wchar_t pbuf [256];
Getmodulefilename (null, pbuf, sizeof (pbuf)/sizeof (wchar_t ));
Strapppath = w2a (pbuf );
2. Create a folder
Strmediadirpath + = "// Media ";
Createdirectory (a2w (strmediadirpath. c_str (), null );

OK
That's all!

Below is

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.