2008年7月30日星期三
Visula Studio Tips
2008年7月22日星期二
Expression Blend Tips
2008年7月9日星期三
Use Google Reader read RSS
2008年7月7日星期一
Minimun Windows Version for VC2008
Origin : in Chinese, in English
---- from MSDN ---
Visual C++ 概念:移植和升级
如何:修改 WINVER 和 _WIN32_WINNT
从 Visual C++ 2008 开始,Visual C++ 不支持面向 Windows 95、Windows 98、Windows ME 或 Windows NT。如果您的 WINVER 或 _WIN32_WINNT 宏被指定到这些 Windows 版本之一,则需要修改宏。当升级从 Visual C++ 的以前版本创建的项目时,如果将 WINVER 或 _WIN32_WINNT 宏指定到不再受支持的 Windows 版本,可能会看到与这些宏相关的编译错误。
2008年7月6日星期日
New Updates to MFC in VS2008
2008年7月4日星期五
WPF ?
To develop WPF application, you need these dev tools:
1, Visual Studio 2008 (or 2005 with some sp);
2, Microsoft Expression Blend, for the GUI programming, if you never heard it, google it.
2008年7月3日星期四
The power of UserControl
Senario 1:
You need display a image in your program. You can use xaml only, or you can use C# codes only. In some cases, combine xaml and Csharp is powerful. First you create a UserControl which only contain the picture, then you get a new class. In Cshap codes, you just "new" one instance.
If you create a image use codes only, you need there lines at least:
Image img = new Image();
BitmapFrame bmp = BitmapFrame.Create(new Uri(@"C:\myImage.jpg", UriKind.RelativeOrAbsolute));
img.Source = bmp;
img.Stretch = Stretch.Fill;
But, use expression blend, you can create a new user control just by several mouse click. Then in codes, just one line:
new MyImage();
Data Binding
Data Binding is a key concept in WPF.
Why I can NOT data bind my class ?
public class MyClass
{
public string MyPorperty { get; set; }
}
First time, I trid to bind MyProperty in MyClass to a TextBox, but I can NOT. Why? Because I did not derived my class from interface INotifyPropertyChanged.
public class MyClass : INotifyPropertyChanged
{...}
Yes, we have to implement the interface. Csharp is a great programming language, but not magician words. So when your data changed, you have to tell the framework the change happened. That's why you need the interface.
Same reason, when you implement you own collection class, you have implement the INotifyCollectionChanged. You may encounter some problem when you want to bind a List to ComboBox/ListBox/ListView. No, you are using the wrong class, you should use ObservableCollection instead.
Use ValidationRule to check your input
-
Let's use TextBox as a sample. You can set a validation rule to the binding. When the rule check failed, a red ring will around the text box.
Related classes: System.Windows.Data.Binding, System.Windows.Controls.ValidationRule
-------------------------------------------
Some Other Good Readings:
2008年7月2日星期三
Regular Expression
Senario:
We need user to input string in a text box, the string represent a frequency value, like "10.000 MHz".
Validation rule: (top down are the charaters can legally show in the string)
0 to N spaces
0 to N figure(0,1,2...9)
0 or 1 dot
1 to N figures
0 to N spaces
0 or 1 letter(the letter could be k, K, m, M, g, G)
0 or 1 letter(h or H)
0 or 1 letter(z or Z)
0 to N spaces.
C# Codes:
Regex r = new Regex(@"^\s*\d*[.]?\d+\s*[kKmMgG]?[hH]?[zZ]?\s*$");
Match m = r.Match(" 20000000000 ghz");
if (m.Success)
{
Console.WriteLine("Found match at position " + m.Index);
}
What simple! You can image how hard this could be when you just use CString, or string classes.
See detail about regular expression here.
DocProject, a document generate tool
- VisualStudio 2005 or 2008;
- Sandcastle
- Help 1.x
- Help 2.x (optional)
- DocProject
Make your "Hello World" DocProject
- Create a C# project, do some comments in the codes, check the "XML Documentation File" in project properties "Build" tab.
- Create a DocProject project, just follow the wizard, you can easily to setup it;
- Compile the projects, this may take some time, just be patient.
- After compile finished, you get your document. Yeah~~
Others
After do these, you may get a compile warning 1591, because you are not comment all the classes, functions, etc. Your can suppress this warning in project properties "Build" tab.