C ++ vc mfc naming rules

Source: Internet
Author: User

 

 

2012, C ++ returns!

Http://www.cnblogs.com/Lhw978/archive/2012/03/10/2389169.html

 

 

//************************************** **************************************
// ----- (C) Lhw978@163.com ----
// File name: C ++ vc mfc. txt
// Collect and organize: heavily (jicao... fragrance-free)
// Mail: Lhw978@163.com
// QQ: 64616914
// C/C ++ group: 194134342
// Date: 2012-03-07
// Skill: C ++ vc mfc naming convention
// Copyright Disclaimer: This provision is completely free and can be used for various legal purposes without respect for the author's copyright.
// The ownership of the final interpretation belongs to the author.
// Standby Note: This specification is collected and compiled by the fragmented specification published on the Internet and modified as appropriate.
// You are welcome to correct, supplement, and exchange your suggestions.
//************************************** **************************************

This name is taken from the "Hungary" method and is for reference only.
For data type naming rules, refer:
Definition type:

Prefix type Description Examples of valid values in bytes (win32)
Bytes -------------------------------------------------------------------------------------
Typedef int bool VC ++ custom bool bflag 4 (true/false) Non-0 | 0
Bool bflag 1 (true/false) (0x0 ~ 0x1)
Bytes -------------------------------------------------------------------------------------
Typedef unsigned char byte; byte byvalue; 1 0 ~ 255 (0x0 ~ 0xff)
Byte byte unsigned 8-bit byte char uchvalue; 1 0 ~ 255 (0x0 ~ 0xff)
8-bit signed Char chvalue; 1-128 ~ 127 (0x80 ~ 0x7f)
Bytes -------------------------------------------------------------------------------------
Typedef unsigned short word; Word wvalue; 2 0 ~ 65535 (0x0 ~ 0 xFFFF)
W unsigned word unsigned 16-bit integer unsigned short usvalue; 2 0 ~ 65535 (0x0 ~ 0 xFFFF)
S signed 16-bit integer number signed short svalue; 2-32768 ~ 32767 (0x8000 ~ 0x7fff)
Bytes -------------------------------------------------------------------------------------
Typedef unsigned int DWORD; DWORD dwvalue; 4 0 ~ 4294967295 (0x0 ~ 0 xffffffff)
DW unsigned doubleword unsigned 32bit integer unsigned int unvalue; 4 0 ~ 4294967295 (0x0 ~ 0 xffffffff)
N signed 32-bit integer number a signed 32-bit integer signed int nvalue; 4-2147483648 ~ 2147483647 (0x80000000 ~ 0x7fffffff)
L signed long integer long lvalue; 4/8
Ll signed extended long integer long llvalue; 8
Bytes -------------------------------------------------------------------------------------
F single-precision floating-point number float fvalue; 4
D double-precision floating-point double dvalue; 8
Bytes -------------------------------------------------------------------------------------
R references float & rfvalue;
P pointer (pointer) pointer char * pchname; 4
PP multilevel pointer int ** ppndata; 4
LP long pointer (VC ++ custom) Char far ** lpchvalue;
PK const pointer (pointer) const pointer const char * pkchname ;/
/* Unsigned char * pchdata; single character/unsigned short * pusdata ;*/
/* Const int * pkndata;/unsigned int * pundata ;*/
Psz points to the string pointer ending with 0 (c-style string) char * psz = "Hello world."; 4
Char SZ [] = "Hello world."; 13
Char SZ [13] = "Hello world."; 13
The ach character array does not end with 0 char achname [2] = {'A', 'B'}; 2
Bytes -------------------------------------------------------------------------------------
T typedef custom types such as Union and struct tnameinfo tname ;/
Ptnameinfo * ptname ;/
Bytes -------------------------------------------------------------------------------------
A array char achname [20];/
AA two-dimensional array multi-digit group unsigned char aachname [4] [2];/
Bytes -------------------------------------------------------------------------------------
Char * apchname [2];/
Pa points to the array pointer unsigned char (* paucname) [2];/
Bytes -------------------------------------------------------------------------------------
H windows object handle (VC ++ custom) hwnd
V void type void * pvvalue; 4
K const type const int knvalue;
En_name enname; 4
C Class class cname ;/
Bytes -------------------------------------------------------------------------------------
PF function pointer (pointer func) function pointer typedef int (* pfmsgfunc) (INT type );
Bytes -------------------------------------------------------------------------------------
S _ static variable (static) static variable static int s_nvalue;
G _ global variable (global) The global variable int g_nvalue;
Int m_nvalue, a data member of the m_class data member (member) class;
Bytes -------------------------------------------------------------------------------------

Literal constant value:
Single precision floating point float 1.0f/F
Double Precision Floating Point 1.0
Extended Double Floating Point long double 1.0l
INTEGER (unsigned) INT 3
Long Integer (unsigned) Long 3l
Double Byte Character w_char l 'AB' l 'A' l 'han'
Double Byte string w_char * l "Hello world." L "Double Byte string"
 

