Index: trunk/ab5.0/abdev/abdev/ProjectControl.cpp
===================================================================
--- trunk/ab5.0/abdev/abdev/ProjectControl.cpp	(revision 620)
+++ trunk/ab5.0/abdev/abdev/ProjectControl.cpp	(revision 621)
@@ -1109,6 +1109,6 @@
 
 	sprintf(temporary,"%s%s.pj",dir,NewProjectInfo.name);
-	projectInfo.Open(temporary);
-	SaveProject();
+	projectInfo.Load(temporary);
+	projectInfo.Save();
 }
 void SetTreeViewForProjectInfo(){
@@ -1568,7 +1568,13 @@
 
 			if(i==IDCANCEL) return 0;
-			if(i==IDYES) SaveProject();
+			if(i==IDYES)
+			{
+				projectInfo.Save();
+			}
 		}
-		else SaveProject();
+		else
+		{
+			projectInfo.Save();
+		}
 		return 1;
 	}
@@ -1602,7 +1608,13 @@
 
 				if(i==IDCANCEL) return 0;
-				if(i==IDYES) SaveProject();
-			}
-			else SaveProject();
+				if(i==IDYES)
+				{
+					projectInfo.Save();
+				}
+			}
+			else
+			{
+				projectInfo.Save();
+			}
 			return 1;
 		}
@@ -1731,268 +1743,4 @@
 	WriteBuffer(temporary,buffer,i2);
 }
