111222在么,一起来讨论问题,也请大家帮个忙

kenny_yuan 2001-07-29 09:40:22
如果看到这个贴子的人不明白我们在说什么,请看下面的说明:
要实现一种功能,将整个系统中的每个编辑框的右键菜单都加上一个菜单项目,比如“&My Item”,并能够处理这个命令ID。我觉得要用hook来做,如果谁有不同的思路,欢迎提供,因为我的思路局限在hook上了(不过好像只有这条路了^_^)。

为了调试方便,我先在一个exe中用钩子将窗口子类化(原先写的工程,为了省时间),基本的思路是:在每一个WM_CREATE消息中,将窗口类是Edit的窗口过程替换掉(当然也将旧的存下来),也将能接受它的命令ID的父窗口的过程替换掉(也保存旧有的),用来处理命令ID(也就是菜单项目选择后的动作),现在的问题是:在一个Edit中如何取得默认的菜单,不同的语言版本的肯定不一样,怎样取?GetMenu(hWnd)是不行的,取来的是一个无效的HMENU,我可以在菜单中加入项目,但是先要调用CreatePopupMenu(),再AppendMenu(),然后我想,处理它的命令ID也不是难事,所以现在先应该解决菜单的问题:如何加入操作系统的默认菜单?

在默认的窗口过程被调用之前,取得的HMENU是无效的,调用之后,也是无效的,在窗口过程中一定是有效的,但是又不能处理。还没想出办法来。

时间有些不够用,也请大家帮个忙,一起来做好它。
...全文
480 29 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
29 条回复
切换为时间正序
请发表友善的回复…
发表回复
sdice 2001-07-30
  • 打赏
  • 举报
回复
gz!!!!!
kenny_yuan 2001-07-30
  • 打赏
  • 举报
回复
我来作一个小的总结:
现在可以实现(或者马上就要实现)将edit菜单替换成自己的,可以实现所要的调用程序的功能,也可以通过固定加入菜单的功能“补”出edit的默认菜单,但这样毕竟不是好的办法。

也就是说:上面的讨论还没能触及核心问题,大家都帮一帮吧!
Hover 2001-07-30
  • 打赏
  • 举报
回复
UP
kenny_yuan 2001-07-30
  • 打赏
  • 举报
回复
要睡觉了,俗话说:睡得早,起得早,今天就到这里吧(04:03 a.m.)!希望大家多关注一下。
to 111222:
对不起,先将大话说过了,但是解决不了(或者说解决不好),时间实在是有限,明天找时间先将处理命令ID做出来(这应该不是问题),做成全局的钩子也不是问题,问题依然是这个菜单。如果你不想要默认的那几项,就好办了(但是语言版本的支持比较烦,判断系统的语言,再装入不同的版本的菜单)。
kenny_yuan 2001-07-30
  • 打赏
  • 举报
回复
为了全力下载电影,马上就要把IE关掉了,以后再来...
kenny_yuan 2001-07-30
  • 打赏
  • 举报
回复
大家还在呢?
一会儿我还要做另一个软件的功能分析,加班的同事改看电影了,我也就不用做协调了。
还是没有解决方案,还是自力更生吧!但愿一会儿做梦能梦出一个苯环来...
111222 2001-07-30
  • 打赏
  • 举报
回复
notepad不支持拖拽啊
111222 2001-07-30
  • 打赏
  • 举报
回复
要是写个服务程序在后台的话。用

