MFC命名規則:
Windows類型
|
樣本變量
|
MFC類
|
樣本變量
|
HWND
|
hWnd;
|
CWnd*
|
pWnd;
|
HDLG
|
hDlg;
|
CDialog*
|
pDlg;
|
HDC
|
hDC;
|
CDC*
|
pDC;
|
HGDIOBJ
|
hGdiObj;
|
CGdiObject*
|
pGdiObj;
|
HPEN
|
hPen;
|
CPen*
|
pPen;
|
HBRUSH
|
hBrush;
|
CBrush*
|
pBrush;
|
HFONT
|
hFont;
|
CFont*
|
pFont;
|
HBITMAP
|
hBitmap;
|
CBitmap*
|
pBitmap;
|
HPALETTE
|
hPaltte;
|
CPalette*
|
pPalette;
|
HRGN
|
hRgn;
|
CRgn*
|
pRgn;
|
HMENU
|
hMenu;
|
CMenu*
|
pMenu;
|
HWND
|
hCtl;
|
CState*
|
pState;
|
HWND
|
hCtl;
|
CButton*
|
pButton;
|
HWND
|
hCtl;
|
CEdit*
|
pEdit;
|
HWND
|
hCtl;
|
CListBox*
|
pListBox;
|
HWND
|
hCtl;
|
CComboBox*
|
pComboBox;
|
HWND
|
hCtl;
|
CScrollBar*
|
pScrollBar;
|
HSZ
|
hszStr;
|
CString
|
pStr;
|
POINT
|
pt;
|
CPoint
|
pt;
|
SIZE
|
size;
|
CSize
|
size;
|
RECT
|
rect;
|
CRect
|
rect;
|
一、MFC中ID 編號原則
IDC_:控件的ID命名前綴(Control)
IDM_:菜單的ID命名前綴(Menu)
IDD_:對話框的ID命名前綴(Dialog)
IDR_:資源的ID命名前綴(Resource)
IDS_:字符串的ID命名前綴(String)
IDB_:位圖資源的ID命名前綴(Bitmap)
二、MFC系統消息前綴小集
ABM 應用程序桌面工具條application desktop toolbar
BM 按鈕 button control
CB 組合框 combo box control
CBEM 擴展組合框 extended combo box control
CDM 通用對話框common dialog box
DBT 設備devicae
DL 下拉列表 drag list box
DM Default Push button control
DTM Date and time picker control
EM 編輯框edit control
HDM Header control
HXM 熱鍵hot key control
IPM IP控件IP address control
LB 列表框list box control
LVM 列表視圖list view control
MCM 日曆控件month calendar control
PBM 進度條progress bar
PGM Pager control
PSM 屬性property control
RB 伸縮條rebar control
SB 狀態條status bar window
SBM 滾動條scrol bar control
STM 靜態條static control
TB 工具條toolbar
TBM 跟蹤條trackbar
TCM Tab control
TTM Tooltip control
TVM 樹視圖tree_view control
UDM Up_down control
WM 一般窗口general window
vc資源名字定義格式:
單選項控件: IDC_RDB_XX //RDB:RadioButton
匈牙利命名法關鍵是:
標識符的名字以一個或者多個小寫字母開頭作爲前綴;
前綴之後的是首字母大寫的一個單詞或多個單詞組合,該單詞要指明變量的用途。
前綴 類型 a 數組 (Array) b 布爾值 (Boolean) by 字節 (Byte) == 8 bit c 有符號字符 (Char) cb 無符號字符 (Char Byte,沒有多少人用) cr 顏色參考值 (ColorRef) cx,cy 座標差(長度 ShortInt) dw 雙字 (Double Word) == 4 Byte == 4 * 8 bit fn 函數(function) h 句柄(Handle) i 整型(int) l 長整型 (Long int) lp 長指針(Long Pointer) m_ 類的成員(member of a class) n 短整型 (Short Int) np 近指針(Near Pointer) p 指針(Pointer) s 字符串型(string) sz 以字符''結尾的字符串 (String with Zero End) w 字(Word) == 2 Byte == 2 * 8 bit