多级菜单案例

admin2021-03-01  150

import win.ui;
import win.ui.menu;
/*DSG{{*/
var winform = win.form(parent=...; bottom=249;right=349;text="aardio Form";maxmize=1 )
winform.add(  )
/*}}*/

var menu = win.ui.menu(winform);//创建主菜单
menu.addTable( {
    { "文件";
            { //----------------
                {   "子菜单";
                    function(id){
                        winform.msgbox("文件->子菜单")
                    }
                };
                {   "子菜单2";
                    function(id){
                        winform.msgbox("文件->子菜单2")
                    }
                }   
            } //----------------
    };
    { "编辑";
            { //----------------
                {   "子菜单";
                    function(id){
                        winform.msgbox("编辑->子菜单")
                    }
                };
                {   "子菜单2";
                    function(id){
                        winform.msgbox("编辑->子菜单2")
                    }
                }   
            } //----------------
    };
    { "编辑2";
            { //----------------
                {   "子菜单";
                    function(id){
                        winform.msgbox("编辑2->子菜单")
                    }
                };
                {   "子菜单2";
                    function(id){
                        winform.msgbox("编辑2->子菜单2")
                    }
                }   
            } //----------------
    };
} )

winform.show()
win.loopMessage();
import win.ui.menu
winform. wndproc =function(hwnd, message,wParam,LParam){
	select(message) {
		case 0x205/*_LWM_RBUTTONUP*/ {
			var x,y = win.getMessagePos(LParam);
			var popMenu = win.ui.popmenu(winform)
			popMenu.addTable({
				{ "菜单文本"; {{
					"子菜单";{{
						"下级子菜单"; function(){
							winform.msgbox("hi")
						}
					}}
				}}};
				{ /*分隔线*/ }
				{ "退出程序"; function(id){
					winform.close()
				} };
			})
			popMenu.popup(x,y)
		}
	}
	//无返回值则继续调用默认回调函数
}
转载请注明原文地址: https://www.aardio.net/read-157.html
最新回复(0)