-void SaveProject(void){
-	extern MDIINFO MdiInfo[MAX_WNDNUM];
-	int i,i2,i3,WndNum;
-	char temporary[MAX_PATH],buffer[32767];
-	HWND hChild;
-
-	//"プロジェクトを保存中..."
-	SetStatusText(STRING_PROJECT_SAVING);
-
-	//プロジェクトファイルのバージョンを設定
-	projectInfo.dwVersion=PROJECT_VERSION;
-
-	hChild=GetWindow(hClient,GW_CHILD);
-	while(hChild){
-		WndNum=GetWndNum(hChild);
-		if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
-			if( MdiInfo[WndNum].pMdiTextEdit->IsModified() ){
-				for(i=0;i<projectInfo.pobj_DBFileInfo->iNum;i++){
-					projectInfo.pobj_DBFileInfo->ppobj_FileInfo[i]->GetFullPath(temporary);
-					if(lstrcmpi(MdiInfo[WndNum].path,temporary)==0){
-						SaveDocument(hChild,NULL);
-						break;
-					}
-				}
-			}
-		}
-		if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
-			if(MdiInfo[WndNum].MdiIconEditInfo->bModify){
-				for(i=0;i<projectInfo.res.NumberOfIconRes;i++){
-					lstrcpy(temporary,projectInfo.res.pIconResInfo[i].path);
-					lstrcpy( temporary, projectInfo.GetWorkDir().GetFullPath( temporary ).c_str() );
-					if(lstrcmpi(MdiInfo[WndNum].path,temporary)==0){
-						SaveDocument(hChild,NULL);
-						break;
-					}
-				}
-			}
-		}
-		hChild=GetNextWindow(hChild,GW_HWNDNEXT);
-	}
-
-
-	//////////////////////////////////////
-	//プロジェクトファイル（*.pj）を作成
-	lstrcpy(buffer,"\' ActiveBasic Project file.\r\n\r\n");
-	i2=lstrlen(buffer);
-	sprintf(buffer+i2,"#VERSION=%d\r\n\r\n",projectInfo.dwVersion);
-	i2+=lstrlen(buffer+i2);
-	sprintf(buffer+i2,"#MODULETYPE=%d\r\n\r\n",(int)projectInfo.GetModuleType());
-	i2+=lstrlen(buffer+i2);
-	sprintf(buffer+i2,"#NAME=%s\r\n\r\n",projectInfo.GetName().c_str());
-	i2+=lstrlen(buffer+i2);
-	extern HWND hSelectCompilerCombo;
-	if(SendMessage(hSelectCompilerCombo,CB_GETCURSEL,0,0)==0){
-		sprintf(buffer+i2,"#PLATFORM=32\r\n\r\n",projectInfo.GetName().c_str());
-		i2+=lstrlen(buffer+i2);
-	}
-	else{
-		sprintf(buffer+i2,"#PLATFORM=64\r\n\r\n",projectInfo.GetName().c_str());
-		i2+=lstrlen(buffer+i2);
-	}
-	sprintf(buffer+i2,"#USEWINDOW=%d\r\n\r\n",projectInfo.windowInfos.size());
-	i2+=lstrlen(buffer+i2);
-	sprintf(buffer+i2,"#OPTION=&H%08x\r\n\r\n",projectInfo.dwOption);
-	i2+=lstrlen(buffer+i2);
-	sprintf(buffer+i2,"#OUTPUT_RELEASE=%s\r\n\r\n",projectInfo.lpszOutput_Release);
-	i2+=lstrlen(buffer+i2);
-	sprintf(buffer+i2,"#OUTPUT_DEBUG=%s\r\n\r\n",projectInfo.lpszOutput_Debug);
-	i2+=lstrlen(buffer+i2);
-	sprintf(buffer+i2,"#MANIFEST=%s\r\n\r\n",projectInfo.szManifestPath);
-	i2+=lstrlen(buffer+i2);
-	sprintf(buffer+i2,"#DEBUG_CMD_LINE=%s\r\n\r\n",projectInfo.szCmdLine);
-	i2+=lstrlen(buffer+i2);
-	sprintf(buffer+i2,"#DEBUG_EXE_PATH=%s\r\n\r\n",projectInfo.szExePath);
-	i2+=lstrlen(buffer+i2);
-	if(projectInfo.ResourceFileName[0]){
-		sprintf(buffer+i2,"#RESOURCE=%s\r\n\r\n",projectInfo.ResourceFileName);
-		i2+=lstrlen(buffer+i2);
-	}
-	else{
-		lstrcpy(buffer+i2,"#RESOURCE=0\r\n\r\n");
-		i2+=lstrlen(buffer+i2);
-	}
-	sprintf(buffer+i2,"#SOURCE\r\n");
-	i2+=lstrlen(buffer+i2);
-	for(i=0;i<projectInfo.pobj_DBFileInfo->iNum;i++){
-		sprintf(buffer+i2,"%s\r\n",projectInfo.pobj_DBFileInfo->ppobj_FileInfo[i]->m_path);
-		i2+=lstrlen(buffer+i2);
-	}
-
-	//保存
-	sprintf(temporary,"%s%s.pj",projectInfo.GetWorkDir().GetPath().c_str(),projectInfo.GetName().c_str());
-	WriteBuffer(temporary,buffer,i2);
-
-
-	//////////////////////////////////
-	// リソースファイル（*.rc、resource.ab）を作成
-	if(projectInfo.ResourceFileName[0]){
-		i2=0;
-		i3=101;
-		for(i=0;i<projectInfo.res.NumberOfCursorRes;i++,i3++){
-			sprintf(buffer+i2,"Const %s=%d\r\n",
-				projectInfo.res.pCursorResInfo[i].IdName,
-				i3);
-			i2+=lstrlen(buffer+i2);
-		}
-		for(i=0;i<projectInfo.res.NumberOfBitmapRes;i++,i3++){
-			sprintf(buffer+i2,"Const %s=%d\r\n",
-				projectInfo.res.pBitmapResInfo[i].IdName,
-				i3);
-			i2+=lstrlen(buffer+i2);
-		}
-		for(i=0;i<projectInfo.res.NumberOfIconRes;i++,i3++){
-			sprintf(buffer+i2,"Const %s=%d\r\n",
-				projectInfo.res.pIconResInfo[i].IdName,
-				i3);
-			i2+=lstrlen(buffer+i2);
-		}
-
-		//保存（resource.ab）
-		lstrcpy(temporary,"resource.ab");
-		lstrcpy( temporary, projectInfo.GetWorkDir().GetFullPath( temporary ).c_str() );
-		WriteBuffer(temporary,buffer,i2);
-
-		i2=0;
-		for(i=0;i<projectInfo.res.NumberOfCursorRes;i++){
-			sprintf(buffer+i2,"%s CURSOR \"%s\"\r\n",
-				projectInfo.res.pCursorResInfo[i].IdName,
-				projectInfo.res.pCursorResInfo[i].path);
-			i2+=lstrlen(buffer+i2);
-		}
-		for(i=0;i<projectInfo.res.NumberOfBitmapRes;i++){
-			sprintf(buffer+i2,"%s BITMAP \"%s\"\r\n",
-				projectInfo.res.pBitmapResInfo[i].IdName,
-				projectInfo.res.pBitmapResInfo[i].path);
-			i2+=lstrlen(buffer+i2);
-		}
-		for(i=0;i<projectInfo.res.NumberOfIconRes;i++){
-			sprintf(buffer+i2,"%s ICON \"%s\"\r\n",
-				projectInfo.res.pIconResInfo[i].IdName,
-				projectInfo.res.pIconResInfo[i].path);
-			i2+=lstrlen(buffer+i2);
-		}
-
-		//マニフェスト
-		if(projectInfo.dwOption&PJ_OP_RC_MANIFEST){
-			sprintf(buffer+i2,"CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST \"%s\"\r\n",
-				projectInfo.szManifestPath);
-			i2+=lstrlen(buffer+i2);
-		}
-
-		//保存
-		lstrcpy(temporary,projectInfo.ResourceFileName);
-		lstrcpy( temporary, projectInfo.GetWorkDir().GetFullPath( temporary ).c_str() );
-		WriteBuffer(temporary,buffer,i2);
-	}
-
-
-	///////////////////////////////////////
-	//インデックスファイル（*.idx）を作成
-	buffer[0]=0;
-	lstrcpy(buffer,"' インデックス プログラム\r\n");
-	i2=lstrlen(buffer);
-	if(projectInfo.dwOption&PJ_OP_SOURCE_MASK){
-		if(projectInfo.dwOption&PJ_OP_STRICT){
-			/* #strictディレクティブは今は使われていない
-			lstrcpy(buffer+i2,"\r\n");
-			i2+=lstrlen(buffer+i2);
-			lstrcpy(buffer+i2,"#strict");
-			i2+=lstrlen(buffer+i2);
-			lstrcpy(buffer+i2,"\r\n");
-			i2+=lstrlen(buffer+i2);
-			*/
-		}
-		lstrcpy(buffer+i2,"\r\n");
-		i2+=lstrlen(buffer+i2);
-		lstrcpy(buffer+i2,"'Win32APIの定義ファイル\r\n");
-		i2+=lstrlen(buffer+i2);
-		if(projectInfo.dwOption&PJ_OP_MMSYSTEM){
-			lstrcpy(buffer+i2,"#include <api_mmsys.sbp>\r\n");
-			i2+=lstrlen(buffer+i2);
-		}
-		if(projectInfo.dwOption&PJ_OP_COMMCTRL){
-			lstrcpy(buffer+i2,"#include <api_commctrl.sbp>\r\n");
-			i2+=lstrlen(buffer+i2);
-		}
-		if(projectInfo.dwOption&PJ_OP_RICHEDIT){
-			lstrcpy(buffer+i2,"#include <api_richedit.sbp>\r\n");
-			i2+=lstrlen(buffer+i2);
-		}
-		if(projectInfo.dwOption&PJ_OP_WINSOCK){
-			lstrcpy(buffer+i2,"#include <api_winsock2.sbp>\r\n");
-			i2+=lstrlen(buffer+i2);
-		}
-	}
-	if( !projectInfo.windowInfos.empty() )
-	{
-		lstrcpy(buffer+i2,"\r\n");
-		i2+=lstrlen(buffer+i2);
-		lstrcpy(buffer+i2,"'RADツールが生成するウィンドウ制御プログラム\r\n");
-		i2+=lstrlen(buffer+i2);
-		sprintf(buffer+i2,"#include \"Callback.wbp\"\r\n");
-		i2+=lstrlen(buffer+i2);
-	}
-	if(projectInfo.pobj_DBFileInfo->iNum>1){
-		lstrcpy(buffer+i2,"\r\n");
-		i2+=lstrlen(buffer+i2);
-		lstrcpy(buffer+i2,"'プロジェクト内のプログラム ファイル\r\n");
-		i2+=lstrlen(buffer+i2);
-		for(i=1;i<projectInfo.pobj_DBFileInfo->iNum;i++){
-			//メインファイルは含まない
-			sprintf(buffer+i2,"#include \"%s\"\r\n",projectInfo.pobj_DBFileInfo->ppobj_FileInfo[i]->m_path);
-			i2+=lstrlen(buffer+i2);
-			lstrcpy(buffer+i2,"_ClearNamespaceImported\r\n");
-			i2+=lstrlen(buffer+i2);
-		}
-	}
-	if( !projectInfo.windowInfos.empty() )
-	{
-		lstrcpy(buffer+i2,"\r\n");
-		i2+=lstrlen(buffer+i2);
-		lstrcpy(buffer+i2,"'RADツールが生成するウィンドウ生成プログラム\r\n");
-		i2+=lstrlen(buffer+i2);
-		sprintf(buffer+i2,"#include \"MakeWindow.wbp\"\r\n");
-		i2+=lstrlen(buffer+i2);
-	}
-	if(projectInfo.ResourceFileName[0]){
-		//リソースファイルが含まれる場合
-		lstrcpy(buffer+i2,"\r\n");
-		i2+=lstrlen(buffer+i2);
-		lstrcpy(buffer+i2,"'リソースファイル\r\n");
-		i2+=lstrlen(buffer+i2);
-		lstrcpy(buffer+i2,"#include \"resource.ab\"\r\n");
-		i2+=lstrlen(buffer+i2);
-		sprintf(buffer+i2,"#resource \"%s.rc\"\r\n",projectInfo.GetName().c_str());
-		i2+=lstrlen(buffer+i2);
-	}
-
-	//保存
-	sprintf(temporary,"%s%s.idx",projectInfo.GetWorkDir().GetPath().c_str(),projectInfo.GetName().c_str());
-	WriteBuffer(temporary,buffer,i2);
-
-
-	if( !projectInfo.windowInfos.empty() )
-	{
-		/////////////////////////////////////////////////////
-		//ウィンドウ関連ファイル（*.wnd）を作成、保存
-		if(projectInfo.ModifyOfMaterial){
-			sprintf(temporary,"%s%s.wnd",projectInfo.GetWorkDir().GetPath().c_str(),projectInfo.GetName().c_str());
-			SaveWindowFile( temporary, projectInfo.windowInfos );
-		}
-
-		//.wbpファイルを生成
-		SaveWindowProgram();
-	}
-
-
-	MakeWorkFile();
-
-	SetStatusText("");
-
-	projectInfo.modify=0;
-	projectInfo.ModifuOfResource=0;
-}
 
 BOOL SetProjectToRun(void){
