两个程序间消息传递的问题!
wfu 2002-06-08 03:30:27 我在程序中启动了一个外部程序abc.exe.在取得外部程序的句柄后,使用AppendMenu(),往这个外部程序里加了一个菜单,代码如下:
WinExec("E:\\Kodak\\XVCS\\MVCS.exe", SW_SHOW);
HWND hwnd;
HWND myhwnd;
char *title;
title =new char[255];
int len;
AnsiString Msg;
Sleep(1000);
bool Loop;
Loop=true;
myhwnd=GetActiveWindow();
do
{
hwnd=GetForegroundWindow();
GetWindowText(hwnd,title,len);
Msg=AnsiString(title);
if(Msg.SubString(1,3)=="Mid")
Loop=false;
}while(Loop);
int MenuPos;
HMENU MVCXMenu;
MVCXMenu=GetMenu(hwnd);
MenuPos=GetMenuItemCount(MVCXMenu);
AppendMenu(MVCXMenu,MF_BYPOSITION,MenuPos,"菜单1");
HMENU MyMenu;
MyMenu=GetSubMenu(MVCXMenu,MenuPos);
InsertMenu(MyMenu,0,MF_BYPOSITION,1,"menu1");
InsertMenu(MyMenu,1,MF_BYPOSITION,0,"menu2");
InsertMenu(MyMenu,2,MF_BYPOSITION,0,"menu3");
DrawMenuBar(hwnd);
delete [] title;
现在的问题是:
1、第一级菜单“菜单1”添加成功,而下面的子菜单“menu1”“menu2”“ menu3”添加没成功!
2、菜单添加后怎样响应用户单击我增加的“菜单1”的事件?也就是怎样捕获用户单击我增加的“菜单1”的消息?