Hungarian variable notation in VC ++

Source: Internet
Author: User

Hungarian Notation:
It places a data type mnemonic in front of each symbolic name Program Provides real-time identification of identifiers.
1. Naming rules for MFC, handles, controls, and structures.
Windows sample variable MFC sample 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 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 cret rect

General prefix naming rules for Article 2
Prefix type instance
C Class or structure cdocument, cprintinfo
M _ member variables m_pdoc, m_ncustomers

Variable name specification in 3
Prefix type description instance
Ch char 8 is the character chgrade
Ch tchar if _ Unicode is defined, it is a 16-character chname
B bool Boolean value benabled
N int INTEGER (its size depends on the operating system) nlength
N unit unsigned value (its size depends on the operating system) nlength
W word 16-bit unsigned value wpos
L long 32-bit signed integer loffset
Dw dword 32-bit unsigned integer dwrange
P * pointer pdoc
LP far * remote pointer lpdoc
Lpsz lpstr 32-Bit String pointer lpszname
Lpsz lpctstr if _ Unicode is defined, a 32-bit constant string pointer lpszname
H handle windows object handle hwnd
Lpfn callback refers to the far pointer of the callback function lpfnabort

4 application symbol naming rules
Prefix type instance range
Idr_ multiple resource sharing identities of different types idr_mainframe 1-0x6fff
Resource idd_spell_check...
Hidd _ dialog box resource help context hidd_spell_check 0x20001-0x26ff
Idb_bitmap resource idb_company_logo 1-0x6fff
IDC _ cursor resource idc_penpencil...
IDI _ chart resource idi_notepad...
Id_tools_spelling 0x8000-0xdfff
Hid _ Command help context hid_tools_spelling...
The IDP _ message box prompts idp_invalid_parino 8-0xdfff.
Hidp _ message box help context hidp_invalid_parino 0x30008-0x3dfff
IDS _ string resource ids_copyright 1-0x7fff
Idc_recalc 8-0xdfff

Microsoft MFC macro naming rules in article 5
Name type
_ Afxdll's unique dynamic link library version
_ ALPHA: only compiles the DEC Alpha processor.
_ Debug includes the debug version 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 identification naming rules
Indicator value and meaning
U ansi (n) or unicodeu (u)
D debugging or release: D = debugging; ignore the indicator as release

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

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

9 windows. H Naming Convention
Type Definition description
Winapi is used in the far Pascal position declared by the API. If you are writing a DLL with an export API entry point, you can
Use this type in your own API
Callback uses the far Pascal position in the application call-back routine, such as the window and dialog box.
The same as the lpstr, but the former is used for read-only string pointers. Its definition is similar to (const char far *)
Unit and the unsigned integer type of the portable value, whose size is determined by the host environment (32-bit for Windows NT and Windows 95 ).
It is a synonym for the unsigned Int. It uses the word position and wants a 16-bit unsigned value on a 32-bit platform.
Except in rare cases
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 (a type of combined data)
Generally, the pointer type of lpvoid is equivalent to (void. Use it instead of lpstr.

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.