程序作者:管宁 个人网站:www.cndev-lab.com VC作为一个主流的开发平台一直深受编程爱好者的喜爱,但是很多人却对它的入门感到难于上青天,究其原因主要是大家对他错误的熟悉造成的,严格的来说VC++不是门语言,虽然它和C++之间有密切的关系,假如形象点比喻的话,可以C++看作为一种”工业标准”,而VC++则是某种操作系统平台下的”厂商标准”,而”厂商标准”是在遵循”工业标准”的前提下扩展而来的。 VC++应用程序的开发主要有两种模式,一种是WIN API方式,另一种则是MFC方式,传统的WIN API开发方式比较繁琐,而MFC则是对WIN API再次封装,所以MFC相对于WIN API开发更具备效率优势,但为了对WINDOWS开发有一个较为全面细致的熟悉,笔者在这里还是以讲解WIN API的相关内容为主线。 话说到这里可能更多人关心的是学习VC++需要具备什么条件,为什么对于这扇门屡攻不破呢? 要想学习好VC必须具备良好的C/C++的基础,必要的英语阅读能力也是必不可少的,因为大量的技术文档多以英文形式发布。 许多初学VC++的人对于它怪异的写法和程序奇异的工作方式非常不理解,为了帮助大家对它的入门有一个比较概括的了解,我们把这一小节内容分成若干部分讲解。 第一部分:VC++中的对象的命名规则、常用宏定义的命名,以及VC++下的数据类型。 注:这部分简单浏览即可。 第二部分:VC++常用技术术语的解释。 第三部分:HelloWin程序的具体分析。 更多内容请看C/C++技术学堂 C/C++技术专题 Solaris基础知识入门专题,或 第一部分匈牙利命名法规则 一般情况下,变量的取名方式为:<scope_> + <PRefix_> + <qualifier>。 范围前缀_,类型前缀_,限定词。非凡的类型命名,前缀表示: 类、接口 前缀 类型例子备注LmClass LmObject表示类型本身 不与范围前缀结合使用IInterface 接口IUnknown 注:类名前缀改为Lm,对于非全局的类最好有语义表示其所属模块。类的实例命名与类名大致相同,只是类名语义表示类的通用含义,而类名表示此实例的具体语义。如类名LmSketPoint表示草图点的类定义,而它的两个实例 _StartPoint,_EndPoint分别代表起点和终点的语义。类的实例命名带上前缀_。 非凡约定: a. MouseTool的派生类的前缀为_Mt. b. 对话框类的前缀为CDlg. c. 橡皮条类的前缀为_Rb.凡围前缀: 前缀类型例子备注g_全局作用域g_Servers m_成员变量m_pDoc, l_局部作用域l_strName少用 注:编程时尽量少用全程变量,对于全程变量还应在类型前缀后加上如下要害字: 特征模块 : Fea 草图模块 : Sket 装配模块 : Asm 工程图模块: Lay 曲面模块 : Surf 界面模块 : Ui 常用的一般数据类型的前缀 前缀类型内存规格描述例子chchar8-bit characterchGradechTCHAR16-bit character if _UNICODE is definedchNamebBOOLBoolean valuebEnablednintInteger (size dependent on Operating system)nLengthnUINTUnsigned value (size dependent on operating system)nLengthwWord16-bit unsigned valuewPoslLONG32-bit signed integerlOffsetdwDWORD32-bit unsigned integerdwRangep*Ambient memory model pointerpDoclpFAR*Far pointerlpDoclpszLPSTR32-bit pointer to character stringlpszNamelpszLPCSTR32-bit pointer to constant character stringlpszNamelpszLPCTSTR32-bit pointer to constant character string if _UNICODE is definedlpszNamehhandleHandle to Windows objecthWndlpfn(*fn)()callbackFar pointer to CALLBACK functionlpfnAbort
常用Windows对象名称缩写 Windows 对象例子变量MFC类例子对象HWNDhWnd;CWnd*pWnd;HDLGhDlg;CDialog*pDlg;HDChDC;CDC*pDC;HGDIOBJhGdiObj;CGdiObject*pGdiObj;HPENhPen;CPen*pPen; HBRUSHhBrush;CBrush*pBrush; HFONThFont;CFont*pFont; HBITMAPhBitmap;CBitmap*pBitmap; HPALETTEhPalette;CPalette*pPalette; HRGNhRgn;CRgn*pRgn; HMENUhMenu;CMenu*pMenu; HWNDhCtl;CStatic*pStatic; HWNDhCtl;CButton*pBTn;HWNDhCtl;CEdit*pEdit; HWNDhCtl;CListBox*pListBox;HWNDhCtl;CComboBox*pComboBox; Visual C++常用宏定义命名列表 前缀符号类型符号例子范围IDR_标识多个资源共享的类型IDR_MAINFRAME1 to 0x6FFFIDD_对话框资源(Dialog)IDD_SPELL_CHECK1 to 0x6FFFIDB_位图资源(Bitmap)IDB_COMPANY_LOGO1 to 0x6FFFIDC_光标资源(Cursor)IDC_PENCIL1 to 0x6FFFIDI_图标资源(Icon)IDI_NOTEPAD1 to 0x6FFFID_IDM_工具栏或菜单栏的命令项ID_TOOLS_SPELLING0x8000 to 0xDFFFHID_命令上下文帮助(Command Help context)HID_TOOLS_SPELLING0x18000 to 0x1DFFFIDP_消息框提示文字资源IDP_INVALID_PARTNO8 to 0xDFFFHIDP_消息框上下文帮助(Message-box Help context)HIDP_INVALID_PARTNO0x30008 to 0x3DFFFIDS_字符串资源(String)IDS_COPYRIGHT1 to 0x7FFFIDC_对话框内的控制资源(Control)IDC_RECALC8 to 0xDFFF VISUAL C++ 下的数据类型 类型含义ATOMAtom. For more information, see Atoms.BOOLBoolean variable (should be TRUE or FALSE).BOOLEANBoolean variable (should be TRUE or FALSE).BYTEByte (8 bits).CALLBACKCalling convention for callback functions.CHAR8-bit Windows (ANSI) character. For more information, see Character Sets Used By Fonts.COLORREFRed, green, blue (RGB) color value (32 bits). See COLORREF for information on this type.CONSTVariable whose value is to remain constant during execution.DWORD32-bit unsigned integer.DWORD_PTRUnsigned long type for pointer precision. Use when casting a pointer to a long type to perform pointer arithmetic. (Also commonly used for general 32-bit parameters that have been extended to 64 bits in 64-bit Windows. )DWORD3232-bit unsigned integer.DWORD6464-bit unsigned integer.FLOATFloating-point variable.HACCELHandle to an accelerator table.HANDLEHandle to an object.HBITMAPHandle to a bitmap. HBRUSHHandle to a brush.HCONVHandle to a dynamic data exchange (DDE) conversation.HCONVLISTHandle to a DDE conversation list.HCURSORHandle to a cursor.HDCHandle to a device context (DC).HDDEDATAHandle to DDE data.HDESKHandle to a desktop.HDROPHandle to an internal drop strUCture.HDWPHandle to a deferred window position structure.HENHMETAFILEHandle to an enhanced metafile.HFILEHandle to a file opened by OpenFile, not CreateFile.HFONTHandle to a font.HGDIOBJHandle to a GDI object.HGLOBALHandle to a global memory block.HHOOKHandle to a hook.HICONHandle to an icon.HIMAGELISTHandle to an image list.HIMCHandle to input context.HINSTANCEHandle to an instance.HKEYHandle to a registry key.HKLInput locale identifier.HLOCALHandle to a local memory block.HMENUHandle to a menu.HMETAFILEHandle to a metafile.HMODULEHandle to a module. The value is the base address of the module.HMONITORHandle to a display monitor.HPALETTEHandle to a palette.HPENHandle to a pen. HRGNHandle to a region.HRSRCHandle to a resource.HSZHandle to a DDE string.HWINSTAHandle to a window station.HWNDHandle to a window.INT32-bit signed integer.INT_PTRSigned integral type for pointer precision. Use when casting a pointer to an integer to perform pointer arithmetic.INT3232-bit signed integer.INT6464-bit signed integer.LANGIDLanguage identifier. For more information, see Locales.LCIDLocale identifier. For more information, see Locales.LCTYPELocale information type. For a list, see Locale and Language Information.LONG32-bit signed integer. LONG_PTRSigned long type for pointer precision. Use when casting a pointer to a long to perform pointer arithmetic.LONG3232-bit signed integer.LONG6464-bit signed integer.LONGLONG64-bit signed integer.LPARAMMessage parameter.LPBOOLPointer to a BOOL. LPBYTEPointer to a BYTE. LPCOLORREFPointer to a COLORREF value.LPCRITICAL_SECTIONPointer to a CRITICAL_SECTION.LPCSTRPointer to a constant null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts.LPCTSTRAn LPCWSTR if UNICODE is defined, an LPCTSTR otherwise.LPCVOIDPointer to a constant of any type.LPCWSTRPointer to a constant null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts.LPDWORDPointer to a DWORD.LPHANDLEPointer to a HANDLE.LPINTPointer to an INT.LPLONGPointer to a LONG.LPSTRPointer to a null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts.LPTSTRAn LPWSTR if UNICODE is defined, an LPSTR otherwise.LPVOIDPointer to any type.LPWORDPointer to a WORD.LPWSTRPointer to a null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts.LRESULTSigned result of message processing.LUIDLocally unique identifier. PBOOLPointer to a BOOL.PBOOLEANPointer to a BOOL.PBYTEPointer to a BYTE.PCHARPointer to a CHAR.PCRITICAL_SECTIONPointer to a CRITICAL_SECTION.PCSTRPointer to a constant null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts.PCTSTRA PCWSTR if UNICODE is defined, a PCSTR otherwise.PCWCHPointer to a constant WCHAR.PCWSTRPointer to a constant null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts. PDWORDPointer to a DWORD.PFLOATPointer to a FLOAT.PHANDLEPointer to a HANDLE.PHKEYPointer to an HKEY.PINTPointer to an INT. PLCIDPointer to an LCID.PLONGPointer to a LONG.PLUIDPointer to a LUID. POINTER_3232-bit pointer. On a 32-bit system, this is a native pointer. On a 64-bit system, this is a truncated 64-bit pointer. POINTER_6464-bit pointer. On a 64-bit system, this is a native pointer. On a 32-bit system, this is a sign-extended 32-bit pointer.PSHORTPointer to a SHORT.PSTRPointer to a null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts.PTBYTEPointer to a TBYTE.PTCHARPointer to a TCHAR.PTSTRPWSTR if UNICODE is defined, a PSTR otherwise.PTBYTEPointer to a TBYTE.PTCHARPointer to a TCHAR.PTSTRA PWSTR if UNICODE is defined, a PSTR otherwise.PUCHARPointer to a UCHAR.PUINTPointer to a UINT.PULONGPointer to a ULONG.PUSHORTPointer to a USHORT.PVOIDPointer to any type.PWCHARPointer to a WCHAR.PWORDPointer to a WORD.PWSTRPointer to a null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts.REGSAMSecurity access mask for registry key.SC_HANDLEHandle to a service control manager database. For more information, see SCM Handles.SC_LOCKHandle to a service control manager database lock. For more information, see SCM Handles.SERVICE_STATUS_HANDLEHandle to a service status value. For more information, see SCM Handles.SHORTShort integer (16 bits).SIZE_TThe maximum number of bytes to which a pointer can point. Use for a count that must span the full range of a pointer.SSIZE_ TSigned SIZE_T.TBYTEA WCHAR if UNICODE is defined, a CHAR otherwise.TCHARA WCHAR if UNICODE is defined, a CHAR otherwise.UCHARUnsigned CHAR.UINTUnsigned INT.UINT_PTRUnsigned INT_PTR.UINT32Unsigned INT32.UINT64Unsigned INT64.ULONGUnsigned LONG.ULONG_PTRUnsigned LONG_PTR.ULONG32Unsigned LONG32.ULONG64Unsigned LONG64.ULONGLONG64-bit unsigned integer.UNSIGNEDUnsigned attribute.USHORTUnsigned SHORT.VOIDAny type.WCHAR16-bit Unicode character. For more information, see Character Sets Used By Fonts.WINAPICalling convention for system functions.WORD16-bit unsigned integer.WPARAMMessage parameter. 更多内容请看C/C++技术学堂 C/C++技术专题 Solaris基础知识入门专题,或