//AAuto界面演示
//AAuto界面演示//模仿QQ登陆界面

/************************************
Author		: ECranesoft Lab
Time		: March 17, 2010
Version		: V1.0.0.01
Description : This demonstrated the AAuto UI.
************************************/

import win;
import win.ui; 
import win.ui.menu
import win.ole.image
/*DSG{{*/
var winform = win.form(parent=...; bgcolor=16708835;bottom=226;text="AAuto_UI_QQ2010";left=0;title="AAuto Form";exmode="";min=1;style=0;right=350;top=0;cls="AAuto_QQ2010" )
winform.add( 
checkbox={ dl=1;checked=1;bottom=172;color=0;text="记住密码";left=126;dt=1;top=152;acceptfiles=1;z=4;tabstop=1;bgcolor=16708835;right=192;cls="checkbox" };
edit2={ dl=1;bgcolor=16777215;color=0;right=248;left=84;dt=1;cls="edit";bottom=130;text="AAuto Studio";top=109;acceptfiles=1;tabstop=1;z=15;edge=1;password=1 };
picturebox2={ dl=1;bgcolor=14215660;color=0;right=352;left=-1;dt=1;image=$"\.res\logon.jpg";cls="picturebox";z=2;bottom=57;text="picturebox2";top=-4;acceptfiles=1;tabstop=1;transparent=1 };
picturebox_floating={ dl=1;bgcolor=14215660;notify=1;color=0;right=111;left=80;dt=1;image=$"\.res\state.jpg";cls="picturebox";z=3;bottom=172;text="picturebox_floating";top=152;acceptfiles=1;tabstop=1;transparent=1 };
checkbox2={ dl=1;bgcolor=16577509;bottom=172;color=0;text="自动登录";left=209;dt=1;top=152;acceptfiles=1;z=7;tabstop=1;right=275;cls="checkbox" };
static={ dl=1;bgcolor=14215660;bottom=92;color=0;text="账 号：";left=37;dt=1;top=72;acceptfiles=1;z=5;right=84;tabstop=1;transparent=1;cls="static" };
static4={ dl=1;bgcolor=14215660;notify=1;color=16711680;right=331;left=266;dt=1;cls="static";transparent=1;bottom=134;text="找回密码";top=114;acceptfiles=1;z=8;tabstop=1 };
button3={ dl=1;bgcolor=14215660;color=0;right=324;left=248;dt=1;cls="button";bottom=216;align="";text="登 录";top=193;acceptfiles=1;tabstop=1;z=9;transparent=1 };
static5={ dl=1;bgcolor=14215660;bottom=174;color=0;text="状 态：";left=36;dt=1;top=154;acceptfiles=1;z=6;right=83;tabstop=1;transparent=1;cls="static" };
button2={ flat=1;bgcolor=14215660;color=0;right=335;left=310;dt=1;cls="button";bottom=177;align="";text="5";top=157;font=LOGFONT( name="Webdings";charset=2;out=3;family=18;clip=2;quality=1 );acceptfiles=1;transparent=1;dl=1;tabstop=1;z=0 };
static3={ dl=1;bgcolor=14215660;notify=1;color=16711680;right=331;left=266;dt=1;cls="static";transparent=1;bottom=97;text="注册新账号";top=77;acceptfiles=1;z=10;tabstop=1 };
static2={ dl=1;bgcolor=14215660;bottom=137;color=0;text="密 码：";left=37;dt=1;top=117;acceptfiles=1;z=11;right=84;tabstop=1;transparent=1;cls="static" };
button={ dl=1;bgcolor=14215660;color=0;right=99;left=23;dt=1;cls="button";bottom=216;align="";text="设 置";top=193;acceptfiles=1;tabstop=1;z=12;transparent=1 };
picturebox={ dl=1;bgcolor=16379852;bottom=223;color=0;text="▲";left=0;dt=1;top=182;acceptfiles=1;z=14;tabstop=1;right=347;cls="picturebox" };
button4={ dl=1;bgcolor=14215660;color=0;right=114;left=79;dt=1;image=$"\.res\state.jpg";cls="button";bottom=169;align="";text="button4";top=152;acceptfiles=1;z=13;tabstop=1 };
combobox={ dl=1;bgcolor=14215660;color=0;right=249;left=85;dt=1;mode="dropdown";cls="combobox";bottom=91;text="combobox";
items={ "90244548" };acceptfiles=1;tabstop=1;top=71;transparent=1;edge=1;z=1 }
)
/*}}*/

