Index: trunk/ab5.0/abdev/abdev/src/MainFrame.cpp
===================================================================
--- trunk/ab5.0/abdev/abdev/src/MainFrame.cpp	(revision 496)
+++ trunk/ab5.0/abdev/abdev/src/MainFrame.cpp	(revision 497)
@@ -365,2 +365,252 @@
 	ShellExecute(m_hWnd,"explore",ProjectInfo.dir,NULL,NULL,SW_SHOWNORMAL);
 }
+
+void MainFrame::OnCmdSave( UINT uNotifyCode, int nID, CWindow wndCtl )
+{
+	SaveDocument(::GetWindow(hClient,GW_CHILD),NULL);
+}
+
+void MainFrame::OnCmdNewSave( UINT uNotifyCode, int nID, CWindow wndCtl )
+{
+	//"保存先のファイルを指定してください"
+	extern LPSTR DefFileFilter;
+	char temporary[1024];
+	if(!GetFilePathDialog(m_hWnd,temporary,DefFileFilter,STRING_FILESAVETITLE_DEFAULT,FALSE)) return;
+
+	SaveDocument(::GetWindow(hClient,GW_CHILD),temporary);
+}
+
+void MainFrame::OnCmdCodeSave( UINT uNotifyCode, int nID, CWindow wndCtl )
+{
+	//文字コードを指定して保存
+	DialogBox(hResInst,MAKEINTRESOURCE(IDD_CODE_SAVE),m_hWnd,(DLGPROC)nkfDlgCodeSave);
+}
+
+void MainFrame::OnCmdAllSave( UINT uNotifyCode, int nID, CWindow wndCtl )
+{
+	for( int i=0;i<MAX_WNDNUM;i++){
+		if(MdiInfo[i].hwnd) SaveDocument(MdiInfo[i].hwnd,NULL);
+	}
+	if(ProjectInfo.name[0]) SaveProject();
+}
+
+void MainFrame::OnCmdPageSet( UINT uNotifyCode, int nID, CWindow wndCtl )
+{
+	//ページ設定
+	obj_Page.SetupDlg();
+}
+
+void MainFrame::OnCmdPreview( UINT uNotifyCode, int nID, CWindow wndCtl )
+{
+	//プレビュー（Pro版のみ）
+	Preview();
+}
+
+void MainFrame::OnCmdPrintOut( UINT uNotifyCode, int nID, CWindow wndCtl )
+{
+	//印刷
+	Printout();
+}
+
+void MainFrame::OnCmdExit( UINT uNotifyCode, int nID, CWindow wndCtl )
+{
+	SendMessage(WM_CLOSE);
+}
+
+void MainFrame::OnCmdUndo( UINT uNotifyCode, int nID, CWindow wndCtl )
+{
+	HWND hChild=::GetWindow(hClient,GW_CHILD);
+	if(!hChild) return;
+	int WndNum=GetWndNum(hChild);
+	if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType))
+		TextEdit_UndoCommand(WndNum);
+	else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD)
+		Rad_UndoCommand(WndNum);
+	else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT)
+		IconEdit_UndoCommand(WndNum);
+}
+
+void MainFrame::OnCmdRedo( UINT uNotifyCode, int nID, CWindow wndCtl )
+{
+	HWND hChild=::GetWindow(hClient,GW_CHILD);
+	if(!hChild) return;
+	int WndNum=GetWndNum(hChild);
+	if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType))
+		TextEdit_RedoCommand(WndNum);
+	else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD)
+		Rad_RedoCommand(WndNum);
+	else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT)
+		IconEdit_RedoCommand(WndNum);
+}
+
+void MainFrame::OnCmdCut( UINT uNotifyCode, int nID, CWindow wndCtl )
+{
+	HWND hChild=::GetWindow(hClient,GW_CHILD);
+	int WndNum=GetWndNum(hChild);
+	if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
+		HWND hEdit=::GetWindow(hChild,GW_CHILD);
+
+		CHARRANGE CharRange;
+		TextEdit_GetSel(WndNum,&CharRange);
+
+		HGLOBAL hGlobal=(char *)GlobalAlloc(GMEM_MOVEABLE,CharRange.cpMax-CharRange.cpMin+1);
+		char *pTemp=(char *)GlobalLock(hGlobal);
+		memcpy(pTemp,MdiInfo[WndNum].pMdiTextEdit->buffer+CharRange.cpMin,CharRange.cpMax-CharRange.cpMin);
+		pTemp[CharRange.cpMax-CharRange.cpMin]=0;
+		GlobalUnlock(hGlobal);
+
+		//クリップボードに保存
+		OpenClipboard();
+		EmptyClipboard();
+		SetClipboardData(CF_TEXT,hGlobal);
+		CloseClipboard();
+
+		//選択文字列を消去
+		SendMessage(hEdit,WM_KEYDOWN,VK_DELETE,0);
+	}
+	else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD){
+		int indexOfWndInfo = GetWndInfoNum(MdiInfo[WndNum].path);
+
+		//クリップボードに格納するためのデータを用意する
+		ProjectInfo.pWindowInfo[indexOfWndInfo].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].pos.x-=17;
+		ProjectInfo.pWindowInfo[indexOfWndInfo].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].pos.y-=10;
+		HGLOBAL hGlobal=Rad_GetChildInfoClipboardData(WndNum,indexOfWndInfo);
+		ProjectInfo.pWindowInfo[indexOfWndInfo].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].pos.x+=17;
+		ProjectInfo.pWindowInfo[indexOfWndInfo].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[0]].pos.y+=10;
+
+		OpenClipboard();
+		EmptyClipboard();
+		extern DWORD dwRadClipboardID;
+		SetClipboardData(dwRadClipboardID,hGlobal);
+		CloseClipboard();
+
+		SendMessage(MdiInfo[WndNum].MdiRadInfo->hRad,WM_COMMAND,IDM_RAD_ITEM_DELETE,0);
+	}
+	else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
+		//クリップボードに格納するためのデータを用意する
+		HGLOBAL hGlobal=IconEdit_GetChildInfoClipboardData(WndNum);
+		if(hGlobal==0) return;
+
+		OpenClipboard();
+		EmptyClipboard();
+		SetClipboardData(CF_BITMAP,hGlobal);
+		CloseClipboard();
+
+		DeleteObject(MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp);
+		MdiInfo[WndNum].MdiIconEditInfo->SelectLevel=0;
+
+		IconEdit_EraseRect(WndNum,&MdiInfo[WndNum].MdiIconEditInfo->DraggingRect);
+	}
+}
+
+void MainFrame::OnCmdCopy( UINT uNotifyCode, int nID, CWindow wndCtl )
+{
+	HWND hChild=::GetWindow(hClient,GW_CHILD);
+	int WndNum=GetWndNum(hChild);
+	if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
+		HWND hEdit = ::GetWindow(hChild,GW_CHILD);
+
+		CHARRANGE CharRange;
+		TextEdit_GetSel(WndNum,&CharRange);
+
+		HGLOBAL hGlobal=(char *)GlobalAlloc(GMEM_MOVEABLE,CharRange.cpMax-CharRange.cpMin+1);
+		char *pTemp=(char *)GlobalLock(hGlobal);
+		memcpy(pTemp,MdiInfo[WndNum].pMdiTextEdit->buffer+CharRange.cpMin,CharRange.cpMax-CharRange.cpMin);
+		pTemp[CharRange.cpMax-CharRange.cpMin]=0;
+		GlobalUnlock(hGlobal);
+
+		//クリップボードに保存
+		OpenClipboard();
+		EmptyClipboard();
+		SetClipboardData(CF_TEXT,hGlobal);
+		CloseClipboard();
+	}
+	else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD){
+		int indexOfWndInfo = GetWndInfoNum(MdiInfo[WndNum].path);
+
+		//クリップボードに格納するためのデータを用意する
+		HGLOBAL hGlobal=Rad_GetChildInfoClipboardData(WndNum,indexOfWndInfo);
+
+		OpenClipboard();
+		EmptyClipboard();
+		extern DWORD dwRadClipboardID;
+		SetClipboardData(dwRadClipboardID,hGlobal);
+		CloseClipboard();
+	}
+	else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
+		//クリップボードに格納するためのデータを用意する
+		HGLOBAL hGlobal=IconEdit_GetChildInfoClipboardData(WndNum);
+
+		OpenClipboard();
+		EmptyClipboard();
+		SetClipboardData(CF_BITMAP,hGlobal);
+		CloseClipboard();
+	}
+}
+
+void MainFrame::OnCmdPaste( UINT uNotifyCode, int nID, CWindow wndCtl )
+{
+	HWND hChild=::GetWindow(hClient,GW_CHILD);
+	int WndNum=GetWndNum(hChild);
+	if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
+		HWND hEdit=::GetWindow(hChild,GW_CHILD);
+
+		//クリップボードを開く
+		OpenClipboard();
+		HGLOBAL hGlobal=GetClipboardData(CF_TEXT);
+		if(!hGlobal){
+			CloseClipboard();
+			return;
+		}
+
+
+		char *pTemp;
+		if(pobj_nv->bPasteIndent){
+			//インデント整形
+			pTemp=CodeFormatter((char *)GlobalLock(hGlobal));
+			GlobalUnlock(hGlobal);
+		}
+		else pTemp=(char *)GlobalLock(hGlobal);
+
+
+		//テキストエディタの文字列をリプレイス
+		TextEdit_ReplaceUpdateUndoData(WndNum,
+			pTemp,
+			1,
+			1);
+
+		if(pobj_nv->bPasteIndent)
+			HeapDefaultFree(pTemp);
+		else
+			GlobalUnlock(hGlobal);
+
+		//クリップボードを閉じる
+		CloseClipboard();
+
+
+		//キャレット位置までスクロールする
+		TextEdit_ScrollCaret(WndNum,0);
+		ResetCaretPos(WndNum);
+	}
+	else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD){
+		OpenClipboard();
+		extern DWORD dwRadClipboardID;
+		HGLOBAL hGlobal=GetClipboardData(dwRadClipboardID);
+		if(!hGlobal){
+			CloseClipboard();
+			return;
+		}
+		Rad_PasteChildInfoClipboardData(WndNum,hGlobal);
+		CloseClipboard();
+	}
+	else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
+		OpenClipboard();
+		HGLOBAL hGlobal=GetClipboardData(CF_BITMAP);
+		if(!hGlobal){
+			CloseClipboard();
+			return;
+		}
+		IconEdit_PasteChildInfoClipboardData(WndNum,(HBITMAP)hGlobal);
+		CloseClipboard();
+	}
+}
