命名缩写

来源:互联网 发布:360网络控制软件 编辑:程序博客网 时间:2024/04/30 13:37
部分的缩写规范

完整单词
缩写

A

average
avg

B

back
bk

background
bg

break
brk

buffer
buf

C

color
cr,clr

control
ctrl

D

data
dat

delete
del

document
doc

E

edit
edt

error
err

escape
esc

F

flag
flg

form
frm

G

grid
grd

I

increment
inc

information
info

initial
init

insert
ins

image
img

L

lable
lab

length
len

list
lst

library
lib

M

manager
mgr,mngr

message
msg

O

Oracle
Ora

P

panorama
pano

password
pwd

picture
pic

point
pt

position
pos

print
prn

program
prg

S

server
srv

source
src

statistic
stat

string
str

Sybase
Syb

T

temp
tmp

text
txt

U

user
usr

W

window
win,wnd

附录二、匈牙利命名法
  a       Array                       数组
b BOOL (int) 布尔(整数)
by Unsigned Char (Byte) 无符号字符(字节)
c Char 字符(字节)
cb Count of bytes 字节数
cr Color reference value 颜色(参考)值
cx Count of x (Short) x的集合(短整数)
dw DWORD (unsigned long) 双字(无符号长整数)
f Flags 标志(一般是有多位的数值)
fn Function 函数
g_ global 全局的
h Handle 句柄
i Integer 整数
l Long 长整数
lp Long pointer 长指针
m_ Data member of a class 一个类的数据成员
n Short int 短整数
p Pointer 指针
s String 字符串
sz Zero terminated String 以0结尾的字符串
tm Text metric 文本规则
u Unsigned int 无符号整数
ul Unsigned long (ULONG) 无符号长整数
w WORD (unsigned short) 无符号短整数
x,y x, y coordinates (short) 坐标值/短整数
v void 空

有关项目的全局变量用g_开始,类成员变量用m_,局部变量若函数较大则可考虑用l_用以显示说明其是局部变量。

前缀       类型        例子
g_ 全局变量 g_Servers
C 类或者结构体 CDocument,CPrintInfo
m_ 成员变量 m_pDoc,m_nCustomers

VC常用前缀列表:

前缀   类型   描述                      例子
ch char 8位字符 chGrade
ch TCHAR 16位UNICODE类型字符 chName
b BOOL 布尔变量 bEnabled
n int 整型 nLength
n UINT 无符号整型 nLength
w WORD 16位无符号整型 wPos
l LONG 32位有符号整型 lOffset
dw DWORD 32位无符号整型 dwRange
p * 内存模块指针,指针变量 pDoc
lp FAR* 长指针 lpDoc
lpsz LPSTR 32位字符串指针 lpszName
lpsz LPCSTR 32位常量字符串指针 lpszName
lpsz LPCTSTR 32位UNICODE类型常量指针 lpszName
h handle Windows对象句柄 hWnd
lpfn (*fn)() 回调函数指针 lpfnAbort

Windows对象名称缩写:

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 hPalette; CPalette* pPalette;
HRGN hRgn; CRgn* pRgn;
HMENU hMenu; CMenu* pMenu;
HWND hCtl; CStatic* pStatic;
HWND hCtl; CButton* pBtn;
HWND hCtl; CEdit* pEdit;
HWND hCtl; CListBox* pListBox;
HWND hCtl; CComboBox* pComboBox;

(全文完)