Macro definition and enumeration value: all uppercase characters are underlined (do not start with underline _) # define max_len 256 // not recommended # DEFINE _ max_len 256
Class Name: starts with C, and the first letter is uppercase class cmyclass {......};
Struct, Consortium: starting with T, uppercase letters (including user-defined types) struct tmystruct {...}; Union tmyunion {......};
Enumeration: Start with EM _. all uppercase characters are underlined with Enum em_my_enum {Sunday, mondy, Tuesday };
Function Name: upper-case letter (the function body must not exceed 200 rows). verb or dynamic name int myfunction (const char * pkchparam, const Int & rknnum ){......}
Virtual function: starting with do, virtual int dofunction ();
Callback Function: void ontimer (INT nparam) Starting with on );
Variable name prefix with the first character in upper case (duplicate or similar names are not allowed) int ntotalvalue; // The name must be abbreviated to more than 30 letters and annotated
Some simple local variables, such as I, J, K, x, y, and z, can also be used.

Note: const is used in C ++, and macro definition is not required as much as possible # define;
The name of a macro starting with dashes _ or dashes _ is reserved for the compiler. It is recommended that you do not start with dashes _ or dashes.
Unless you have to, use as few global variables as possible.
Write only one line of code.
Spaces should be placed between operators (Rule omitted ).
It is best to replace the tab key with four spaces for indentation.

========================================================== ========================================================== ====

List of common VC prefixes:
Prefix type Description Example
Ch char 8-character chgrade
Ch tchar 16-bit Unicode Character chname
B bool Boolean variable benabled
N int INTEGER (the size is determined by the operating system) nlength
N uint unsigned integer (the size is determined by the operating system) nlength
WWord 16-bit unsigned integer wpos
L long 32-bit signed integer loffset
Dw dword 32-bit unsigned integer dwrange
P * ambient Memory Model pointer memory module pointer, pointer variable pdoc
LP far * long pointer lpdoc
Lpsz lpstr 32-Bit String pointer lpszname
Lpsz lpcstr 32-bit constant string pointer lpszname
Lpsz lpctstr 32-bit Unicode type constant pointer lpszname
H handle windows object handle hwnd
Lpfn (* fN) () callback function pointer callback far pointer to callback function lpfnabort

========================================================== ========================================================== ====
Abbreviation of Windows Object Name:

Windows Object example variable MFC class example object
Hwnd; cwnd * pwnd;
Hdlg; cdialog * pdlg;
HDC; CDC * PDC;
Hgdiobj; cgdiobject * pgdiobj;
Hpen; cpen * ppen;
Hbrush; cbrush * pbrush;
Hfont; cfont * pfont;
Hbitmap; cbitmap * pbitmap;
Hpalette; cpalette * ppalette;
Hrgn; crgn * prgn;
Hmenu; cmenu * pmenu;
Hwnd hctl; cstatic * pstatic;
Hwnd hctl; cbutton * pbtn;
Hwnd hctl; cedit * pedit;
Hwnd hctl; clistbox * plistbox;
Hwnd hctl; ccombobox * pcombobox;

========================================================== ========================================================== ====
List of commonly used macro definitions in VC:

Example range of prefix symbols
Idr_identifies the types of resource sharing idr_mainframe 1 ~ 0x6fff
Resource (DIALOG) idd_spell_check 1 ~ 0x6fff
Hidd _ helps hidd_spell_check 0x20001 ~ Based on the context of the dialog box ~ 0x26ff
Idb_bitmap Resource (Bitmap) idb_company_logo 1 ~ 0x6fff
IDC _ cursor idc_penpencil 1 ~ 0x6fff
IDI _ icon Resource (icon) idi_notepad 1 ~ 0x6fff
Id_tools_spelling 0x8000 ~ 0 xdfff
Hid _ command context help hid_tools_spelling 0x18000 ~ 0x1dfff
The IDP _ message box prompts the text resource idp_invalid_partno 8 ~ 0 xdfff
Hidp _ message box context help hidp_invalid_partno 0x30008 ~ 0x3dfff
IDS _ string resource (string) ids_copyright 1 ~ 0x7fff
Idc_recalc 8 ~ 0 xdfff

========================================================== ========================================================== ====
Microsoft MFC macro naming rules

Name type
_ Afxdll's unique dynamic connection library (DLL) version
_ ALPHA: only compiles the DEC Alpha processor.
_ Debug includes debugging versions for Diagnosis
_ MBCS compile multi-byte character sets
_ Unicode open Unicode in an application
Functions provided by afxapi MFC
Callback functions that Use Pointer callback

Library identifier name Method
Identifier value and meaning
U ansi (n) or Unicode (u)
D debugging or release: D = debugging; ignore the identifier as release

Static library version naming rules
Library description
Debugging version of nafxcwd. Lib: MFC static Connection Library
Nafxcw. Lib release: MFC static Connection Library
Uafxcwd. Lib debugging version: the static Connection Library of MFC with Unicode support
Uafxcw. Lib release version: static Connection Library of MFC with Unicode support

Dynamic Connection Library naming rules
Name type
_ Afxdll unique dynamic connection library (DLL) version
Functions provided by winapi windows

New naming rules in windows. h
Type Definition description
Winapi uses the far Pascal position in the API declaration. If you are writing a DLL with an export API population point, you can use this type in your own API.
Callback uses the position of far Pascal in the application callback program, such as the window and dialog box.
The same as lpstr, but the same as the definition (const char far *)
The portable unsigned integer type of uint, which is determined by the host environment (32-bit for Windows NT and Windows 9x). It is a synonym for unsigned Int.
Type of the return value of the lresult window Program
Lparam declares the type used by lparam. lparam is the fourth parameter of the window program.
Wparam declares the type used by wparam. wparam is the third parameter of the window program.
Lpvoid is generally a pointer type, which is the same as (void *) and can be used to replace lpstr

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.