windows程序设计 大写标识符与缩写

Uppercase Identifiers

You'llnotice the use of quite a few uppercase identifiers in HELLOWIN.C. Theseidentifiers are defined in the

Windowsheader files. Several of these identifiers contain a two-letter or three-letterprefix followed by an

underscore:

CS_HREDRAW

DT_VCENTER

SND_FILENAME

CS_VREDRAW

IDC_ARROW

WM_CREATE

CW_USEDEFAULT

IDI_APPLICATION

WM_DESTROY

DT_CENTER

MB_ICONERROR

WM_PAINT

DT_SINGLELINE

SND_ASYNC

WS_OVERLAPPEDWINDOW

These aresimply numeric constants. The prefix indicates a general category to which theconstant belongs, as

indicated inthis table:

Prefix

Constant

CS

Class styleoption

CW

Createwindow option

DT

Draw textoption

IDI

ID numberfor an icon

IDC

ID numberfor a cursor

MB

Message boxoptions

SND

Sound option

WM

Windowmessage

WS

Window style

New Data Types

For example,the third and fourth parameters to WndProcare defined as WPARAM and LPARAM,respectively. The origin of these names requires a bit of history. When Windows was a 16-bit system, the third parameter toWndProcwas defined as a WORD, which was a 16-bit unsigned shortinteger, and thefourth parameter was defined as a LONG, which was a 32-bit signed long integer.That's the reason for the "W" and "L" prefixes on the word"PARAM." In the 32-bit versions of Windows, however, WPARAM isdefined as a UINT and LPARAM is defined as a LONG (which is still the C longdata type), so both parameters to the window procedure are 32-bit values. Thismay be a little confusing because the WORD data type is still defined as a16-bit unsigned shortinteger in Windows 98, so the "W" prefix to"PARAM" creates somewhat of a misnomer.

TheWndProcfunction returns a value of type LRESULT. That's simply defined as aLONG. The  WinMainfunction is given atype of WINAPI (as is every Windows function call defined in the header files),and the WndProc function is given a type ofCALLBACK. Both these identifiers are defined as __stdcall, which refers to aspecial calling sequence for function calls that occur between Windows itselfand your application.

HELLOWINalso uses four data structures (which I'll discuss later in this chapter)defined in the Windows header files. These data structures are shown in thetable below.

Structure

Meaning

MSG

Messagestructure

WNDCLASS

Window classstructure

PAINTSTRUCT

Paintstructure

RECT

Rectanglestructure

Getting aHandle on Handles

 

Finally,there are three uppercase identifiers for various types of "handles":

Identifier

Meaning

HINSTANCE

Handle to an"instance"—the program itself

HWND

Handle to awindow

HDC

Handle to adevice context

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值