回 帖 发 新 帖 刷新版面

主题:请教关于在DLL中添加菜单TMenuItem的问题

我编写了一个DLL,把主程序的Popup菜单的指针传到这个DLL中,然后在DLL中添加子菜单,菜单能添加成功,但是菜单的OnClick事件只能在前3个子菜单中触发,非常奇怪,如下示例:
这是一个DLL中的函数:
void __stdcall AddSubMenu(LPVOID popMenu)
{    
    TPopupMenu *pMenu = (TPopupMenu *)popMenu;
    TMenuItem *item = new TMenuItem(item);
    item->Caption = "NewItem";
    pMenu->Add(item);
    //下在增加子菜单,SubItemClick是菜单单击事件函数
    for(int i=0;i<10;i++)
    {
        TMenuItem *subitem = new TMenuItem(item);
        subitem->Caption = "SubItem"+String(i);
        subitem->OnClick = SubItemClick;
        item->Add(subitem);
    }
}
以后函数能添加菜单成功,但只是前面3个SubItem能触发OnClick事件,后面的不触发,不知为什么,请高手指教?

回复列表 (共2个回复)

沙发


    TMenuItem *item = new TMenuItem(item);
改為:

    TMenuItem *item = new TMenuItem(pMenu);

板凳

不会添加的,我也是来学习的




















Signature--------------------------------------------------------
Experience is the father of wisdom and memory the mother[url=http://www.freerunall.com/nike-lunarglide-2-c-32.html]nike lunarglide 2[/url] [url=http://www.freerunall.com/nike-lunarglide-3-c-20.html]nike lunarglide 3[/url] [url=http://www.freerunall.com/nike-free-30-v2-c-26.html]nike free 3.0 V2[/url] [url=http://www.freerunall.com/nike-lunarfly-c-39.html]nike lunarfly[/url]

我来回复

您尚未登录,请登录后再回复。点此登录或注册