Write nativeCodeOne week later, I have some feelings.
Before:
- I have been studying C # for about 4 years (I have been studying C # for three and a half years in a university), and I am familiar with C #2.0.
- Tcpl, or K & r c, read twice or three times (at least); C and pointer, read at least three times
- TC ++ PL has been read more than once (mainly used as a Tool Book)
- A little understanding of C/C ++ syntax (simple C ++ code can be understood)
- I have read programming language for a few months (I haven't read it once, because it is an English version), so I can understand the working mode of windows.
Syntax is not a problem for me. At the beginning, I wrote out the UI code with my own ideas (I prefer something unrelated to the UI ). code Writing in addition to the UI is still relatively simple. After all, it is an application and there are not many problems. When the UI speed is reached, I don't know how many times ...... The hardships were hard to describe in words, and the reading of the news was very fast (it was not psychological and it was almost physical ).
To this end, I also used MFC. I am very fond of MFC, but I cannot solve those complicated problems with Win32 ......
Let's summarize some questions:
1. Access deny ??)
One of the most common problems is that I applied for memory and added constant n to the length of the original string, but it was written as follows during code writing:
// Wchar_t * _ STR = new wchar_t [wcslen (STR) + N];
Wchar_t * _ STR = new wchar_t [sizeof (STR) + N];
The symptoms of the problem are quite strange. In debug, access is not fixed ...... I was dizzy at the time. Fortunately, there was an old project that could be run and the problem was discovered only by comparing the differences.
Because C # code writing is used to it, one bad thing is to return automatic variables ...... (It can be solved through new/delete)
The subsequent MFC propertysheet crash is solved by experience.
2. garbled characters
There are two types of garbled characters: one is read from the file and the other is converted from Char and wchar_t.
After reading from the file, I sum up that as long as the file encoding is changed to the default value and then read from the wifstream, there will be no garbled characters;
I like STL (For this reason I have suffered a lot). When I find a string, I mistakenly write it into L' = '. Then, through the ca2t conversion, it becomes a bunch ????, Although c_str is normal ......
3. API design
The wince API only supports wchar_t, So I sum up my experience, that is, all the APIs are designed as wchar_t instead of char APIs, which will only make the problem more complicated, or bring more problems.
4. Be careful
The C/C ++ compiler provides you with limited information. Sometimes, some strange prompts are generated ...... Need to be careful and sum up experience
5. UI
I am speechless about this UI. I don't like the UI, but it doesn't work if there is no UI in the app. it is more difficult to do the UI with Win32 alone, and MFC/wtl can simplify the problem a little. but to be beautiful, we need to bring MFC/wtl back to its original shape ......
Once, I was very much looking forward to the xaml c ++ API of Wince 6.0 R3. If I used that, the Win32 UI would be very good, but WP 7 cut it down ......
I really don't know how to implement the Win32 UI. You can tell it in the same industry.
6. debugging
I have read the code I wrote half a year ago. I used MessageBox for debugging in debug (macro). Currently, MessageBox is less used, mainly relying on the compiler (Khan)
In the future, log and TDD may be required to solve the debugging problem. After all, the efficiency is too low.
7. Learn with humility
I have been soaking in the WM version of The devdiv forum, where I found more than N monsters:
Who have 6 K of graduation salary, the most important thing is that it is still 10 years...
What to writeProgramThis kind of person has been in China for 15 years.
There are too many Nb people (there are a bunch of such people as Big V, Dao Ge, tomcat .......)