wparam和lparam

原创 2015年07月08日 16:48:28

WPARAM 和 LPARAM是windows消息响应机制中提供的两个用来传递消息的形参。

类型定义如下:

typedef UINT WPARAM;

typedef LONG LPARAM;

其中:

(1)wparam是一个UINT/word类型的变量,lparam是一个long类型的变量。在win32 API中二者长度一样。

(2)由于系统中地址的长度与lparam长度相同,因此在传递地址时通常使用lparam。例如需要在其他窗口过程中调用的函数指针。

(3)但是由于并没有强制规定这两个参数具体用来传递什么信息,所以不同的函数调用中意义可能不同需要具体去查参考文档



下附MSDN中windows 数据类型:

Type

Definition

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.

CRITICAL_SECTION

Critical-section object. For more information, see Critical Section Objects.

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.

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.

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 LPCSTR 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

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.

 

Wparam与Lparam的区别

在Win32 SDK中消息本身是作为一个结构体记录传递给应用程序的,这个记录中包含了消息的类型以及其他信息。这个记录类型叫做MSG,它在window中是这样声明的:  typedef struct ...
  • scsyuzujin
  • scsyuzujin
  • 2014年09月29日 16:04
  • 2816

MFC 消息中( WPARAM wParam,LPARAM lParam)包含信息 (2014-08-30 09:27:13)

MFC 消息中( WPARAM wParam,LPARAM lParam)包含信息   分类: 操作系统/ Windows/ 文章   windows的消息具有以下两个参数:     (1...
  • sunnyli3166
  • sunnyli3166
  • 2015年08月12日 09:58
  • 458

VC++中WPARAM和LPARAM的使用

这两个数据数一样的数据类型 typedef UINT WPARAM; typedef LONG LPARAM; 在Win32 API中,WPARAM和LPARAM都是32位,所以没有什么本质的区...
  • mjzhlstk
  • mjzhlstk
  • 2014年10月12日 14:18
  • 773

十三:谈谈MSG中的 WPARAM 和 LPARAM

第一:WPARAM 和 LPARAM 是什么东西         typedef uint wparam;//就是无符号整形         typedef long lparam;//就是长整形  ...
  • ljd_1986413
  • ljd_1986413
  • 2011年03月18日 11:45
  • 8177

WPARAM和LPARAM的含义

lParam 和 wParam 是宏定义,一般在消息函数中带这两个类型的参数,通常用来存储窗口消息的参数。 LRESULT CALLBACK WindowProc(HWND hwnd, UINT u...
  • cxq_1993
  • cxq_1993
  • 2015年08月24日 13:55
  • 2395

消息中的wParam和lParam

具体是这么说:“在Win 3.x中,WPARAM是16位的,而LPARAM是32位的,两者有明显的区别。因为地址通常是32位的,所以LPARAM 被用来传递地址,这个习惯在Win32 API中仍然能够...
  • ahuang1900
  • ahuang1900
  • 2014年08月08日 16:22
  • 1333

一些WM消息与其相应WPARAM,LPARAM的定义

以下内容首发在我的百度空间:http://hi.baidu.com/legend_sss 1. WM_PAINT,WM_SIZE:     LOWORD(lParam)是客户区的宽     ...
  • warc_k
  • warc_k
  • 2014年03月22日 22:26
  • 1065

DuiLib 通用窗口类封装

class WindowImplBase : public CWindowWnd, public INotifyUI, public IMessageFilterUI, public IDi...
  • KingRama
  • KingRama
  • 2014年12月08日 12:33
  • 457

WIN32 API编程,wParam lParam参数小结

1.WM_LBUTTONDOWN:产生单击鼠标左键的消息: 1Param 低字节包含当前光标的X坐标值; 高字节包含当前光标的Y坐标值 wParam 包含一整数值以标识鼠标键的按下状态 MK_...
  • yangluoning
  • yangluoning
  • 2013年10月12日 17:03
  • 968

WM消息其lParam和wParam参数定义

鼠标消息 lParam:低字组为x 座标,高字组为y 座标,这两个座标是相对于窗口显示区域左上角的位置。 Wparam:指示滑鼠按键以及Shift和Ctrl 键的状态。可以使用头文件WINUSER...
  • b41077213
  • b41077213
  • 2013年09月10日 14:26
  • 718
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:wparam和lparam
举报原因:
原因补充:

(最多只允许输入30个字)