Index: trunk/ab5.0/abdev/abdev/src/MainFrame.cpp
===================================================================
--- trunk/ab5.0/abdev/abdev/src/MainFrame.cpp	(revision 620)
+++ trunk/ab5.0/abdev/abdev/src/MainFrame.cpp	(revision 621)
@@ -507,10 +507,10 @@
 	}
 
-	projectInfo.Open(temporary);
+	projectInfo.Load(temporary);
 }
 
 void MainFrame::OnCmdProjectSave( UINT uNotifyCode, int nID, CWindow wndCtl )
 {
-	SaveProject();
+	projectInfo.Save();
 }
 
@@ -551,5 +551,8 @@
 		if(MdiInfo[i].hwnd) SaveDocument(MdiInfo[i].hwnd,NULL);
 	}
-	if( projectInfo.IsOpened() ) SaveProject();
+	if( projectInfo.IsOpened() )
+	{
+		projectInfo.Save();
+	}
 }
 
Index: trunk/ab5.0/abdev/abdev/src/ProjectManager/ProjectManager.cpp
===================================================================
--- trunk/ab5.0/abdev/abdev/src/ProjectManager/ProjectManager.cpp	(revision 620)
+++ trunk/ab5.0/abdev/abdev/src/ProjectManager/ProjectManager.cpp	(revision 621)
@@ -5,5 +5,5 @@
 void OpenWorkfile( const std::string &path );
 
