Index: trunk/ab5.0/abdev/abdev/WindowControl.cpp
===================================================================
--- trunk/ab5.0/abdev/abdev/WindowControl.cpp	(revision 609)
+++ trunk/ab5.0/abdev/abdev/WindowControl.cpp	(revision 612)
@@ -15,6 +15,5 @@
 int GetWndInfoNum(char *name){
 	extern PROJECTINFO ProjectInfo;
-	int i;
-	for(i=0;i<ProjectInfo.windowInfos.size();i++){
+	for( int i=0;i<static_cast<int>(ProjectInfo.windowInfos.size());i++){
 		if(lstrcmpi(name,ProjectInfo.windowInfos[i].name)==0) return i;
 	}
@@ -24,8 +23,7 @@
 {
 	extern PROJECTINFO ProjectInfo;
-	int i;
-	for( int i=0;i<ProjectInfo.windowInfos.size();i++)
+	BOOST_FOREACH( WINDOW_INFO &windowInfo, ProjectInfo.windowInfos )
 	{
-		if(lstrcmpi(name,ProjectInfo.windowInfos[i].name)==0) return &ProjectInfo.windowInfos[i];
+		if(lstrcmpi(name,windowInfo.name)==0) return &windowInfo;
 	}
 	return NULL;
@@ -1008,10 +1006,13 @@
 
 	ppNames=(char **)HeapAlloc(hHeap,0,1);
-	for(i=0,i4=1000,i5=0;i<ProjectInfo.windowInfos.size();i++){
-		for(i3=0;i3<ProjectInfo.windowInfos[i].NumberOfChildWindows;i3++){
+	i4=1000;
+	i5=0;
+	BOOST_FOREACH( WINDOW_INFO &windowInfo, ProjectInfo.windowInfos )
+	{
+		for(i3=0;i3<windowInfo.NumberOfChildWindows;i3++){
 
 			//重複チェック
 			for(i6=0,sw1=0;i6<i5;i6++){
-				if(lstrcmpi(ppNames[i6],ProjectInfo.windowInfos[i].pChildInfo[i3].IdName)==0){
+				if(lstrcmpi(ppNames[i6],windowInfo.pChildInfo[i3].IdName)==0){
 					sw1=1;
 					break;
@@ -1021,8 +1022,8 @@
 
 			ppNames=(char **)HeapReAlloc(hHeap,0,ppNames,sizeof(char *)*(i5+1));
-			ppNames[i5]=ProjectInfo.windowInfos[i].pChildInfo[i3].IdName;
+			ppNames[i5]=windowInfo.pChildInfo[i3].IdName;
 			i5++;
 
-			sprintf(buffer+i2,"Const %s=%d\r\n",ProjectInfo.windowInfos[i].pChildInfo[i3].IdName,i4);
+			sprintf(buffer+i2,"Const %s=%d\r\n",windowInfo.pChildInfo[i3].IdName,i4);
 			i2+=lstrlen(buffer+i2);
 			i4++;
@@ -1044,25 +1045,26 @@
 
 	//ハンドル変数を定義
-	for(i=0;i<ProjectInfo.windowInfos.size();i++){
-		sprintf(buffer+i2,"Dim %s As HWND\r\n",ProjectInfo.windowInfos[i].HandleName);
-		i2+=lstrlen(buffer+i2);
-		sprintf(buffer+i2,"Dim hFont_%s As HFONT\r\n",ProjectInfo.windowInfos[i].name);
+	BOOST_FOREACH( WINDOW_INFO &windowInfo, ProjectInfo.windowInfos )
+	{
+		sprintf(buffer+i2,"Dim %s As HWND\r\n",windowInfo.HandleName);
+		i2+=lstrlen(buffer+i2);
+		sprintf(buffer+i2,"Dim hFont_%s As HFONT\r\n",windowInfo.name);
 		i2+=lstrlen(buffer+i2);
 		sprintf(buffer+i2,"hFont_%s=CreateFont(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\"%s\")\r\n",
-			ProjectInfo.windowInfos[i].name,
-			ProjectInfo.windowInfos[i].LogFont.lfHeight,
-			ProjectInfo.windowInfos[i].LogFont.lfWidth,
-			ProjectInfo.windowInfos[i].LogFont.lfEscapement,
-			ProjectInfo.windowInfos[i].LogFont.lfOrientation,
-			ProjectInfo.windowInfos[i].LogFont.lfWeight,
-			ProjectInfo.windowInfos[i].LogFont.lfItalic,
-			ProjectInfo.windowInfos[i].LogFont.lfUnderline,
-			ProjectInfo.windowInfos[i].LogFont.lfStrikeOut,
-			ProjectInfo.windowInfos[i].LogFont.lfCharSet,
-			ProjectInfo.windowInfos[i].LogFont.lfOutPrecision,
-			ProjectInfo.windowInfos[i].LogFont.lfClipPrecision,
-			ProjectInfo.windowInfos[i].LogFont.lfQuality,
-			ProjectInfo.windowInfos[i].LogFont.lfPitchAndFamily,
-			ProjectInfo.windowInfos[i].LogFont.lfFaceName);
+			windowInfo.name,
+			windowInfo.LogFont.lfHeight,
+			windowInfo.LogFont.lfWidth,
+			windowInfo.LogFont.lfEscapement,
+			windowInfo.LogFont.lfOrientation,
+			windowInfo.LogFont.lfWeight,
+			windowInfo.LogFont.lfItalic,
+			windowInfo.LogFont.lfUnderline,
+			windowInfo.LogFont.lfStrikeOut,
+			windowInfo.LogFont.lfCharSet,
+			windowInfo.LogFont.lfOutPrecision,
+			windowInfo.LogFont.lfClipPrecision,
+			windowInfo.LogFont.lfQuality,
+			windowInfo.LogFont.lfPitchAndFamily,
+			windowInfo.LogFont.lfFaceName);
 		i2+=lstrlen(buffer+i2);
 
@@ -1078,21 +1080,25 @@
 	lstrcpy(buffer+i2,"h3DFaceBrush=CreateSolidBrush(GetSysColor(COLOR_3DFACE))\r\n");
 	i2+=lstrlen(buffer+i2);
-	for(i=0;i<ProjectInfo.windowInfos.size();i++){
-		if(ProjectInfo.windowInfos[i].bgColor<=0&&
-			ProjectInfo.windowInfos[i].bgColor!=-(int)RGB(255,255,255)&&
-			ProjectInfo.windowInfos[i].bgColor!=-(int)RGB(0,0,0)){
+	i=0;
+	BOOST_FOREACH( WINDOW_INFO &windowInfo, ProjectInfo.windowInfos )
+	{
+		if(windowInfo.bgColor<=0&&
+			windowInfo.bgColor!=-(int)RGB(255,255,255)&&
+			windowInfo.bgColor!=-(int)RGB(0,0,0)){
 				sprintf(buffer+i2,"Dim _RadSys_hBackBrush%d As HBRUSH\r\n",i);
 				i2+=lstrlen(buffer+i2);
-				sprintf(buffer+i2,"_RadSys_hBackBrush%d=CreateSolidBrush(%d)\r\n",i,-ProjectInfo.windowInfos[i].bgColor);
+				sprintf(buffer+i2,"_RadSys_hBackBrush%d=CreateSolidBrush(%d)\r\n",i,-windowInfo.bgColor);
 				i2+=lstrlen(buffer+i2);
 		}
-		if(ProjectInfo.windowInfos[i].bgColor>=0x1000){
+		if(windowInfo.bgColor>=0x1000){
 				sprintf(buffer+i2,"Dim _RadSys_hBackBrush%d As HBRUSH\r\n",i);
 				i2+=lstrlen(buffer+i2);
 				sprintf(buffer+i2,"_RadSys_hBackBrush%d=CreatePatternBrush(LoadImage(GetModuleHandle(0),%s,IMAGE_BITMAP,0,0,LR_DEFAULTSIZE or LR_SHARED))\r\n",
 					i,
-					ProjectInfo.res.pBitmapResInfo[ProjectInfo.windowInfos[i].bgColor-0x1000].IdName);
+					ProjectInfo.res.pBitmapResInfo[windowInfo.bgColor-0x1000].IdName);
 				i2+=lstrlen(buffer+i2);
 		}
+
+		i++;
 	}
 
@@ -1101,10 +1107,11 @@
 
 	//イメージ ボックス用の変数を定義
-	for(i=0;i<ProjectInfo.windowInfos.size();i++){
-		for(i3=0;i3<ProjectInfo.windowInfos[i].NumberOfChildWindows;i3++){
-			if(ProjectInfo.windowInfos[i].pChildInfo[i3].Control==CT_IMAGEBOX){
-				if((ProjectInfo.windowInfos[i].pChildInfo[i3].style&0x000F)==SS_ICON||
-					(ProjectInfo.windowInfos[i].pChildInfo[i3].style&0x000F)==SS_BITMAP){
-					sprintf(buffer+i2,"Dim hImage_%s_%s As HANDLE\r\n",ProjectInfo.windowInfos[i].name,ProjectInfo.windowInfos[i].pChildInfo[i3].IdName);
+	BOOST_FOREACH( WINDOW_INFO &windowInfo, ProjectInfo.windowInfos )
+	{
+		for(i3=0;i3<windowInfo.NumberOfChildWindows;i3++){
+			if(windowInfo.pChildInfo[i3].Control==CT_IMAGEBOX){
+				if((windowInfo.pChildInfo[i3].style&0x000F)==SS_ICON||
+					(windowInfo.pChildInfo[i3].style&0x000F)==SS_BITMAP){
+					sprintf(buffer+i2,"Dim hImage_%s_%s As HANDLE\r\n",windowInfo.name,windowInfo.pChildInfo[i3].IdName);
 					i2+=lstrlen(buffer+i2);
 
@@ -1154,7 +1161,8 @@
 	}
 
-	for(i=0;i<ProjectInfo.windowInfos.size();i++){
+	BOOST_FOREACH( WINDOW_INFO &windowInfo, ProjectInfo.windowInfos )
+	{
 		//フォントハンドル解放
-		sprintf(buffer+i2,"\tDeleteObject(hFont_%s)\r\n",ProjectInfo.windowInfos[i].name);
+		sprintf(buffer+i2,"\tDeleteObject(hFont_%s)\r\n",windowInfo.name);
 		i2+=lstrlen(buffer+i2);
 
@@ -1168,11 +1176,14 @@
 	lstrcpy(buffer+i2,"\tDeleteObject(h3DFaceBrush)\r\n");
 	i2+=lstrlen(buffer+i2);
-	for(i=0;i<ProjectInfo.windowInfos.size();i++){
-		if(ProjectInfo.windowInfos[i].bgColor<=0&&
-			ProjectInfo.windowInfos[i].bgColor!=-(int)RGB(255,255,255)&&
-			ProjectInfo.windowInfos[i].bgColor!=-(int)RGB(0,0,0)){
+	i=0;
+	BOOST_FOREACH( WINDOW_INFO &windowInfo, ProjectInfo.windowInfos )
+	{
+		if(windowInfo.bgColor<=0&&
+			windowInfo.bgColor!=-(int)RGB(255,255,255)&&
+			windowInfo.bgColor!=-(int)RGB(0,0,0)){
 				sprintf(buffer+i2,"\tDeleteObject(_RadSys_hBackBrush%d)\r\n",i);
 				i2+=lstrlen(buffer+i2);
 		}
+		i++;
 	}
 
@@ -1184,5 +1195,7 @@
 
 
-	for(i=0;i<ProjectInfo.windowInfos.size();i++){
+	i=0;
+	BOOST_FOREACH( WINDOW_INFO &windowInfo, ProjectInfo.windowInfos )
+	{
 		if(i!=0){
 			lstrcpy(buffer+i2,"\r\n");
@@ -1197,5 +1210,5 @@
 		ppNames=GetProcedureNamesOfMessageCall(i,&pItemEventInfo,&i3,&bAvailUserProc[i]);
 
-		sprintf(buffer+i2,"Function EventCall_%s(hWnd As HWND, message As DWord, wParam As WPARAM, lParam As LPARAM) As LRESULT\r\n",ProjectInfo.windowInfos[i].name);
+		sprintf(buffer+i2,"Function EventCall_%s(hWnd As HWND, message As DWord, wParam As WPARAM, lParam As LPARAM) As LRESULT\r\n",windowInfo.name);
 		i2+=lstrlen(buffer+i2);
 
@@ -1235,5 +1248,5 @@
 			i2+=lstrlen(buffer+i2);
 			if(sw4){
-				sprintf(buffer+i2,"\t\t\t%s_Notify(ByVal (lParam As *NMHDR))\r\n",ProjectInfo.windowInfos[i].name);
+				sprintf(buffer+i2,"\t\t\t%s_Notify(ByVal (lParam As *NMHDR))\r\n",windowInfo.name);
 				i2+=lstrlen(buffer+i2);
 			}
@@ -1245,5 +1258,5 @@
 			i2+=lstrlen(buffer+i2);
 
-			if(GetNotifyCommandByItemMessage(&ProjectInfo.windowInfos[i],pItemEventInfo,buffer+i2,"\t\t\t\t")){
+			if(GetNotifyCommandByItemMessage(&windowInfo,pItemEventInfo,buffer+i2,"\t\t\t\t")){
 				i2+=lstrlen(buffer+i2);
 
@@ -1261,5 +1274,5 @@
 			lstrcpy(buffer+i2,"\t\tCase WM_NOTIFY\r\n");
 			i2+=lstrlen(buffer+i2);
-			sprintf(buffer+i2,"\t\t\t%s_Notify(ByVal (lParam As *NMHDR))\r\n",ProjectInfo.windowInfos[i].name);
+			sprintf(buffer+i2,"\t\t\t%s_Notify(ByVal (lParam As *NMHDR))\r\n",windowInfo.name);
 			i2+=lstrlen(buffer+i2);
 		}
@@ -1273,5 +1286,5 @@
 
 			//pItemEventInfoのIdName、EventNameメンバのメモリ解放はこの関数内で行う
-			GetCommandByItemMessage(&ProjectInfo.windowInfos[i],pItemEventInfo,buffer+i2,"\t\t\t\t");
+			GetCommandByItemMessage(&windowInfo,pItemEventInfo,buffer+i2,"\t\t\t\t");
 			i2+=lstrlen(buffer+i2);
 
@@ -1284,5 +1297,5 @@
 		lstrcpy(buffer+i2,"\t\tCase Else\r\n");
 		i2+=lstrlen(buffer+i2);
-		sprintf(buffer+i2,"\t\t\tEventCall_%s=DefWindowProc(hWnd,message,wParam,lParam)\r\n",ProjectInfo.windowInfos[i].name);
+		sprintf(buffer+i2,"\t\t\tEventCall_%s=DefWindowProc(hWnd,message,wParam,lParam)\r\n",windowInfo.name);
 		i2+=lstrlen(buffer+i2);
 		lstrcpy(buffer+i2,"\t\t\tExit Function\r\n");
@@ -1292,5 +1305,5 @@
 		i2+=lstrlen(buffer+i2);
 
-		sprintf(buffer+i2,"\tEventCall_%s=0\r\n",ProjectInfo.windowInfos[i].name);
+		sprintf(buffer+i2,"\tEventCall_%s=0\r\n",windowInfo.name);
 		i2+=lstrlen(buffer+i2);
 		lstrcpy(buffer+i2,"End Function\r\n");
@@ -1301,4 +1314,6 @@
 			buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size);
 		}
+
+		i++;
 	}
 
@@ -1344,47 +1359,50 @@
 	lstrcpy(buffer+i2,"\tDim hDlg As HWND\r\n");
 	i2+=lstrlen(buffer+i2);
-	for(i=0,sw1=0;i<ProjectInfo.windowInfos.size();i++){
-		if(ProjectInfo.windowInfos[i].type==WNDTYPE_MODALDLG){
+	sw1=0;
+	i=0;
+	BOOST_FOREACH( WINDOW_INFO &windowInfo, ProjectInfo.windowInfos )
+	{
+		if(windowInfo.type==WNDTYPE_MODALDLG){
 			if(sw1==0){
-				sprintf(buffer+i2,"\tIf lstrcmp(TemplateName,\"%s\")=0 Then\r\n",ProjectInfo.windowInfos[i].name);
+				sprintf(buffer+i2,"\tIf lstrcmp(TemplateName,\"%s\")=0 Then\r\n",windowInfo.name);
 				i2+=lstrlen(buffer+i2);
 				sw1=1;
 			}
 			else{
-				sprintf(buffer+i2,"\tElseIf lstrcmp(TemplateName,\"%s\")=0 Then\r\n",ProjectInfo.windowInfos[i].name);
+				sprintf(buffer+i2,"\tElseIf lstrcmp(TemplateName,\"%s\")=0 Then\r\n",windowInfo.name);
 				i2+=lstrlen(buffer+i2);
 			}
 			sprintf(buffer+i2,"\t\t%s=CreateWindowEx(&H%08x,\"NORMALDLG\",\"%s\",&H%08x,%d,%d,%d,%d,hOwnerWnd,%d As HMENU,GetModuleHandle(0),0)\r\n",
-				ProjectInfo.windowInfos[i].HandleName,
-				ProjectInfo.windowInfos[i].ExStyle,
-				ProjectInfo.windowInfos[i].caption,
-				ProjectInfo.windowInfos[i].style,
-				ProjectInfo.windowInfos[i].pos.x,
-				ProjectInfo.windowInfos[i].pos.y,
-				ProjectInfo.windowInfos[i].size.cx,
-				ProjectInfo.windowInfos[i].size.cy,
-				ProjectInfo.windowInfos[i].id);
+				windowInfo.HandleName,
+				windowInfo.ExStyle,
+				windowInfo.caption,
+				windowInfo.style,
+				windowInfo.pos.x,
+				windowInfo.pos.y,
+				windowInfo.size.cx,
+				windowInfo.size.cy,
+				windowInfo.id);
 			i2+=lstrlen(buffer+i2);
 			sprintf(buffer+i2,"\t\thDlg=%s\r\n",
-				ProjectInfo.windowInfos[i].HandleName);
+				windowInfo.HandleName);
 			i2+=lstrlen(buffer+i2);
 			if(bAvailUserProc[i]){
 				sprintf(buffer+i2,"\t\tSetWindowLongPtr(%s,GWLP_WNDPROC,AddressOf(%s) As LONG_PTR)\r\n",
-					ProjectInfo.windowInfos[i].HandleName,
-					ProjectInfo.windowInfos[i].CallBackName);
+					windowInfo.HandleName,
+					windowInfo.CallBackName);
 			}
 			else{
 				sprintf(buffer+i2,"\t\tSetWindowLongPtr(%s,GWLP_WNDPROC,AddressOf(EventCall_%s) As LONG_PTR)\r\n",
-					ProjectInfo.windowInfos[i].HandleName,
-					ProjectInfo.windowInfos[i].name);
-			}
-			i2+=lstrlen(buffer+i2);
-			sprintf(buffer+i2,"\t\tSendMessage(%s,WM_INITDIALOG,0,0)\r\n",ProjectInfo.windowInfos[i].HandleName);
-			i2+=lstrlen(buffer+i2);
-			if(ProjectInfo.windowInfos[i].IconResName){
-				sprintf(buffer+i2,"\t\tSendMessage(%s,WM_SETICON,ICON_SMALL,LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(%s)) As LPARAM)\r\n",ProjectInfo.windowInfos[i].HandleName,ProjectInfo.windowInfos[i].IconResName);
+					windowInfo.HandleName,
+					windowInfo.name);
+			}
+			i2+=lstrlen(buffer+i2);
+			sprintf(buffer+i2,"\t\tSendMessage(%s,WM_INITDIALOG,0,0)\r\n",windowInfo.HandleName);
+			i2+=lstrlen(buffer+i2);
+			if(windowInfo.IconResName){
+				sprintf(buffer+i2,"\t\tSendMessage(%s,WM_SETICON,ICON_SMALL,LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(%s)) As LPARAM)\r\n",windowInfo.HandleName,windowInfo.IconResName);
 				i2+=lstrlen(buffer+i2);
 			}
-			sprintf(buffer+i2,"\t\tShowWindow(%s,SW_SHOW)\r\n",ProjectInfo.windowInfos[i].HandleName);
+			sprintf(buffer+i2,"\t\tShowWindow(%s,SW_SHOW)\r\n",windowInfo.HandleName);
 			i2+=lstrlen(buffer+i2);
 		}
@@ -1393,4 +1411,5 @@
 			buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size);
 		}
+		i++;
 	}
 	if(sw1){
@@ -1440,40 +1459,42 @@
 	lstrcpy(buffer+i2,"\r\nFunction CreateDialog(hOwnerWnd As HWND, TemplateName As LPSTR) As HWND\r\n");
 	i2+=lstrlen(buffer+i2);
-	for(i=0;i<ProjectInfo.windowInfos.size();i++){
-		if(ProjectInfo.windowInfos[i].type==WNDTYPE_MODELESSDLG){
-			sprintf(buffer+i2,"\tIf lstrcmp(TemplateName,\"%s\")=0 Then\r\n",ProjectInfo.windowInfos[i].name);
+	i=0;
+	BOOST_FOREACH( WINDOW_INFO &windowInfo, ProjectInfo.windowInfos )
+	{
+		if(windowInfo.type==WNDTYPE_MODELESSDLG){
+			sprintf(buffer+i2,"\tIf lstrcmp(TemplateName,\"%s\")=0 Then\r\n",windowInfo.name);
 			i2+=lstrlen(buffer+i2);
 
 			sprintf(buffer+i2,"\t\t%s=CreateWindowEx(&H%08x,\"NORMALDLG\",\"%s\",&H%08x,%d,%d,%d,%d,hOwnerWnd,%d As HMENU,GetModuleHandle(0),0)\r\n",
-				ProjectInfo.windowInfos[i].HandleName,
-				ProjectInfo.windowInfos[i].ExStyle,
-				ProjectInfo.windowInfos[i].caption,
-				ProjectInfo.windowInfos[i].style,
-				ProjectInfo.windowInfos[i].pos.x,
-				ProjectInfo.windowInfos[i].pos.y,
-				ProjectInfo.windowInfos[i].size.cx,
-				ProjectInfo.windowInfos[i].size.cy,
-				ProjectInfo.windowInfos[i].id);
-			i2+=lstrlen(buffer+i2);
-			sprintf(buffer+i2,"\t\tCreateDialog=%s\r\n",ProjectInfo.windowInfos[i].HandleName);
+				windowInfo.HandleName,
+				windowInfo.ExStyle,
+				windowInfo.caption,
+				windowInfo.style,
+				windowInfo.pos.x,
+				windowInfo.pos.y,
+				windowInfo.size.cx,
+				windowInfo.size.cy,
+				windowInfo.id);
+			i2+=lstrlen(buffer+i2);
+			sprintf(buffer+i2,"\t\tCreateDialog=%s\r\n",windowInfo.HandleName);
 			i2+=lstrlen(buffer+i2);
 			if(bAvailUserProc[i]){
 				sprintf(buffer+i2,"\t\tSetWindowLongPtr(%s,GWLP_WNDPROC,AddressOf(%s) As LONG_PTR)\r\n",
-					ProjectInfo.windowInfos[i].HandleName,
-					ProjectInfo.windowInfos[i].CallBackName);
+					windowInfo.HandleName,
+					windowInfo.CallBackName);
 			}
 			else{
 				sprintf(buffer+i2,"\t\tSetWindowLongPtr(%s,GWLP_WNDPROC,AddressOf(EventCall_%s) As LONG_PTR)\r\n",
-					ProjectInfo.windowInfos[i].HandleName,
-					ProjectInfo.windowInfos[i].name);
-			}
-			i2+=lstrlen(buffer+i2);
-			sprintf(buffer+i2,"\t\tSendMessage(%s,WM_INITDIALOG,0,0)\r\n",ProjectInfo.windowInfos[i].HandleName);
-			i2+=lstrlen(buffer+i2);
-			if(ProjectInfo.windowInfos[i].IconResName){
-				sprintf(buffer+i2,"\t\tSendMessage(%s,WM_SETICON,ICON_SMALL,LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(%s)) As LPARAM)\r\n",ProjectInfo.windowInfos[i].HandleName,ProjectInfo.windowInfos[i].IconResName);
+					windowInfo.HandleName,
+					windowInfo.name);
+			}
+			i2+=lstrlen(buffer+i2);
+			sprintf(buffer+i2,"\t\tSendMessage(%s,WM_INITDIALOG,0,0)\r\n",windowInfo.HandleName);
+			i2+=lstrlen(buffer+i2);
+			if(windowInfo.IconResName){
+				sprintf(buffer+i2,"\t\tSendMessage(%s,WM_SETICON,ICON_SMALL,LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(%s)) As LPARAM)\r\n",windowInfo.HandleName,windowInfo.IconResName);
 				i2+=lstrlen(buffer+i2);
 			}
-			sprintf(buffer+i2,"\tEnd If\r\n",ProjectInfo.windowInfos[i].name);
+			sprintf(buffer+i2,"\tEnd If\r\n",windowInfo.name);
 			i2+=lstrlen(buffer+i2);
 		}
@@ -1482,4 +1503,5 @@
 			buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size);
 		}
+		i++;
 	}
 	lstrcpy(buffer+i2,"End Function\r\n");
@@ -1510,6 +1532,8 @@
 	i2+=lstrlen(buffer+i2);
 
-	for(i=0;i<ProjectInfo.windowInfos.size();i++){
-		if(ProjectInfo.windowInfos[i].type==WNDTYPE_DEFAULT){
+	i=0;
+	BOOST_FOREACH( WINDOW_INFO &windowInfo, ProjectInfo.windowInfos )
+	{
+		if(windowInfo.type==WNDTYPE_DEFAULT){
 			//////////////////////
 			//通常ウィンドウ作成
@@ -1518,5 +1542,5 @@
 			i2+=2;
 
-			if(ProjectInfo.windowInfos[i].IconResName==0){
+			if(windowInfo.IconResName==0){
 				lstrcpy(buffer+i2,"_RadSys_wcl.hIcon=LoadIcon(NULL,MAKEINTRESOURCE(IDI_APPLICATION))\r\n");
 				i2+=lstrlen(buffer+i2);
@@ -1525,7 +1549,7 @@
 			}
 			else{
-				sprintf(buffer+i2,"_RadSys_wcl.hIcon=LoadIcon(_RadSys_wcl.hInstance,MAKEINTRESOURCE(%s))\r\n",ProjectInfo.windowInfos[i].IconResName);
+				sprintf(buffer+i2,"_RadSys_wcl.hIcon=LoadIcon(_RadSys_wcl.hInstance,MAKEINTRESOURCE(%s))\r\n",windowInfo.IconResName);
 				i2+=lstrlen(buffer+i2);
-				sprintf(buffer+i2,"_RadSys_wcl.hIconSm=LoadIcon(_RadSys_wcl.hInstance,MAKEINTRESOURCE(%s))\r\n",ProjectInfo.windowInfos[i].IconResName);
+				sprintf(buffer+i2,"_RadSys_wcl.hIconSm=LoadIcon(_RadSys_wcl.hInstance,MAKEINTRESOURCE(%s))\r\n",windowInfo.IconResName);
 				i2+=lstrlen(buffer+i2);
 			}
@@ -1534,15 +1558,15 @@
 			i2+=lstrlen(buffer+i2);
 			if(bAvailUserProc[i])
-				sprintf(buffer+i2,"_RadSys_wcl.lpfnWndProc=AddressOf(%s)\r\n",ProjectInfo.windowInfos[i].CallBackName);
-			else sprintf(buffer+i2,"_RadSys_wcl.lpfnWndProc=AddressOf(EventCall_%s)\r\n",ProjectInfo.windowInfos[i].name);
-			i2+=lstrlen(buffer+i2);
-			if(ProjectInfo.windowInfos[i].bgColor==COLOR_3DFACE)
+				sprintf(buffer+i2,"_RadSys_wcl.lpfnWndProc=AddressOf(%s)\r\n",windowInfo.CallBackName);
+			else sprintf(buffer+i2,"_RadSys_wcl.lpfnWndProc=AddressOf(EventCall_%s)\r\n",windowInfo.name);
+			i2+=lstrlen(buffer+i2);
+			if(windowInfo.bgColor==COLOR_3DFACE)
 				lstrcpy(buffer+i2,"_RadSys_wcl.hbrBackground=h3DFaceBrush\r\n");
-			else if(ProjectInfo.windowInfos[i].bgColor==-(int)RGB(255,255,255))
+			else if(windowInfo.bgColor==-(int)RGB(255,255,255))
 				lstrcpy(buffer+i2,"_RadSys_wcl.hbrBackground=GetStockObject(WHITE_BRUSH)\r\n");
-			else if(ProjectInfo.windowInfos[i].bgColor==-(int)RGB(0,0,0))
+			else if(windowInfo.bgColor==-(int)RGB(0,0,0))
 				lstrcpy(buffer+i2,"_RadSys_wcl.hbrBackground=GetStockObject(BLACK_BRUSH)\r\n");
-			else if(ProjectInfo.windowInfos[i].bgColor<=0||
-				ProjectInfo.windowInfos[i].bgColor>=0x1000){
+			else if(windowInfo.bgColor<=0||
+				windowInfo.bgColor>=0x1000){
 				//色指定またはビットマップ
 				sprintf(buffer+i2,"_RadSys_wcl.hbrBackground=_RadSys_hBackBrush%d\r\n",i);
@@ -1552,12 +1576,12 @@
 			i2+=lstrlen(buffer+i2);
 			sprintf(buffer+i2,"CreateWindowEx(&H%08x,\"%s%d\",\"%s\",&H%08x,%d,%d,%d,%d,0,0,GetModuleHandle(0),0)\r\n",
-				ProjectInfo.windowInfos[i].ExStyle,
-				ProjectInfo.windowInfos[i].ClassName,i,
-				ProjectInfo.windowInfos[i].caption,
-				ProjectInfo.windowInfos[i].style,
-				ProjectInfo.windowInfos[i].pos.x,
-				ProjectInfo.windowInfos[i].pos.y,
-				ProjectInfo.windowInfos[i].size.cx,
-				ProjectInfo.windowInfos[i].size.cy);
+				windowInfo.ExStyle,
+				windowInfo.ClassName,i,
+				windowInfo.caption,
+				windowInfo.style,
+				windowInfo.pos.x,
+				windowInfo.pos.y,
+				windowInfo.size.cx,
+				windowInfo.size.cy);
 			i2+=lstrlen(buffer+i2);
 		}
@@ -1567,4 +1591,6 @@
 			buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size);
 		}
+
+		i++;
 	}
 
@@ -1612,70 +1638,72 @@
 	size=2;
 	buffer=(char *)HeapAlloc(hHeap,0,GENERAL_SIZE*size);
-	for(i=0,i2=0;i<windowInfos.size();i++){
-		sprintf(buffer+i2,"WINDOW:%s\r\n",windowInfos[i].name);
-		i2+=lstrlen(buffer+i2);
-		sprintf(buffer+i2,"    HANDLE    = %s\r\n",windowInfos[i].HandleName);
-		i2+=lstrlen(buffer+i2);
-		sprintf(buffer+i2,"    POINT     = %d,%d\r\n",windowInfos[i].pos.x,windowInfos[i].pos.y);
-		i2+=lstrlen(buffer+i2);
-		sprintf(buffer+i2,"    SIZE      = %d,%d\r\n",windowInfos[i].size.cx,windowInfos[i].size.cy);
-		i2+=lstrlen(buffer+i2);
-		sprintf(buffer+i2,"    CAPTION   = \"%s\"\r\n",windowInfos[i].caption);
-		i2+=lstrlen(buffer+i2);
-		sprintf(buffer+i2,"    STYLE     = &H%08x\r\n",windowInfos[i].style);
-		i2+=lstrlen(buffer+i2);
-		sprintf(buffer+i2,"    EXSTYLE   = &H%08x\r\n",windowInfos[i].ExStyle);
-		i2+=lstrlen(buffer+i2);
-		if(windowInfos[i].MenuID){
-			sprintf(buffer+i2,"    MENUID    = %s\r\n",windowInfos[i].MenuID);
-			i2+=lstrlen(buffer+i2);
-		}
-		sprintf(buffer+i2,"    ID        = %d\r\n",windowInfos[i].id);
-		i2+=lstrlen(buffer+i2);
-		sprintf(buffer+i2,"    BGCOLOR   = %d\r\n",windowInfos[i].bgColor);
+	i2=0;
+	BOOST_FOREACH( WINDOW_INFO &windowInfo, ProjectInfo.windowInfos )
+	{
+		sprintf(buffer+i2,"WINDOW:%s\r\n",windowInfo.name);
+		i2+=lstrlen(buffer+i2);
+		sprintf(buffer+i2,"    HANDLE    = %s\r\n",windowInfo.HandleName);
+		i2+=lstrlen(buffer+i2);
+		sprintf(buffer+i2,"    POINT     = %d,%d\r\n",windowInfo.pos.x,windowInfo.pos.y);
+		i2+=lstrlen(buffer+i2);
+		sprintf(buffer+i2,"    SIZE      = %d,%d\r\n",windowInfo.size.cx,windowInfo.size.cy);
+		i2+=lstrlen(buffer+i2);
+		sprintf(buffer+i2,"    CAPTION   = \"%s\"\r\n",windowInfo.caption);
+		i2+=lstrlen(buffer+i2);
+		sprintf(buffer+i2,"    STYLE     = &H%08x\r\n",windowInfo.style);
+		i2+=lstrlen(buffer+i2);
+		sprintf(buffer+i2,"    EXSTYLE   = &H%08x\r\n",windowInfo.ExStyle);
+		i2+=lstrlen(buffer+i2);
+		if(windowInfo.MenuID){
+			sprintf(buffer+i2,"    MENUID    = %s\r\n",windowInfo.MenuID);
+			i2+=lstrlen(buffer+i2);
+		}
+		sprintf(buffer+i2,"    ID        = %d\r\n",windowInfo.id);
+		i2+=lstrlen(buffer+i2);
+		sprintf(buffer+i2,"    BGCOLOR   = %d\r\n",windowInfo.bgColor);
 		i2+=lstrlen(buffer+i2);
 		sprintf(buffer+i2,"    FONT      = %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\"%s\"\r\n",
-			windowInfos[i].LogFont.lfHeight,
-			windowInfos[i].LogFont.lfWidth,
-			windowInfos[i].LogFont.lfEscapement,
-			windowInfos[i].LogFont.lfOrientation,
-			windowInfos[i].LogFont.lfWeight,
-			windowInfos[i].LogFont.lfItalic,
-			windowInfos[i].LogFont.lfUnderline,
-			windowInfos[i].LogFont.lfStrikeOut,
-			windowInfos[i].LogFont.lfCharSet,
-			windowInfos[i].LogFont.lfOutPrecision,
-			windowInfos[i].LogFont.lfClipPrecision,
-			windowInfos[i].LogFont.lfQuality,
-			windowInfos[i].LogFont.lfPitchAndFamily,
-			windowInfos[i].LogFont.lfFaceName);
-		i2+=lstrlen(buffer+i2);
-		if(windowInfos[i].IconResName){
-			sprintf(buffer+i2,"    ICONID    = %s\r\n",windowInfos[i].IconResName);
-			i2+=lstrlen(buffer+i2);
-		}
-		sprintf(buffer+i2,"    CLASS     = \"%s\"\r\n",windowInfos[i].ClassName);
-		i2+=lstrlen(buffer+i2);
-		sprintf(buffer+i2,"    CALLBACK  = %s\r\n",windowInfos[i].CallBackName);
-		i2+=lstrlen(buffer+i2);
-		sprintf(buffer+i2,"    TYPE      = %d\r\n",windowInfos[i].type);
-		i2+=lstrlen(buffer+i2);
-		sprintf(buffer+i2,"    FILEPATH  = %s\r\n",windowInfos[i].filepath);
-		i2+=lstrlen(buffer+i2);
-		for(i3=0;i3<windowInfos[i].NumberOfChildWindows;i3++){
-			temporary=SetCaptionSequence(windowInfos[i].pChildInfo[i3].caption);
+			windowInfo.LogFont.lfHeight,
+			windowInfo.LogFont.lfWidth,
+			windowInfo.LogFont.lfEscapement,
+			windowInfo.LogFont.lfOrientation,
+			windowInfo.LogFont.lfWeight,
+			windowInfo.LogFont.lfItalic,
+			windowInfo.LogFont.lfUnderline,
+			windowInfo.LogFont.lfStrikeOut,
+			windowInfo.LogFont.lfCharSet,
+			windowInfo.LogFont.lfOutPrecision,
+			windowInfo.LogFont.lfClipPrecision,
+			windowInfo.LogFont.lfQuality,
+			windowInfo.LogFont.lfPitchAndFamily,
+			windowInfo.LogFont.lfFaceName);
+		i2+=lstrlen(buffer+i2);
+		if(windowInfo.IconResName){
+			sprintf(buffer+i2,"    ICONID    = %s\r\n",windowInfo.IconResName);
+			i2+=lstrlen(buffer+i2);
+		}
+		sprintf(buffer+i2,"    CLASS     = \"%s\"\r\n",windowInfo.ClassName);
+		i2+=lstrlen(buffer+i2);
+		sprintf(buffer+i2,"    CALLBACK  = %s\r\n",windowInfo.CallBackName);
+		i2+=lstrlen(buffer+i2);
+		sprintf(buffer+i2,"    TYPE      = %d\r\n",windowInfo.type);
+		i2+=lstrlen(buffer+i2);
+		sprintf(buffer+i2,"    FILEPATH  = %s\r\n",windowInfo.filepath);
+		i2+=lstrlen(buffer+i2);
+		for(i3=0;i3<windowInfo.NumberOfChildWindows;i3++){
+			temporary=SetCaptionSequence(windowInfo.pChildInfo[i3].caption);
 			sprintf(buffer+i2,"    ITEM      = %s,%d,%d,%d,%d,\"%s\",&H%08x,&H%08x,%d",
-				windowInfos[i].pChildInfo[i3].IdName,
-				windowInfos[i].pChildInfo[i3].pos.x,windowInfos[i].pChildInfo[i3].pos.y,
-				windowInfos[i].pChildInfo[i3].size.cx,windowInfos[i].pChildInfo[i3].size.cy,
+				windowInfo.pChildInfo[i3].IdName,
+				windowInfo.pChildInfo[i3].pos.x,windowInfo.pChildInfo[i3].pos.y,
+				windowInfo.pChildInfo[i3].size.cx,windowInfo.pChildInfo[i3].size.cy,
 				temporary,
-				windowInfos[i].pChildInfo[i3].style,
-				windowInfos[i].pChildInfo[i3].ExStyle,
-				windowInfos[i].pChildInfo[i3].Control
+				windowInfo.pChildInfo[i3].style,
+				windowInfo.pChildInfo[i3].ExStyle,
+				windowInfo.pChildInfo[i3].Control
 			);
 			i2+=lstrlen(buffer+i2);
 			HeapDefaultFree(temporary);
-			if(windowInfos[i].pChildInfo[i3].Control==CT_IMAGEBOX){
-				sprintf(buffer+i2,",%d,\"%s\"",windowInfos[i].pChildInfo[i3].ImageCtrlInfo.type,windowInfos[i].pChildInfo[i3].ImageCtrlInfo.path);
+			if(windowInfo.pChildInfo[i3].Control==CT_IMAGEBOX){
+				sprintf(buffer+i2,",%d,\"%s\"",windowInfo.pChildInfo[i3].ImageCtrlInfo.type,windowInfo.pChildInfo[i3].ImageCtrlInfo.path);
 				i2+=lstrlen(buffer+i2);
 			}
@@ -1687,5 +1715,5 @@
 			}
 		}
-		sprintf(buffer+i2,"END\r\n",windowInfos[i].name);
+		sprintf(buffer+i2,"END\r\n",windowInfo.name);
 		i2+=lstrlen(buffer+i2);
 		if(i2-GENERAL_SIZE<GENERAL_SIZE){
@@ -2146,5 +2174,4 @@
 	extern HANDLE hHeap;
 	extern PROJECTINFO ProjectInfo;
-	int i;
 	char temporary[MAX_PATH],temp2[1024],*pTemp;
 
@@ -2158,20 +2185,21 @@
 		return;
 	}
-	for(i=0;i<ProjectInfo.windowInfos.size();i++){
-		if(lstrcmpi(NewWindow.name,ProjectInfo.windowInfos[i].name)==0){
+	BOOST_FOREACH( WINDOW_INFO &windowInfo, ProjectInfo.windowInfos )
+	{
+		if(lstrcmpi(NewWindow.name,windowInfo.name)==0){
 			//"\"%s\" ウィンドウは既にプロジェクト内に存在します。"
-			sprintf(temporary,STRING_DUPLICATIONERROR_WINDOW_IN_PROJECT,ProjectInfo.windowInfos[i].name);
+			sprintf(temporary,STRING_DUPLICATIONERROR_WINDOW_IN_PROJECT,windowInfo.name);
 			MessageBox(hOwner,temporary,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
 			return;
 		}
-		if(lstrcmpi(NewWindow.HandleName,ProjectInfo.windowInfos[i].HandleName)==0){
+		if(lstrcmpi(NewWindow.HandleName,windowInfo.HandleName)==0){
 			//"\"%s\" ハンドルは既にプロジェクト内に存在します。"
-			sprintf(temporary,STRING_DUPLICATIONERROR_HANDLE_IN_PROJECT,ProjectInfo.windowInfos[i].HandleName);
+			sprintf(temporary,STRING_DUPLICATIONERROR_HANDLE_IN_PROJECT,windowInfo.HandleName);
 			MessageBox(hOwner,temporary,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
 			return;
 		}
-		if(lstrcmpi(NewWindow.CallBackName,ProjectInfo.windowInfos[i].CallBackName)==0){
+		if(lstrcmpi(NewWindow.CallBackName,windowInfo.CallBackName)==0){
 			//"\"%s\" プロシージャは既にプロジェクト内に存在します。"
-			sprintf(temporary,STRING_DUPLICATIONERROR_PROC_IN_PROJECT,ProjectInfo.windowInfos[i].CallBackName);
+			sprintf(temporary,STRING_DUPLICATIONERROR_PROC_IN_PROJECT,windowInfo.CallBackName);
 			MessageBox(hOwner,temporary,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
 			return;
@@ -2301,5 +2329,5 @@
 	ProjectInfo.ModifyOfMaterial=1;
 
-	NewRadWindow(ProjectInfo.windowInfos.size()-1);
+	NewRadWindow( ProjectInfo.windowInfos.back() );
 }
 void Project_Window_Delete(int WndInfoNum){
