[AAuto] 菜单演示程序

import win.ui;
import win.ui.menu;
/*DSG{{*/
var winform = win.form( right=337;bottom=229;parent=...;text="菜单图标及加速键演示程序";max=false )
winform.add( 
edit={ bottom=230;right=338;left=0;multiline=1;top=0;z=1;edge=1;cls="edit" }
)
/*}}*/

var str = /*
加速键列表:

新建:Ctrl+N
打开:Ctrl+O
保存:Ctrl+S
打印:Ctrl+P
退出:Ctrl+E

导航键说明:

首先按下Alt键,菜单选项后面设置的键会出现下划线,
再按下菜单后面的按键、就可以一步步选择菜单了! .....
^_^
*/; 
winform.edit.text = str;

var new = function(id){winform.msgbox("新建")};
var open = function(id){winform.msgbox("打开")};
var save = function(id){winform.msgbox("保存")};
var print = function(id){winform.msgbox("打印")};
var exit = function(id){winform.close()};

import win.ui.accelerator;

var accel = win.ui.accelerator({
{ ctrl = true; vkey = 'N'#; oncommand = new }
{ ctrl = true; vkey = 'O'#; oncommand = open } 
{ ctrl = true; vkey = 'S'#; oncommand = save } 
{ ctrl = true; vkey = 'P'#; oncommand = print } 
{ ctrl = true; vkey = 'Q'#; oncommand = exit }  
},winform)


//注意菜单的导航键'文件(&F)'、加速键'文件\tCtrl+N' ,此文本样式只有在单引号  '' 下才有效!
 
var menu = win.ui.menu(winform);
menu.addTable( {
	{ '文件(&F)';
		{//图标文件为16*16的位图 默认背景色为#f0f0f0
			{text = '新建(&N)\tCtrl+N';proc=new;bitmap="\res\ico\new.bmp"};
			{text='打开(&O)\tCtrl+O';proc=open;bitmap="\res\ico\open.bmp"};
			{text = '保存(&S)\tCtrl+S';proc=save;bitmap="\res\ico\save.bmp"};
			{/*分割线*/};
			{text='打印(&P)\tCtrl+P';proc=print;bitmap="\res\ico\print.bmp"}
			{/*分割线*/};
			{text='退出(&E)\tCtrl+E';proc=exit;bitmap="\res\ico\close.bmp"};
		}
	};
	{ '帮助(&H)';
		{
			{text = '帮助(&H)';
				proc = function(id){
					winform.msgbox("帮助")
				};
				bitmap="\res\ico\help.bmp"};
			
			{text = '主页(&P)';
				proc = function(id){
					import process;
					process.execute( "http://www.aau.cn" )
				};
				bitmap="\res\ico\home.bmp"
			}
			{/*__*/}
			{text = '关于(&A)';
				proc = function(id){
					winform.msgbox("菜单图标及加速键演示程序! -- xAuto","关于")
				};
				bitmap="\res\ico\info.bmp"	
			}
		}
	};
})

//创建右键弹出菜单
var popmenu = win.ui.popmenu(winform);
popmenu.addTable( {
	{ text="复制";proc=function(id){winform.edit.copy()};bitmap="\res\ico\copy.bmp"}; 
	{ text="剪切";proc=function(id){winform.edit.cut()};bitmap="\res\ico\cut.bmp"}; 
	{ text="粘贴";proc=function(id){winform.edit.paste()};bitmap="\res\ico\paste.bmp"}; 
	{/*__*/}
	{ text="撤消";proc=function(id){winform.edit.undo()};bitmap="\res\ico\undo.bmp"}; 
	{ text="重做";proc=function(id){winform.edit.redo()};bitmap="\res\ico\redo.bmp"}; 
	{/*__*/}
	{ text="全选";proc=function(id){winform.edit.selectAll()};bitmap="\res\ico\select.bmp"}; 
} )

winform.edit.wndproc = function(hwnd,message,wParam,lParam){
	if(message= 0x205/*_WM_RBUTTONUP*/ ){ 
		popmenu.popup(::LOWORD(lParam), ::HIWORD(lParam));//弹出菜单
		return false; 
	}
}//endproc

//重写winform.isDialogMessage函数,屏蔽按Esc退出程序的问题。
winform.isDialogMessage = function(hwnd,msg){
	if(msg.message = 0x100/*_WM_KEYDOWN*/){
		if(msg.wParam = 0x1B/*_VK_ESCAPE*/)
			return true; 
	}
}

winform.show() 

win.loopMessage();

return winform;

demo及源码:点击下载

你可能感兴趣的:(源码,menu,aauto)