if(Msg == WM_RBUTTONDOWN)
{
POINT pt;
TCHAR szClass[10];
GetCursorPos(&pt);
HWND hWnd=WindowFromPoint(pt);
GetClassName(hWnd, szClass, 10);
if(lstrcmpi(szClass, _T("EDIT")) == 0)
//替换菜单,或者干脆弄个大一点儿的窗口画的像菜单一样把Edit持有的菜单盖住..
//但复制、粘贴操作怎么实现呢?

————————————
可以写个dll,"rundll32.exe replacemenu.dll SetMouseHook"



richincsdn2 2001-07-30
  • 打赏
  • 举报
回复


干吗老想着用右键啊
richincsdn2 2001-07-30
  • 打赏
  • 举报
回复


同情,叫你一招最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最最简单,优雅的方法--------->拖拽
111222 2001-07-29
  • 打赏
  • 举报
回复
我想这还是应该找接口。
111222 2001-07-29
  • 打赏
  • 举报
回复
调用什么程序?我没想调用程序 。

我原来的意图是把edit里的文本直接送到我的程序里去。(其实“复制”,我的程序监视剪贴板也成,但,这样不够直观)如果为此写个服务程序,监视系统,对于我那个程序就得不偿失了.....因为我那个是个极小的小工具....

我想不出来办法。(挠头....)

kenny_yuan 2001-07-29
  • 打赏
  • 举报
回复
to 111222:
即使不是空的,也不会管上用(对于我们要实现的功能)
应当想别的方法。

by the way:在那个贴子里,你说要我调什么程序?
111222 2001-07-29
  • 打赏
  • 举报
回复
HKCU\AppEvents\Schemes\Apps\.Default\MenuPopup\.Current
里面总是空的,缺省也是空的
kenny_yuan 2001-07-29
  • 打赏
  • 举报
回复
这样子思路错了,绝对应该回程序中发掘。
kenny_yuan 2001-07-29
  • 打赏
  • 举报
回复
如果不打开输入法,只有这几个:
1 WINLOGON.EXE OpenKey HKCU SUCCESS Key: 0xE3F352E0
2 WINLOGON.EXE OpenKey HKCU\AppEvents\Schemes\Apps\.Default\MenuPopup\.Current SUCCESS Key: 0xE3D5D2E0
3 WINLOGON.EXE QueryValue HKCU\AppEvents\Schemes\Apps\.Default\MenuPopup\.Current\(Default) SUCCESS ""
4 WINLOGON.EXE CloseKey HKCU\AppEvents\Schemes\Apps\.Default\MenuPopup\.Current SUCCESS Key: 0xE3D5D2E0
5 WINLOGON.EXE CloseKey HKCU SUCCESS Key: 0xE3F352E0
6 WINLOGON.EXE OpenKey HKCU SUCCESS Key: 0xE3F352E0
7 WINLOGON.EXE OpenKey HKCU\AppEvents\Schemes\Apps\.Default\MenuPopup\.Current\Active NOTFOUND
8 WINLOGON.EXE QueryValue HKCU\(Default) NOTFOUND
9 WINLOGON.EXE CloseKey HKCU SUCCESS Key: 0xE3F352E0
10 WINLOGON.EXE OpenKey HKLM\Software\Microsoft\Windows\CurrentVersion SUCCESS Key: 0xE3F352E0
11 WINLOGON.EXE OpenKey HKLM\Software\Microsoft\Windows\CurrentVersion\Software\Microsoft\Windows\CurrentVersion NOTFOUND
12 WINLOGON.EXE QueryValue HKLM\Software\Microsoft\Windows\CurrentVersion\MediaPath SUCCESS "C:\WINNT\Media"
13 WINLOGON.EXE CloseKey HKLM\Software\Microsoft\Windows\CurrentVersion SUCCESS Key: 0xE3F352E0
kenny_yuan 2001-07-29
  • 打赏
  • 举报
回复
to 111222:
不要在注册表中找了,应该没有用的,我在查找程序资源,dll和exe中的,未果。我用注册表监视工具查看的结果如下:(在notepad.exe中点击右键)
1 notepad.exe OpenKey HKCU\Control Panel\Input Method SUCCESS Key: 0xE3C3F740
2 notepad.exe QueryValue HKCU\Control Panel\Input Method\show status SUCCESS "1"
3 notepad.exe CloseKey HKCU\Control Panel\Input Method SUCCESS Key: 0xE3C3F740
4 notepad.exe OpenKey HKCU\Software\Microsoft\Windows\CurrentVersion SUCCESS Key: 0xE3E0D8A0
5 notepad.exe OpenKey HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型 SUCCESS Key: 0xE3721620
6 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\词语联想 SUCCESS 0x1
7 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\词语输入 SUCCESS 0x1
8 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\逐渐提示 SUCCESS 0x1
9 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\外码提示 SUCCESS 0x1
10 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\插空格 SUCCESS 0x0
11 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\光标跟随 SUCCESS 0x1
12 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\<SPACE> SUCCESS 0x1
13 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\<ENTER> SUCCESS 0x0
14 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\FC input SUCCESS 0x1
15 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\FC aid SUCCESS 0x1
16 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\EUDCDictName NOTFOUND
17 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\EUDCMapFileName NOTFOUND
18 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\编码查询 SUCCESS 0x0
19 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\编码查询码长 SUCCESS 0x4
20 notepad.exe CloseKey HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型 SUCCESS Key: 0xE3721620
21 notepad.exe CloseKey HKCU\Software\Microsoft\Windows\CurrentVersion SUCCESS Key: 0xE3E0D8A0
22 notepad.exe OpenKey HKCU\Control Panel\Input Method SUCCESS Key: 0xE3C3F740
23 notepad.exe QueryValue HKCU\Control Panel\Input Method\show status SUCCESS "1"
24 notepad.exe CloseKey HKCU\Control Panel\Input Method SUCCESS Key: 0xE3C3F740
25 notepad.exe OpenKey HKCU\Software\Microsoft\Windows\CurrentVersion SUCCESS Key: 0xE3E0D8A0
26 notepad.exe OpenKey HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型 SUCCESS Key: 0xE32DBD60
27 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\词语联想 SUCCESS 0x1
28 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\词语输入 SUCCESS 0x1
29 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\逐渐提示 SUCCESS 0x1
30 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\外码提示 SUCCESS 0x1
31 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\插空格 SUCCESS 0x0
32 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\光标跟随 SUCCESS 0x1
33 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\<SPACE> SUCCESS 0x1
34 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\<ENTER> SUCCESS 0x0
35 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\FC input SUCCESS 0x1
36 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\FC aid SUCCESS 0x1
37 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\EUDCDictName NOTFOUND
38 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\EUDCMapFileName NOTFOUND
39 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\编码查询 SUCCESS 0x0
40 notepad.exe QueryValue HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型\编码查询码长 SUCCESS 0x4
41 notepad.exe CloseKey HKCU\Software\Microsoft\Windows\CurrentVersion\五笔型 SUCCESS Key: 0xE32DBD60
42 notepad.exe CloseKey HKCU\Software\Microsoft\Windows\CurrentVersion SUCCESS Key: 0xE3E0D8A0
43 WINLOGON.EXE OpenKey HKCU SUCCESS Key: 0xE36CA300
44 WINLOGON.EXE OpenKey HKCU\AppEvents\Schemes\Apps\.Default\MenuPopup\.Current SUCCESS Key: 0xE3E54A60
45 WINLOGON.EXE QueryValue HKCU\AppEvents\Schemes\Apps\.Default\MenuPopup\.Current\(Default) SUCCESS ""
46 WINLOGON.EXE CloseKey HKCU\AppEvents\Schemes\Apps\.Default\MenuPopup\.Current SUCCESS Key: 0xE3E54A60
47 WINLOGON.EXE CloseKey HKCU SUCCESS Key: 0xE36CA300
48 WINLOGON.EXE OpenKey HKCU SUCCESS Key: 0xE36CA300
49 WINLOGON.EXE OpenKey HKCU\AppEvents\Schemes\Apps\.Default\MenuPopup\.Current\Active NOTFOUND
50 WINLOGON.EXE QueryValue HKCU\(Default) NOTFOUND
51 WINLOGON.EXE CloseKey HKCU SUCCESS Key: 0xE36CA300
52 WINLOGON.EXE OpenKey HKLM\Software\Microsoft\Windows\CurrentVersion SUCCESS Key: 0xE36CA300
53 WINLOGON.EXE OpenKey HKLM\Software\Microsoft\Windows\CurrentVersion\Software\Microsoft\Windows\CurrentVersion NOTFOUND
54 WINLOGON.EXE QueryValue HKLM\Software\Microsoft\Windows\CurrentVersion\MediaPath SUCCESS "C:\WINNT\Media"
55 WINLOGON.EXE CloseKey HKLM\Software\Microsoft\Windows\CurrentVersion SUCCESS Key: 0xE36CA300
56 LSASS.EXE OpenKey HKLM\System\CurrentControlSet\Control\Lsa SUCCESS Key: 0xE31E71E0
57 LSASS.EXE QueryValue HKLM\System\CurrentControlSet\Control\Lsa\RestrictAnonymous SUCCESS 0x0
58 LSASS.EXE CloseKey HKLM\System\CurrentControlSet\Control\Lsa SUCCESS Key: 0xE31E71E0
59 dllhost.exe OpenKey HKU\.DEFAULT\Software\ORACLE\HOME0 NOTFOUND
60 dllhost.exe OpenKey HKLM\Software\ORACLE\HOME0 SUCCESS Key: 0xE31E71E0
61 dllhost.exe QueryValue HKLM\Software\ORACLE\HOME0\ORA_NLS_PROFILE33 NOTFOUND
62 dllhost.exe CloseKey HKLM\Software\ORACLE\HOME0 SUCCESS Key: 0xE31E71E0
63 dllhost.exe OpenKey HKU\.DEFAULT\Software\ORACLE\HOME0 NOTFOUND
64 dllhost.exe OpenKey HKLM\Software\ORACLE\HOME0 SUCCESS Key: 0xE356F560
...
txtview.txtviewctrl.1不是windows的基本com服务器,我这里就没有,你可以看一下它的inprocserver32或是其它的主键下的值,看它到底在哪里,再看一下版本信息。
111222 2001-07-29
  • 打赏
  • 举报
回复
找不到,HKEY_CLASSES_ROOT\TXTVIEW.TxtviewCtrl.1
这个键是不是指看txt的控件?是不是edit?
kenny_yuan 2001-07-29
  • 打赏
  • 举报
回复
还要试验中,明天又要上班了,还得加班,真想今晚就解决掉!
kenny_yuan 2001-07-29
  • 打赏
  • 举报
回复
to masterz:
thanx, but all I wanna know is how to get the menu, not how to set the global hook, which I've already known.
加载更多回复(9)

16,548

社区成员

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

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

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