wParam,lParam代表什么

SoftP 2002-10-23 10:14:33
SendMessage(......)
当消息分别是WM_KEYDOWN,WM_CHAR,WM_MOUSEMOVE,SendMessage(......)的后两个参数。
...全文
114 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
guopo 2002-10-23
  • 打赏
  • 举报
回复
这两个参数可代表的意义太丰富了,具体问题查一下MSDN吧。
用户 昵称 2002-10-23
  • 打赏
  • 举报
回复
一个参数的低两个字节和全部
zhoujiangsusan 2002-10-23
  • 打赏
  • 举报
回复
给你个例子
////9.26 如果“删除用户”对话框已经打开,//////////////
//则送一个包含新用户名的WM_CLIENT_ONLINE消息给它,不让删除新用户
//开始///////////////////////////////// ///////////////////
//查找到目标窗口
CWnd* pWindow=CWnd::FindWindow(NULL, "删除用户" );
//如果没找到 返回
if (pWindow==NULL)
return TRUE;
//转变要发送的类型
char * p=pMsg->m_strUserName.GetBuffer(username_NAME_LEN+1);
//发送消息
::PostMessage(pWindow->m_hWnd,WM_CLIENT_ONLINE,0,(LPARAM)p);
///////////9.26 如果“删除用户”对话框已经打开,//////////////
//则送一个包含新用户名的WM_CLIENT_ONLINE消息给它,不让删除新用户
//结束////////////////////////////////// ///////
qing_li73 2002-10-23
  • 打赏
  • 举报
回复
WM_MOUSEMOVE
The WM_MOUSEMOVE message is posted to a window when the cursor moves. If the mouse is not captured, the message is posted to the window that contains the cursor. Otherwise, the message is posted to the window that has captured the mouse.

WM_MOUSEMOVE
fwKeys = wParam; // key flags
xPos = LOWORD(lParam); // horizontal position of cursor
yPos = HIWORD(lParam); // vertical position of cursor

Parameters
fwKeys
Value of wParam. Indicates whether various virtual keys are down. This parameter can be any combination of the following values: Value Description
MK_CONTROL Set if the ctrl key is down.
MK_LBUTTON Set if the left mouse button is down.
MK_MBUTTON Set if the middle mouse button is down.
MK_RBUTTON Set if the right mouse button is down.
MK_SHIFT Set if the shift key is down.


xPos
Value of the low-order word of lParam. Specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
yPos
Value of the high-order word of lParam. Specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
Remarks
The MAKEPOINTS macro can be used to convert the lParam parameter to a POINTS structure.

QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.

See Also
Mouse Input Overview, Mouse Input Messages, GetCapture,MAKEPOINTS,POINTS, SetCapture


qing_li73 2002-10-23
  • 打赏
  • 举报
回复
WM_CHAR
The WM_CHAR message is posted to the window with the keyboard focus when a WM_KEYDOWN message is translated by the TranslateMessage function. WM_CHAR contains the character code of the key that was pressed.

WM_CHAR
chCharCode = (TCHAR) wParam; // character code
lKeyData = lParam; // key data

Parameters
chCharCode
Value of wParam. Specifies the character code of the key.
lKeyData
Value of lParam. Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table. Value Description
0–15 Specifies the repeat count for the current message. The value is the number of times the keystroke is auto-repeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative.
16–23 Specifies the scan code. The value depends on the original equipment manufacturer (OEM).
24 Specifies whether the key is an extended key, such as the right-hand alt and ctrl keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0.
25–28 Reserved; do not use.
29 Specifies the context code. The value is 1 if the alt key is held down while the key is pressed; otherwise, the value is 0.
30 Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is 0 if the key is up.
31 Specifies the transition state. The value is 1 if the key is being released, or it is 0 if the key is being pressed.


Return Values
An application should return zero if it processes this message.

Remarks
Because there is not necessarily a one-to-one correspondence between keys pressed and character messages generated, the information in the high-order word of the lKeyData parameter is generally not useful to applications. The information in the high-order word applies only to the most recent WM_KEYDOWN message that precedes the posting of the WM_CHAR message.

For enhanced 101- and 102-key keyboards, extended keys are the right alt and the right ctrl keys on the main section of the keyboard; the ins, del, home, end, page up, page down and arrow keys in the clusters to the left of the numeric keypad; and the divide (/) and enter keys in the numeric keypad. Some other keyboards may support the extended-key bit in the lKeyData parameter.

QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.

See Also
Keyboard Input Overview, Keyboard Input Messages, TranslateMessage, WM_KEYDOWN


qing_li73 2002-10-23
  • 打赏
  • 举报
回复
WM_KEYDOWN
The WM_KEYDOWN message is posted to the window with the keyboard focus when a nonsystem key is pressed. A nonsystem key is a key that is pressed when the alt key is not pressed.

WM_KEYDOWN
nVirtKey = (int) wParam; // virtual-key code
lKeyData = lParam; // key data

Parameters
nVirtKey
Value of wParam. Specifies the virtual-key code of the nonsystem key.
lKeyData
Value of lParam. Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table. Value Description
0–15 Specifies the repeat count for the current message. The value is the number of times the keystroke is auto-repeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative.
16–23 Specifies the scan code. The value depends on the original equipment manufacturer (OEM).
24 Specifies whether the key is an extended key, such as the right-hand alt and ctrl keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0.
25–28 Reserved; do not use.
29 Specifies the context code. The value is always 0 for a WM_KEYDOWN message.
30 Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is 0 if the key is up.
31 Specifies the transition state. The value is always 0 for a WM_KEYDOWN message.


Return Values
An application should return zero if it processes this message.

Default Action
If the f10 key is pressed, the DefWindowProc function sets an internal flag. When DefWindowProc receives the WM_KEYUP message, the function checks whether the internal flag is set and, if so, sends a WM_SYSCOMMAND message to the top-level window. The wParam parameter of the message is set to SC_KEYMENU.

Remarks
Because of the autorepeat feature, more than one WM_KEYDOWN message may be posted before a WM_KEYUP message is posted. The previous key state (bit 30) can be used to determine whether the WM_KEYDOWN message indicates the first down transition or a repeated down transition.

For enhanced 101- and 102-key keyboards, extended keys are the right alt and ctrl keys on the main section of the keyboard; the ins, del, home, end, page up, page down and arrow keys in the clusters to the left of the numeric keypad; and the divide (/) and enter keys in the numeric keypad. Other keyboards may support the extended-key bit in the lKeyData parameter.

QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.

See Also
Keyboard Input Overview, Keyboard Input Messages, DefWindowProc, WM_CHAR, WM_KEYUP, WM_SYSCOMMAND


Kevin_C_K 2002-10-23
  • 打赏
  • 举报
回复
好好看看windows程序設計
SoftP 2002-10-23
  • 打赏
  • 举报
回复
WPARAM LPARAM对不同的消息有不同的含义,这我知道,我想和道常见的。
mjk 2002-10-23
  • 打赏
  • 举报
回复
WPARAM LPARAM对不同的消息有不同的含义
SuperFC 2002-10-23
  • 打赏
  • 举报
回复
这两个参数是描述消息用的,也就是说是关于消息的一些信息。
譬如,你的程序接受到关于SIZE消息的话,那么以上参数就可以描述到底是
MAX_SIZE,还是MIN_SIZE等
wParam 与lParam的区别在于为一个为32位的,一个为16位的,
这是我所理解的,具体的情况,你最好去看<<Windows程序设计>>里面讲得很清楚

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