var m_isover_floatingbtn = false;
winform.wndproc = function(hwnd,message,wparam,lparam){
select(message) {//判断消息类型
	case 0x201/*_WM_LBUTTONDOWN*/ {//鼠标按下
	
	}
	case 0x200/*_WM_MOUSEMOVE*/ 
	{
	    	winform.picturebox_floating.hide= false;
	    	winform.button4.hide= true;
	    	if(m_isover_floatingbtn){ 
	    	    m_isover_floatingbtn= false;
	    	    winform.redraw();
	    	}
    }  
	case 0x202/*_WM_LBUTTONUP*///鼠标弹起
	{ }
	case 0x3/*_WM_MOVE*/ //鼠标移动
	{ }
	case 0x10/*_WM_CLOSE*///窗口关闭消息
	{ }
	case 0x205/*_WM_RBUTTONUP*///鼠标右键弹起消息
	{
	//winform.popmenu.popup(::LOWORD(lparam), ::HIWORD(lparam));//弹出菜单
	}
	else
	{ }
}
}//endproc

winform.picturebox_floating.wndproc = function(hwnd,message,wparam,lparam){
	select(message) {
		case 0x200/*_WM_MOUSEMOVE*/ 
		{
	    	winform.picturebox_floating.hide= true;
	    	winform.button4.hide= false;
	    	m_isover_floatingbtn = true;
		}   
	}
	//无返回值则继续调用默认回调函数
}//endproc
winform.button4.wndproc = function(hwnd,message,wparam,lparam){
	
	//无返回值则继续调用默认回调函数
}//endproc
winform.button4.oncommand = function(id,event){
	//win.msgbox( winform.button4.text );
	
	var popmenu1 = win.ui.popmenu(winform);
	popmenu1.add('我在线上',function(){win.msgbox("我在线上!","AAuto UI Demo" )});
	popmenu1.add('Q 我吧',function(){win.msgbox("Q 我吧!","AAuto UI Demo" )});
	popmenu1.add();
	popmenu1.add('离 开',function(){win.msgbox("离 开!","AAuto UI Demo" )});
	popmenu1.add('忙 碌',function(){win.msgbox("忙 碌!","AAuto UI Demo" )});
	popmenu1.add('请勿打扰',function(){win.msgbox("请勿打扰!","AAuto UI Demo" )});
	popmenu1.add();
	popmenu1.add('隐 身',function(){win.msgbox("隐 身!","AAuto UI Demo" )});
	//添加按钮弹出菜单

	popmenu1.popup(winform.button4.right - 34 ,winform.button4.bottom);
	
	//无返回值则继续调用默认回调函数
}//endproc

winform.button4.hide= true;

/*
//对于独立运行的aau文件，已直接支持将启动文件所在目录作为虚拟根目录
//是以不再需要此处代码
path = io.splitpath(...)
winform.button4.image = path.dir + ".res\state.jpg";
winform.picturebox_floating.image = path.dir + ".res\state.jpg";
 
winform.picturebox2.image = path.dir + ".res\logon.jpg";
winform.redraw();
winform.combobox.selectIndex = 0;
*/


winform.button3.oncommand = function(id,event){
	//win.msgbox( winform.button3.text );
	var userID = winform.combobox.text;
	var userPW = winform.edit2.text;
	var strTemp = string.format( '帐号是: %s\r\n密码是: %s', userID,userPW);
	win.msgbox(strTemp ,"AAuto_UI_DEMO" );

	//无返回值则继续调用默认回调函数
}//endproc

winform.static4.oncommand = function(id,event){
	//win.msgbox( winform.static4.text );
	import process;
	::ShellExecute(0, "", "http://www.ecranesoft.com/bbs", "", "", 0);
	//无返回值则继续调用默认回调函数
}//endproc

winform.picturebox3.oncommand = function(id,event){
	//win.msgbox( winform.picturebox3.text );
	
	//无返回值则继续调用默认回调函数
}//endproc

winform.static3.oncommand = function(id,event){
	//win.msgbox( winform.static3.text );
	//无返回值则继续调用默认回调函数
	import process;
	::ShellExecute(0, "", "http://www.ecranesoft.com/bbs", "", "", 0);
}//endproc
  set = false;
winform.button2.oncommand = function(id,event){
	//win.msgbox( winform.button2.text );
	winform.button.hide= true;
	winform.button3.hide= true;
	var rc = ::RECT();
	
	if(!set){
		winform.button.hide= true;
		winform.button3.hide= true;
	::GetWindowRect( winform.hwnd,rc );
	::MoveWindow(winform.hwnd,rc.left,rc.top,rc.right - rc.left,rc.bottom - rc.top -40,1);
	set = true;
	winform.button2.text = "6"
	}
	else{ 
		winform.button.hide= false;
		winform.button3.hide= false;
		::GetWindowRect( winform.hwnd,rc );
		::MoveWindow(winform.hwnd,rc.left,rc.top,rc.right - rc.left,rc.bottom - rc.top +40,1);
		set = false;
		winform.button2.text = "5"
	}
 	
	//无返回值则继续调用默认回调函数
}//endproc
winform.addtimer(1000/*毫秒*/,function(hwnd,msg,id,time){//定时执行代码
	

	//winform.killtimer(id)//移除此定时器
	});
winform.show(true) 
win.loopMessage( winform );