-void Project::Open( char *path )
+void Project::Load( char *path )
 {
 	extern HANDLE hHeap;
@@ -268,4 +268,270 @@
 	this->modify=0;
 	this->ModifyOfMaterial=0;
+	this->ModifuOfResource=0;
+}
+
+void SetStatusText(char *MenuText);
+void Project::Save()
+{
+	extern MDIINFO MdiInfo[MAX_WNDNUM];
+	int i,i2,i3,WndNum;
+	char temporary[MAX_PATH],buffer[32767];
+	HWND hChild;
+
+	SetStatusText( "プロジェクトを保存中..." );
+
+	//プロジェクトファイルのバージョンを設定
+	this->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<this->pobj_DBFileInfo->iNum;i++){
+					this->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<this->res.NumberOfIconRes;i++){
+					lstrcpy(temporary,this->res.pIconResInfo[i].path);
+					lstrcpy( temporary, this->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",this->dwVersion);
+	i2+=lstrlen(buffer+i2);
+	sprintf(buffer+i2,"#MODULETYPE=%d\r\n\r\n",(int)this->GetModuleType());
+	i2+=lstrlen(buffer+i2);
+	sprintf(buffer+i2,"#NAME=%s\r\n\r\n",this->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",this->GetName().c_str());
+		i2+=lstrlen(buffer+i2);
+	}
+	else{
+		sprintf(buffer+i2,"#PLATFORM=64\r\n\r\n",this->GetName().c_str());
+		i2+=lstrlen(buffer+i2);
+	}
+	sprintf(buffer+i2,"#USEWINDOW=%d\r\n\r\n",this->windowInfos.size());
+	i2+=lstrlen(buffer+i2);
+	sprintf(buffer+i2,"#OPTION=&H%08x\r\n\r\n",this->dwOption);
+	i2+=lstrlen(buffer+i2);
+	sprintf(buffer+i2,"#OUTPUT_RELEASE=%s\r\n\r\n",this->lpszOutput_Release);
+	i2+=lstrlen(buffer+i2);
+	sprintf(buffer+i2,"#OUTPUT_DEBUG=%s\r\n\r\n",this->lpszOutput_Debug);
+	i2+=lstrlen(buffer+i2);
+	sprintf(buffer+i2,"#MANIFEST=%s\r\n\r\n",this->szManifestPath);
+	i2+=lstrlen(buffer+i2);
+	sprintf(buffer+i2,"#DEBUG_CMD_LINE=%s\r\n\r\n",this->szCmdLine);
+	i2+=lstrlen(buffer+i2);
+	sprintf(buffer+i2,"#DEBUG_EXE_PATH=%s\r\n\r\n",this->szExePath);
+	i2+=lstrlen(buffer+i2);
+	if(this->ResourceFileName[0]){
+		sprintf(buffer+i2,"#RESOURCE=%s\r\n\r\n",this->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<this->pobj_DBFileInfo->iNum;i++){
+		sprintf(buffer+i2,"%s\r\n",this->pobj_DBFileInfo->ppobj_FileInfo[i]->m_path);
+		i2+=lstrlen(buffer+i2);
+	}
+
+	//保存
+	sprintf(temporary,"%s%s.pj",this->GetWorkDir().GetPath().c_str(),this->GetName().c_str());
+	WriteBuffer(temporary,buffer,i2);
+
+
+	//////////////////////////////////
+	// リソースファイル（*.rc、resource.ab）を作成
+	if(this->ResourceFileName[0]){
+		i2=0;
+		i3=101;
+		for(i=0;i<this->res.NumberOfCursorRes;i++,i3++){
+			sprintf(buffer+i2,"Const %s=%d\r\n",
+				this->res.pCursorResInfo[i].IdName,
+				i3);
+			i2+=lstrlen(buffer+i2);
+		}
+		for(i=0;i<this->res.NumberOfBitmapRes;i++,i3++){
+			sprintf(buffer+i2,"Const %s=%d\r\n",
+				this->res.pBitmapResInfo[i].IdName,
+				i3);
+			i2+=lstrlen(buffer+i2);
+		}
+		for(i=0;i<this->res.NumberOfIconRes;i++,i3++){
+			sprintf(buffer+i2,"Const %s=%d\r\n",
+				this->res.pIconResInfo[i].IdName,
+				i3);
+			i2+=lstrlen(buffer+i2);
+		}
+
+		//保存（resource.ab）
+		lstrcpy(temporary,"resource.ab");
+		lstrcpy( temporary, this->GetWorkDir().GetFullPath( temporary ).c_str() );
+		WriteBuffer(temporary,buffer,i2);
+
+		i2=0;
+		for(i=0;i<this->res.NumberOfCursorRes;i++){
+			sprintf(buffer+i2,"%s CURSOR \"%s\"\r\n",
+				this->res.pCursorResInfo[i].IdName,
+				this->res.pCursorResInfo[i].path);
+			i2+=lstrlen(buffer+i2);
+		}
+		for(i=0;i<this->res.NumberOfBitmapRes;i++){
+			sprintf(buffer+i2,"%s BITMAP \"%s\"\r\n",
+				this->res.pBitmapResInfo[i].IdName,
+				this->res.pBitmapResInfo[i].path);
+			i2+=lstrlen(buffer+i2);
+		}
+		for(i=0;i<this->res.NumberOfIconRes;i++){
+			sprintf(buffer+i2,"%s ICON \"%s\"\r\n",
+				this->res.pIconResInfo[i].IdName,
+				this->res.pIconResInfo[i].path);
+			i2+=lstrlen(buffer+i2);
+		}
+
+		//マニフェスト
+		if(this->dwOption&PJ_OP_RC_MANIFEST){
+			sprintf(buffer+i2,"CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST \"%s\"\r\n",
+				this->szManifestPath);
+			i2+=lstrlen(buffer+i2);
+		}
+
+		//保存
+		lstrcpy(temporary,this->ResourceFileName);
+		lstrcpy( temporary, this->GetWorkDir().GetFullPath( temporary ).c_str() );
+		WriteBuffer(temporary,buffer,i2);
+	}
+
+
+	///////////////////////////////////////
+	//インデックスファイル（*.idx）を作成
+	buffer[0]=0;
+	lstrcpy(buffer,"' インデックス プログラム\r\n");
+	i2=lstrlen(buffer);
+	if(this->dwOption&PJ_OP_SOURCE_MASK){
+		if(this->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(this->dwOption&PJ_OP_MMSYSTEM){
+			lstrcpy(buffer+i2,"#include <api_mmsys.sbp>\r\n");
+			i2+=lstrlen(buffer+i2);
+		}
+		if(this->dwOption&PJ_OP_COMMCTRL){
+			lstrcpy(buffer+i2,"#include <api_commctrl.sbp>\r\n");
+			i2+=lstrlen(buffer+i2);
+		}
+		if(this->dwOption&PJ_OP_RICHEDIT){
+			lstrcpy(buffer+i2,"#include <api_richedit.sbp>\r\n");
+			i2+=lstrlen(buffer+i2);
+		}
+		if(this->dwOption&PJ_OP_WINSOCK){
+			lstrcpy(buffer+i2,"#include <api_winsock2.sbp>\r\n");
+			i2+=lstrlen(buffer+i2);
+		}
+	}
+	if( !this->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(this->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<this->pobj_DBFileInfo->iNum;i++){
+			//メインファイルは含まない
+			sprintf(buffer+i2,"#include \"%s\"\r\n",this->pobj_DBFileInfo->ppobj_FileInfo[i]->m_path);
+			i2+=lstrlen(buffer+i2);
+			lstrcpy(buffer+i2,"_ClearNamespaceImported\r\n");
+			i2+=lstrlen(buffer+i2);
+		}
+	}
+	if( !this->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(this->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",this->GetName().c_str());
+		i2+=lstrlen(buffer+i2);
+	}
+
+	//保存
+	sprintf(temporary,"%s%s.idx",this->GetWorkDir().GetPath().c_str(),this->GetName().c_str());
+	WriteBuffer(temporary,buffer,i2);
+
+
+	if( !this->windowInfos.empty() )
+	{
+		/////////////////////////////////////////////////////
+		//ウィンドウ関連ファイル（*.wnd）を作成、保存
+		if(this->ModifyOfMaterial){
+			sprintf(temporary,"%s%s.wnd",this->GetWorkDir().GetPath().c_str(),this->GetName().c_str());
+			SaveWindowFile( temporary, this->windowInfos );
+		}
+
+		//.wbpファイルを生成
+		SaveWindowProgram();
+	}
+
+
+	MakeWorkFile();
+
+	SetStatusText("");
+
+	this->modify=0;
 	this->ModifuOfResource=0;
 }
