



function setting(){


	
	
	
	var frm=new VCLForm(true);
	
	frm.width=130;
	frm.height=130;
	frm.left=Memo.left+20;
	frm.top=Memo.top+20;
	//frm.Position='poScreenCenter';
	frm.caption='File cabinet';
	frm.caption='Drop or Delete item.';
	frm.Bordericons='biSystemMenu';
	frm.Borderstyle='bsSizeToolWin';
	frm.acceptDrop=true;
	//alert(frm.getEvents());
	
	
	
	var lv=new VCLListView(frm);
	
	
	
	lv.column.add();
	lv.column.items[0].width=100;
	lv.ShowColumnHeaders=false;
	lv.ViewStyle='vsReport';
	
	lv.GridLines=false;
	
	
			
	//lv.ViewStyle='vsSmallIcon';
	//lv.ViewStyle='vsList';
	
	
	lv.ReadOnly=true;
	lv.Align='alClient';
	lv.borderstyle='bsNone';
	
				
	lv.onDblClick = function(sender){
		//alert(lv.Selected.sdata);
		//dcall.ShellExecute(0, '', lv.Selected.sdata , '', '', 1);
		Win32.shellExecute( '', lv.Selected.sdata , '', '');
	};	
	
	lv.onKeyUp = function(Sender,Key){
		//alert(Key);
		if(Key==46||Key==8){
			for(var i=0;i<lv.items.count;i++){
				if(lv.items[i]==lv.Selected){lv.items.delete(i);};
			}
		
		}
	};		
	
	
	
	
	frm.onDragDropFiles=function(form,x,y,files){
		for (var i=0;i<files.count;i++){
			lv.items.add();
			file=new File(files[i]);
			//alert(file.exists());
			lv.items[lv.items.count-1].caption=file.extractName();
			//if(!file.exists()){   lv.items[lv.items.count-1].caption = '['+lv.items[lv.items.count-1].caption+']';   }
			lv.items[lv.items.count-1].sdata=files[i];
		}
	
	 };
	
	
	frm.onCloseQuery=function(){
	
		var sl=new Strings;
		var data=new Strings;
		
			for(var i=0;i<lv.items.count;i++){
				data.clear();
				data.add(lv.items[i].caption);
				data.add(lv.items[i].sdata);
				sl.add(data.commaText);
			}
			
		sl.saveToFile(Memo.id);
		
		var ini = new Ini(Memo.id + '.ini');
		ini.write('setting','width',frm.width);
		ini.write('setting','height',frm.height);	
		ini.update();	
	};
	
	frm.onShow=function(){
	
		var sl=new Strings;
		var data=new Strings;
		if( new File(Memo.id).exists()  ){
			sl.loadFromFile(Memo.id);
			
				for(var i=0;i<sl.count;i++){
					data.clear();
					data.commaText=sl[i];
					if (data.count>=2){
						lv.items.add();
						lv.items[lv.items.count-1].caption=data[0];
						lv.items[lv.items.count-1].sdata=data[1];
						lv.items[lv.items.count-1].ImageIndex=1;
					}
				}
		}
		
		var ini = new Ini(Memo.id + '.ini');
		frm.width=ini.read('setting','width','130');
		frm.height=ini.read('setting','height','130');
			
	};
	
	
			
	 // frm.show(); //フォームを表示
	
	  frm.showModal(); //フォームを表示	
	
	  //eventLoop();

}




dcalllb = new DynaCall;
dcalllb.register('user32','LoadImage','i=lsullu','f=s','r=l');

dcalld = new DynaCall;
dcalld.register('GDI32.DLL','DeleteObject','i=l','f=s','r=l');




var bmp_file = dcalllb.LoadImage(0,"file.bmp",0,0,0,0x0010);
var bmp_exe = dcalllb.LoadImage(0,"exe.bmp",0,0,0,0x0010);
var bmp_dir = dcalllb.LoadImage(0,"dir.bmp",0,0,0,0x0010);








mitems=new Array();

menu = new VCLPopupMenu;





		var sl=new Strings;
		var data=new Strings;
		if( new File(Memo.id).exists()  ){
			sl.loadFromFile(Memo.id);
			
				for(var i=0;i<sl.count;i++){
					data.clear();
					data.commaText=sl[i];
					if (data.count>=2){
						
						mitems.add( new VCLMenuItem );
						mitems[mitems.length-1].caption=data[0];
						mitems[mitems.length-1].sdata=data[1];
						mitems[mitems.length-1].onClick = function (sender){
							Win32.shellExecute( '', sender.sdata , '', '');
						};
						
						
						
						file=new File(data[1]);
						if(!file.exists()){
							if(new Directory(data[1]).exists()){
								mitems[mitems.length-1].setBitmapHandle(bmp_dir);
								menu.Items.add(mitems[mitems.length-1]);
							}
						}else{
							if( file.extractExt().toLowerCase() == '.exe' ){
								mitems[mitems.length-1].setBitmapHandle(bmp_exe);
							}else{
								mitems[mitems.length-1].setBitmapHandle(bmp_file);
							}
							menu.Items.add(mitems[mitems.length-1]);						
						}
						
					}
				}
		}


			




mitem2 = new VCLMenuItem;
mitem2.caption='-';
menu.Items.add(mitem2);


mitem = new VCLMenuItem;
mitem.caption='File Cabinet Setting...';
mitem.onClick = function (){
	setting();
};
menu.Items.add(mitem);





menu.popup(Mouse.x,Mouse.y);
eventLoop();
doEvents();
terminate();








 dcalld.DeleteObject(bmp_file)  ;
 dcalld.DeleteObject(bmp_exe)  ;
 dcalld.DeleteObject(bmp_dir)  ;




