分类: WINDOWS
2007-01-19 10:50:34
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程序的详细分析。
前缀 |
类型 |
例子 |
备注 |
Lm |
Class |
LmObject |
表示类型本身 不与范围前缀结合使用 |
I |
Interface 接口 |
IUnknown |
前缀 |
类型 |
例子 |
备注 |
g_ |
全局作用域 |
g_Servers |
|
m_ |
成员变量 |
m_pDoc, | |
l_ |
局部作用域 |
l_strName |
少用 |
前缀 |
类型 |
内存规格描述 |
例子 |
ch |
char |
8-bit character |
chGrade |
ch |
TCHAR |
16-bit character if _UNICODE is defined |
chName |
b |
BOOL |
Boolean value |
bEnabled |
n |
int |
Integer (size dependent on operating system) |
nLength |
n |
UINT |
Unsigned value (size dependent on 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 |
* |
Ambient memory model pointer |
pDoc |
lp |
FAR* |
Far pointer |
lpDoc |
lpsz |
LPSTR |
32-bit pointer to character string |
lpszName |
lpsz |
LPCSTR |
32-bit pointer to constant character string |
lpszName |
lpsz |
LPCTSTR |
32-bit pointer to constant character string if _UNICODE is defined |
lpszName |
h |
handle |
Handle to Windows object |
hWnd |
lpfn |
(*fn)() |
callbackFar pointer to CALLBACK function |
lpfnAbort |
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; |
前缀 |
符号类型 |
符号例子 |
范围 |
IDR_ |
标识多个资源共享的类型 |
IDR_MAINFRAME |
1 to 0x6FFF |
IDD_ |
对话框资源(Dialog) |
IDD_SPELL_CHECK |
1 to 0x6FFF |
IDB_ |
位图资源(Bitmap) |
IDB_COMPANY_LOGO |
1 to 0x6FFF |
IDC_ |
光标资源(Cursor) |
IDC_PENCIL |
1 to 0x6FFF |
IDI_ |
图标资源(Icon) |
IDI_NOTEPAD |
1 to 0x6FFF |
ID_IDM_ |
工具栏或菜单栏的命令项 |
ID_TOOLS_SPELLING |
0x8000 to 0xDFFF |
HID_ |
命令上下文帮助(Command Help context) |
HID_TOOLS_SPELLING |
0x18000 to 0x1DFFF |
IDP_ |
消息框提示文字资源 |
IDP_INVALID_PARTNO |
8 to 0xDFFF |
HIDP_ |
消息框上下文帮助(Message-box Help context) |
HIDP_INVALID_PARTNO |
0x30008 to 0x3DFFF |
IDS_ |
字符串资源(String) |
IDS_COPYRIGHT |
1 to 0x7FFF |
IDC_ |
对话框内的控制资源(Control) |
IDC_RECALC |
8 to 0xDFFF |
类型 |
含义 |
ATOM |
Atom. For more information, see Atoms. |
BOOL |
Boolean variable (should be TRUE or FALSE). |
BOOLEAN |
Boolean variable (should be TRUE or FALSE). |
BYTE |
Byte (8 bits). |
CALLBACK |
Calling convention for callback functions. |
CHAR |
8-bit Windows (ANSI) character. For more information, see Character Sets Used By Fonts. |
COLORREF |
Red, green, blue (RGB) color value (32 bits). See COLORREF for information on this type. |
CONST |
Variable whose value is to remain constant during execution. |
DWORD |
32-bit unsigned integer. |
DWORD_PTR |
Unsigned 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. ) |
DWORD32 |
32-bit unsigned integer. |
DWORD64 |
64-bit unsigned integer. |
FLOAT |
Floating-point variable. |
HACCEL |
Handle to an accelerator table. |
HANDLE |
Handle to an object. |
HBITMAP |
Handle to a bitmap. |
HBRUSH |
Handle to a brush. |
HCONV |
Handle to a dynamic data exchange (DDE) conversation. |
HCONVLIST |
Handle to a DDE conversation list. |
HCURSOR |
Handle to a cursor. |
HDC |
Handle to a device context (DC). |
HDDEDATA |
Handle to DDE data. |
HDESK |
Handle to a desktop. |
HDROP |
Handle to an internal drop structure. |
HDWP |
Handle to a deferred window position structure. |
HENHMETAFILE |
Handle to an enhanced metafile. |
HFILE |
Handle to a file opened by OpenFile, not CreateFile. |
HFONT |
Handle to a font. |
HGDIOBJ |
Handle to a GDI object. |
HGLOBAL |
Handle to a global memory block. |
HHOOK |
Handle to a hook. |
HICON |
Handle to an icon. |
HIMAGELIST |
Handle to an image list. |
HIMC |
Handle to input context. |
HINSTANCE |
Handle to an instance. |
HKEY |
Handle to a registry key. |
HKL |
Input locale identifier. |
HLOCAL |
Handle to a local memory block. |
HMENU |
Handle to a menu. |
HMETAFILE |
Handle to a metafile. |
HMODULE |
Handle to a module. The value is the base address of the module. |
HMONITOR |
Handle to a display monitor. |
HPALETTE |
Handle to a palette. |
HPEN |
Handle to a pen. |
HRGN |
Handle to a region. |
HRSRC |
Handle to a resource. |
HSZ |
Handle to a DDE string. |
HWINSTA |
Handle to a window station. |
HWND |
Handle to a window. |
INT |
32-bit signed integer. |
INT_PTR |
Signed integral type for pointer precision. Use when casting a pointer to an integer to perform pointer arithmetic. |
INT32 |
32-bit signed integer. |
INT64 |
64-bit signed integer. |
LANGID |
Language identifier. For more information, see Locales. |
LCID |
Locale identifier. For more information, see Locales. |
LCTYPE |
Locale information type. For a list, see Locale and Language Information. |
LONG |
32-bit signed integer. |
LONG_PTR |
Signed long type for pointer precision. Use when casting a pointer to a long to perform pointer arithmetic. |
LONG32 |
32-bit signed integer. |
LONG64 |
64-bit signed integer. |
LONGLONG |
64-bit signed integer. |
LPARAM |
Message parameter. |
LPBOOL |
Pointer to a BOOL. |
LPBYTE |
Pointer to a BYTE. |
LPCOLORREF |
Pointer to a COLORREF value. |
LPCRITICAL_SECTION |
Pointer to a CRITICAL_SECTION. |
LPCSTR |
Pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts. |
LPCTSTR |
An LPCWSTR if UNICODE is defined, an LPCTSTR otherwise. |
LPCVOID |
Pointer to a constant of any type. |
LPCWSTR |
Pointer to a constant null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts. |
LPDWORD |
Pointer to a DWORD. |
LPHANDLE |
Pointer to a HANDLE. |
LPINT |
Pointer to an INT. |
LPLONG |
Pointer to a LONG. |
LPSTR |
Pointer to a null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts. |
LPTSTR |
An LPWSTR if UNICODE is defined, an LPSTR otherwise. |
LPVOID |
Pointer to any type. |
LPWORD |
Pointer to a WORD. |
LPWSTR |
Pointer to a null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts. |
LRESULT |
Signed result of message processing. |
LUID |
Locally unique identifier. |
PBOOL |
Pointer to a BOOL. |
PBOOLEAN |
Pointer to a BOOL. |
PBYTE |
Pointer to a BYTE. |
PCHAR |
Pointer to a CHAR. |
PCRITICAL_SECTION |
Pointer to a CRITICAL_SECTION. |
PCSTR |
Pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts. |
PCTSTR |
A PCWSTR if UNICODE is defined, a PCSTR otherwise. |
PCWCH |
Pointer to a constant WCHAR. |
PCWSTR |
Pointer to a constant null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts. |
PDWORD |
Pointer to a DWORD. |
PFLOAT |
Pointer to a FLOAT. |
PHANDLE |
Pointer to a HANDLE. |
PHKEY |
Pointer to an HKEY. |
PINT |
Pointer to an INT. |
PLCID |
Pointer to an LCID. |
PLONG |
Pointer to a LONG. |
PLUID |
Pointer to a LUID. |
POINTER_32 |
32-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_64 |
64-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. |
PSHORT |
Pointer to a SHORT. |
PSTR |
Pointer to a null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts. |
PTBYTE |
Pointer to a TBYTE. |
PTCHAR |
Pointer to a TCHAR. |
PTSTR |
PWSTR if UNICODE is defined, a PSTR otherwise. |
PTBYTE |
Pointer to a TBYTE. |
PTCHAR |
Pointer to a TCHAR. |
PTSTR |
A PWSTR if UNICODE is defined, a PSTR otherwise. |
PUCHAR |
Pointer to a UCHAR. |
PUINT |
Pointer to a UINT. |
PULONG |
Pointer to a ULONG. |
PUSHORT |
Pointer to a USHORT. |
PVOID |
Pointer to any type. |
PWCHAR |
Pointer to a WCHAR. |
PWORD |
Pointer to a WORD. |
PWSTR |
Pointer to a null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts. |
REGSAM |
Security access mask for registry key. |
SC_HANDLE |
Handle to a service control manager database. For more information, see SCM Handles. |
SC_LOCK |
Handle to a service control manager database lock. For more information, see SCM Handles. |
SERVICE_STATUS_HANDLE |
Handle to a service status value. For more information, see SCM Handles. |
SHORT |
Short integer (16 bits). |
SIZE_T |
The maximum number of bytes to which a pointer can point. Use for a count that must span the full range of a pointer. |
SSIZE_ T |
Signed SIZE_T. |
TBYTE |
A WCHAR if UNICODE is defined, a CHAR otherwise. |
TCHAR |
A WCHAR if UNICODE is defined, a CHAR otherwise. |
UCHAR |
Unsigned CHAR. |
UINT |
Unsigned INT. |
UINT_PTR |
Unsigned INT_PTR. |
UINT32 |
Unsigned INT32. |
UINT64 |
Unsigned INT64. |
ULONG |
Unsigned LONG. |
ULONG_PTR |
Unsigned LONG_PTR. |
ULONG32 |
Unsigned LONG32. |
ULONG64 |
Unsigned LONG64. |
ULONGLONG |
64-bit unsigned integer. |
UNSIGNED |
Unsigned attribute. |
USHORT |
Unsigned SHORT. |
VOID |
Any type. |
WCHAR |
16-bit Unicode character. For more information, see Character Sets Used By Fonts. |
WINAPI |
Calling convention for system functions. |
WORD |
16-bit unsigned integer. |
WPARAM |
Message parameter. |