当前位置:编程学习 > VB >>

菜单项没有句柄的话,如何给菜单项发windows消息,有思路吗各位?

如题,我现在可以找到各菜单类似记事本中的“文件”“编辑”的句柄,现在只想对一个菜单项进行操作。类似于对记事本中的“文件”的新建进行操作。
及我点击,父窗体的某个按钮,就有点击子窗体中的某一菜单项的效果。
大家说说 可以实现吗? --------------------编程问答-------------------- 这个标准的方法是发WM_COMMAND消息,如果那菜单是在EXE资源里定义的,那你找个能查看资源的软件看下相应项的ID号是多少就行了.否则的话,用GetMenu,GetMenuItemID这些API好像也可得到.或者你用SPYXX HOOK一下那个WM_COMMAND试试

MSDN中关于WM_COMMAND的部分:
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. 

WM_COMMAND 
wNotifyCode = HIWORD(wParam); // notification code 
wID = LOWORD(wParam);         // item, control, or accelerator identifier 
hwndCtl = (HWND) lParam;      // handle of control 
 
Parameters
wNotifyCode 
Value of the high-order word of wParam. Specifies the notification code if the message is from a control. If the message is from an accelerator, this parameter is 1. If the message is from a menu, this parameter is 0. 
wID 
Value of the low-order word of wParam. Specifies the identifier of the menu item, control, or accelerator. 
hwndCtl 
Value of 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.

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
Edit Controls Overview, Edit Control Messages, WM_SYSCOMMAND 

 
--------------------编程问答-------------------- 没错,窗口菜单是可以用标准方法得到。不知道自绘菜单如何?没搞过这个! --------------------编程问答-------------------- xuexi --------------------编程问答-------------------- 帮顶,路上学习。。。。 --------------------编程问答-------------------- 顶一楼.

另外二楼的自绘菜单应该不能使用标准方法获取.

因为其并不是属于EXE中的静态资源,是动态生成的.

具体没弄过,等待弄过的来吼一句. --------------------编程问答-------------------- 我现在想这样做,如果正常运行该应用程序,
1.用鼠标单击菜单中的“文件”会弹出下拉菜单,
2.然后按键盘“向下键”一下
3.然后按“ENTER键”
就可以打开文件的框了,并且这就是我想要的。

所以,当设置应用程序的窗体为子窗体后,我是不是可以这样:
先获得“文件”的句柄,
让子窗体获得焦点
然后用windows消息,执行单击操作,
然后发送键盘消息,是不是可以达到目的了?
--------------------编程问答-------------------- 我现在连单击菜单的操作都做不出来。。。
已知菜单的句柄(比如记事本中的“文件”的句柄),如何对其进行单击操作。
各位大侠帮帮忙吧?
一个小P活我都干第四天了,这是最后一步了。
帮帮小弟吧  --------------------编程问答-------------------- 请问可以进行这样的操作吗?
当单击父窗体某按钮,就在子窗体中的某个位置(由坐标决定)做单击操作,可以实现吗? --------------------编程问答-------------------- 单击菜单我已经用代码实现 如有需要 可以加我qq346855017
补充:VB ,  API
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,