Hungarian nomenclature

xiaoxiao2021-03-06  23

The Hungarian nomenclature is a naming specification for a variable, function, object, prefix, macro definition, and other types of symbols. The main idea of ​​Hungarian nomenclature is: adding prefix in variables and function names to enhance people's understanding of procedures. It is used by a Hungarian in Microsoft, and it is gradually popular in Microsoft, and promotes Windows developers around the world.

Naming specification does not have to follow, the unregulated code can be running, but only the specified code can make others understand, and only the standard code can better maintain.

Naming Specification for MFC, handle, control and structure

Windows type sample variable MFC class sample variable HWNDhWnd; CWnd * pWnd; HDLGhDlg; CDialog * pDlg; HDChDC; CDC * pDC; HGDIOBJhGdiObj; CGdiObject * pGdiObj; HPENhPen; CPen * pPen; HBRUSHhBrush; 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; generic prefix naming

Prefix Type Instance C Class C or Structure CDocument, CPrintInFom_ Member Variable M_PDOC, M_NCUSTOMERS Variable Name Specification

Prefix Type Description Instance Chchar8 Bit Character Chgradech Tchar If _unicode definition, 16-bit character chnamebbool Boolean Benablen int integer (whose size depends on operating system) NLENGTHN UINT No symbol value (whose size depends on operating system) NHEighTW Word 16 Non-symbolic WPOSL Long 32-bit Symbol Integer LoffSetDW DWORD 32-bit No Symbol Integer DWRANGEP * Pointer PDOCLP FAR * Far Pointer LPSZNAMELPSZ LPSTR 32 Bit Characters LPSZNAMELPSZ LPCSTR 32-bit Constant string pointer Lpsznamelpsz lpctstr If _unicode definition, The 32-bit constant string pointer LPSZNAMEH HANDLE Windows object handle hwndlpfn callback points to the far pointer application symbol naming specification for the Callback function

Examples of types of symbols prefixed range IDR_ Help context HIDD_SPELL_CHECK plurality of different types of resource-sharing identification IDR_MAIINFRAME1 ~ 0x6FFFIDD_ dialog resource IDD_SPELL_CHECK 1 ~ 0x6FFFHIDD_ dialog resource 0x20001 ~ 0x26FFIDB_ bitmap resource IDB_COMPANY_LOGO 1 ~ 0x6FFFIDC_ cursor resource IDC_PENCIL 1 ~ 0x6FFFIDI _ icon resource IDI_NOTEPAD 1 ~ 0x6FFFID_ command from the menu or toolbar ID_TOOLS_SPELLING 0x8000 ~ 0xDFFFHID_ command Help context HID_TOOLS_SPELLING 0x18000 ~ 0x1DFFFIDP_ message box prompts IDP_INVALID_PARTNO 8 ~ 0xDEEFHIDP_ message box Help context HIDP_INVALID_PARTNO 0x30008 ~ 0x3DEFFIDS_ string resources IDS_COPYRIGHT 1 ~ 0x7eefidc_ dialog box Control IDC_Recalc 8 ~ 0xdeefmicrosoft MFC Macro Name Specification Name Type_AFXDLL Unique Dynamic Library (DLL) version _alpha only compile DEC Alpha processor _debug includes the diagnostic debug version _mbCS Compile multibyte character set _unicode Open UnicodeafxAPI MFC in an application Callback passed the function library identifier nomenclature by pointer callback

Identifiers and Meaning U ANSI (N) or Unicode (U) D debug or release: d = debug; ignore the identifier is issued. Static library version naming specification

Description Nafxcwd.lib debug version: MFC Static connection library NAFXCW.LIB Release: MFC Static connection library uafxcwd.lib debug version: MFC static connection library with Unicode support UAFXCW.LIB Release: MFC static connection library supported by Unicode Dynamic connection library naming specification

Name Type_AFXDLL Unique Dynamic Connection Library (DLL) Version WINAPI Windows Functions WINDOWS.H China New Naming Specification

Type Definition Description WinAPI uses the FAR Pascal location in the API declaration, if you are writing a DLL with exporting API people, you can use this type of Callback in your own API to use in the application recursive routine, such as windows and conversations The position LPCSTR of the FAR PASCAL in the frame is the same as LPSTR, just LPCSTR is used for read-only string pointers, which defines similar (const char far *) uint-free integer type, whose size is determined by host environment (for Windows NT and Windows 9x are 32 bits); it is the synonym of unsigned int LRESULT window program Return Value LPARAM declares that the type used by LPARAM, LPARAM is the fourth parameter of the window, WPARAM is used, WPARAM is a window. The third parameter of the program LPVOID general pointer type, with (void *), can be used instead of LPSTR

There are a lot of drawbacks in Hungarian naming regulations, such as making the work of changing the variable types difficult. Many people no longer abide by this norm. As for what the drawbacks, everyone can look at this article: http://www.9cbs.com.cn/program/4906.htm

转载请注明原文地址:https://www.9cbs.com/read-40248.html

New Post(0)