Hungarian notation BOOL b Variable int INT n
变量名的匈牙利记法 Hungarian notation BOOL : b. Variable int, INT : n. Variable UINT : u. Variable char, CHAR : ch. Variable BYTE : by. Variable SHORT : s. Variable WORD : w. Variable LONG : l. Variable DWORD : dw. Variable FLOAT : flt. Variable DOUBLE : dbl. Variable CHAR[] : sz. Variable
class CSize : public tag. SIZE { 重载构造函数 public: CSize(); CSize(int init. CX, int init. CY); CSize(SIZE init. Size); 另外一个数据类 CSize(POINT init. Pt); 型 CSize(DWORD dw. Size); 。。。 低16位为cx 高 16位为cy
BOOL operator==(SIZE size) const; BOOL operator!=(SIZE size) const; 赋 void operator+=(SIZE size); 值 void operator-=(SIZE size); 运 CSize operator+(SIZE size) const; 算 CSize operator-(SIZE size) const; CSize operator-() const; CPoint operator+(POINT point) const; CPoint operator-(POINT point) const; CRect operator+(const RECT* lp. Rect) const; CRect operator-(const RECT* lp. Rect) const; 比 较
CSize的用法 SIZE size. Box 1={20, 40}; SIZE size. Box 2={60, 30}; SIZE size. Box 3=size. Box 1+size. Box 2; CSize size. Box(size. Box 1); CSize size. Big. Box = size. Box + size. Box 2; CSize SIZE 结果拷贝到
与CSize类似的类 : CPoint typedef struct tag. POINT { LONG x; LONG y; } POINT, *PPOINT, *LPPOINT; class CPoint : public tag. POINT { public: CPoint(); CPoint(int init. X, int init. Y); CPoint(POINT init. Pt); 。。。 。。。 };
与CSize类似的类 : CRect typedef struct tag. RECT { LONG left; LONG top; LONG right; LONG bottom; } RECT, *PRECT, *LPRECT;
与CSize类似的类 : CRect class CRect : public tag. RECT {public: CRect(); CRect(int l, int t, int r, int b); CRect(const RECT& src. Rect); CRect(LPCRECT lp. Src. Rect); CRect(POINT point, SIZE size); CRect(POINT top. Left, POINT bottom. Right); 。。。 。。。 typedef const RECT* LPCRECT; // pointer to read/only RECT
关于LPCTSTR和CString类 定义:typedef const CHAR *LPCTSTR; ® CString是管理字符串的类。 ® class CString LPCTSTR { public: LPCSTR CString(); CString(const CString& string. Src); LPCSTR CString(TCHAR ch, int n. Repeat = 1); 是单字节 void Func(LPCTSTR CString(LPCSTR lpsz); lpsz) CString(LPCWSTR lpsz); LPCWST CString(LPCSTR lpch, int n. Length); { CString str(lpsz); R CString(LPCWSTR lpch, int n. Length); int l=str. Length(); 是双字节 CString(const unsigned char* psz); } 。。。
关于LPCTSTR和CString类 int Get. Length() const; BOOL Is. Empty() const; 取值 void Empty(); TCHAR Get. At(int n. Index) const; TCHAR operator[](int n. Index) const; void Set. At(int n. Index, TCHAR ch); operator CString: : operator LPCTSTR() const; LPCTSTR() const 类型转换运算 使用实例:CString str; { return m_pch. Data; } LPCTSTR lpsz = (LPCTSTR) str;
const CString& operator= (const CString& string. Src); const CString& operator=(TCHAR ch); const CString& operator=(LPCSTR lpsz); const CString& operator=(LPCWSTR lpsz); const CString& operator=(const LPBYTE psz); const CString& operator+=(const CString& string); const CString& operator+=(TCHAR ch); const CString& operator+=(LPCTSTR lpsz); 。。。
® MFC是由一系列类(Class)构成的窗口 程序支撑体系。 CObject CCmd. Targ et CWnd CFrame. W nd CDocume nt CDialog CView CWin. App
® class CObject : ® ® ® 1) 一般诊断 Assert. Valid 2) 运行期识别 Runtime. Class 3) 串行化 Serialize 4) 动态创建 DECLARE_DYNAMIC/IMPLEMENT_DYNAMIC class CCmd. Target : public CObject ® ® ® ® 1) 消息发送 BEGIN_MESSAGE_MAP(CMy. View, Cview) ON_COMMAND(ID_FILE_OPEN, On. File. Open) … … END_MESSAGE_MAP() 2) 等待光标 3) 支持自动化 IDispatch COM
® class CWin. App : public CCmd. Target ® ® class CWnd : public CCmd. Target ® ® ® 1) 获取应用程序的信息。 2) 支持注册表 Registry. Key 3) 支持文档 Document Template 1) 注册新窗口类。 2) 创建和使用窗口 Create, Create. Ex; class CFrame. Wnd : public CWnd ® 标题栏、系统菜单、边框、最小/最大化
® class CView : public CWnd ® ® ® 1) 显示/打印的处理 On. Draw() 2) 与用户进行交互操作(鼠标/键盘) On. LButton. Down/On. LButton. Up On. Key. Down … … 3) 系统重画 Invalidate(); Update. Window(); class CDocument : public CCmd. Target ® ® ® 1) 文档的输入/输出。 Open. Document/Save. Document 2) 数据的保存和更新; 3) View的维护。
- Slides: 20