导航
  • 主页
  • VC综合技术
  • 互联网技术
  • MFC AppLauncher
  • .NET 技术
  • VC/MFC界面
  • VC/MFC 进程
  • VC/MFC 数据库
  • VC++技术资源

我想模拟WM_COMMAND

lsaturn 2004-04-05 02:04:48
我有一个id为IDC_FINALPROT的控件
hwndTemp = GetDlgItem(hwnd, IDC_FINALPROT);//这个hwnd是正确的,大家就不要怀疑了!
SendMessage(hwnd, WM_COMMAND, IDC_FINALPROT, (LPARAM)hwndTemp);
我想这样来发消息来模拟WM_COMMAND
在hwnd的消息循环中是这样处理的
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_FINALPROT:
为什么无法响应我自己发的消息?

...全文
21 点赞 收藏 7
写回复
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lsaturn 2004-04-08
up一下
回复
lsaturn 2004-04-05
up一下
回复
lsaturn 2004-04-05
我也看了msdn
但是NOTIFY_CODE是什么呢?
我这里是点击一个check box
回复
QunKangLi 2004-04-05
WM_COMMAND的LPARAM参数是处理该消息的窗口,WPARAM才是的低16位是发送方的控件ID,高16位是通知代码.正确的发送方法是:
#define NOTIFY_CODE IDC_FINALPROT
SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_FINALPROT,NOTIFY_CODE), (LPARAM)hwnd);

WM_COMMAND
The WM_COMMAND message is sent when the user selects a command item from a menu, when a control sends a notification message to its parent window, or when an accelerator keystroke is translated.

A window receives this message through its WindowProc function.

LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_COMMAND
WPARAM wParam, // notification code and identifier
LPARAM lParam // handle to control (HWND)
);
Parameters
wParam
The high-order word specifies the notification code if the message is from a control. If the message is from an accelerator, this value is 1. If the message is from a menu, this value is zero.
The low-order word specifies the identifier of the menu item, control, or accelerator.

lParam
Handle to the control sending the message if the message is from a control. Otherwise, this parameter is NULL.
Return Values
If an application processes this message, it should return zero.

Remarks
Accelerator keystrokes that select items from the window menu are translated into WM_SYSCOMMAND messages.

If an accelerator keystroke occurs that corresponds to a menu item when the window that owns the menu is minimized, no WM_COMMAND message is sent. However, if an accelerator keystroke occurs that does not match any of the items in the window's menu or in the window menu, a WM_COMMAND message is sent, even if the window is minimized.

If an application enables a menu separator, the system sends a WM_COMMAND message with the low-word of the wParam parameter set to zero when the user selects the separator.

Windows 98, Windows 2000: If a menu is defined with a MENUINFO.dwStyle value of MNS_NOTIFYBYPOS, WM_MENUCOMMAND is sent instead of WM_COMMAND.

Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winuser.h; include Windows.h.


回复
lsaturn 2004-04-05
那应该怎么处理?
因为我要和正常的点击相兼容!
SendMessage(hwnd, WM_COMMAND, MAKEWPAMRAM(IDC_FINALPROT,3), (LPARAM)hwndTemp);
这样也不行
回复
_foo 2004-04-05
你SendMessage时没把ID搞到LOWORD里,在处理时却从LOWORD取出来。。。
回复
_foo 2004-04-05
LOWORD(wParam)?????
回复
发动态
发帖子
VC/MFC
创建于2007-09-28

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
社区公告

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