Index: trunk/ab5.0/abdev/abdev/FileTree.cpp
===================================================================
--- trunk/ab5.0/abdev/abdev/FileTree.cpp	(revision 620)
+++ trunk/ab5.0/abdev/abdev/FileTree.cpp	(revision 651)
@@ -3,5 +3,5 @@
 #include "common.h"
 
-CFileTree *pobj_FileTree;
+FileListTreeViewCtrl *pobj_FileTree;
 
 WNDPROC OldFileTreeViewProc;
@@ -17,63 +17,64 @@
 	switch(message){
 		case WM_INITDIALOG:
-			SetPosCenter(hwnd);
-
-			hTreeItem=TreeView_GetSelection(pobj_FileTree->hTree);
-
-			char *path;
-			path=projectInfo.pobj_DBFileInfo->GetPath(hTreeItem);
-
-			//絶対パス、相対パスを表示
-			lstrcpy(temporary,path);
-			lstrcpy( temporary, projectInfo.GetWorkDir().GetFullPath( temporary ).c_str() );
-			SetDlgItemText(hwnd,IDC_USING_FILE,temporary);
-			SetDlgItemText(hwnd,IDC_DEFINED_FILE,path);
-
-			//最終更新日時を表示
-			hFile=CreateFile(temporary,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
-			if(hFile==INVALID_HANDLE_VALUE){
-				//"エラー"
-				lstrcpy(temporary,STRING_ERROR);
-			}
-			else{
-				GetFileTime(hFile,NULL,NULL,&LastWriteTime);
-				FileTimeToLocalFileTime(&LastWriteTime,&LocalTime);
-				FileTimeToSystemTime(&LocalTime,&SystemTime);
-				if(SystemTime.wHour>=12){
-					//"午後 "
-					lstrcpy(temporary,STRING_AFTERNOON);
-					lstrcat(temporary," ");
-					SystemTime.wHour-=12;
+			{
+				SetPosCenter(hwnd);
+
+				hTreeItem = pobj_FileTree->GetSelectedItem();
+
+				std::string tempPath = projectInfo.pobj_DBFileInfo->GetPath(hTreeItem);
+
+				//絶対パス、相対パスを表示
+				lstrcpy( temporary, tempPath.c_str() );
+				lstrcpy( temporary, projectInfo.GetWorkDir().GetFullPath( temporary ).c_str() );
+				SetDlgItemText(hwnd,IDC_USING_FILE,temporary);
+				SetDlgItemText(hwnd,IDC_DEFINED_FILE,tempPath.c_str());
+
+				//最終更新日時を表示
+				hFile=CreateFile(temporary,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
+				if(hFile==INVALID_HANDLE_VALUE){
+					//"エラー"
+					lstrcpy(temporary,STRING_ERROR);
 				}
 				else{
-					//"午前 "
-					lstrcpy(temporary,STRING_MORNING);
-					lstrcat(temporary," ");
+					GetFileTime(hFile,NULL,NULL,&LastWriteTime);
+					FileTimeToLocalFileTime(&LastWriteTime,&LocalTime);
+					FileTimeToSystemTime(&LocalTime,&SystemTime);
+					if(SystemTime.wHour>=12){
+						//"午後 "
+						lstrcpy(temporary,STRING_AFTERNOON);
+						lstrcat(temporary," ");
+						SystemTime.wHour-=12;
+					}
+					else{
+						//"午前 "
+						lstrcpy(temporary,STRING_MORNING);
+						lstrcat(temporary," ");
+					}
+					sprintf(temporary+5,"%02d:%02d:%02d %04d/%02d/%02d",
+						SystemTime.wHour,SystemTime.wMinute,SystemTime.wSecond,
+						SystemTime.wYear,SystemTime.wMonth,SystemTime.wDay);
+					CloseHandle(hFile);
 				}
-				sprintf(temporary+5,"%02d:%02d:%02d %04d/%02d/%02d",
-					SystemTime.wHour,SystemTime.wMinute,SystemTime.wSecond,
-					SystemTime.wYear,SystemTime.wMonth,SystemTime.wDay);
-				CloseHandle(hFile);
-			}
-			SetDlgItemText(hwnd,IDC_UPDATE_TIME,temporary);
-
-
-			//////////////
-			// 形式を表示
-			//////////////
-			i=GetFileExtension(path);
-
-			//"Basic プログラム"
-			if(i==FT_BASICPROGRAM) lstrcpy(temporary,STRING_FILETYPE_BASICPROGRAM);
-			//"サブ プログラム"
-			else if(i==FT_SUBPROGRAM) lstrcpy(temporary,STRING_FILETYPE_SUBPROGRAM);
-			//"テキスト ドキュメント"
-			else if(i==FT_TEXT) lstrcpy(temporary,STRING_FILETYPE_TEXT);
-			//"判別できません"
-			else lstrcpy(temporary,STRING_FILETYPE_UNKNOWN);
-
-			SetDlgItemText(hwnd,IDC_FILETYPE,temporary);
-
-			break;
+				SetDlgItemText(hwnd,IDC_UPDATE_TIME,temporary);
+
+
+				//////////////
+				// 形式を表示
+				//////////////
+				i=GetFileExtension(tempPath.c_str());
+
+				//"Basic プログラム"
+				if(i==FT_BASICPROGRAM) lstrcpy(temporary,STRING_FILETYPE_BASICPROGRAM);
+				//"サブ プログラム"
+				else if(i==FT_SUBPROGRAM) lstrcpy(temporary,STRING_FILETYPE_SUBPROGRAM);
+				//"テキスト ドキュメント"
+				else if(i==FT_TEXT) lstrcpy(temporary,STRING_FILETYPE_TEXT);
+				//"判別できません"
+				else lstrcpy(temporary,STRING_FILETYPE_UNKNOWN);
+
+				SetDlgItemText(hwnd,IDC_FILETYPE,temporary);
+
+				break;
+			}
 		case WM_COMMAND:
 			switch(LOWORD(wParam)){
@@ -93,5 +94,4 @@
 	HTREEITEM hTreeItem;
 	char temporary[MAX_PATH];
-	char *path;
 	switch(message){
 		case WM_COMMAND:
@@ -104,13 +104,14 @@
 					break;
 				case IDM_FILETREE_OPEN:
-					hTreeItem=TreeView_GetSelection(hwnd);
-
-					path=projectInfo.pobj_DBFileInfo->GetPath(hTreeItem);
-					if(!path) break;
-
-					lstrcpy(temporary,path);
-					lstrcpy( temporary, projectInfo.GetWorkDir().GetFullPath( temporary ).c_str() );
-					OpenFileWithExtension(temporary);
-					break;
+					{
+						hTreeItem=TreeView_GetSelection(hwnd);
+
+						std::string tempPath = projectInfo.pobj_DBFileInfo->GetPath(hTreeItem);
+
+						lstrcpy( temporary, tempPath.c_str() );
+						lstrcpy( temporary, projectInfo.GetWorkDir().GetFullPath( temporary ).c_str() );
+						OpenFileWithExtension(temporary);
+						break;
+					}
 				case IDM_FILETREE_DELETE:
 					hTreeItem=TreeView_GetSelection(hwnd);
@@ -141,11 +142,14 @@
 }
 
-CFileTree::CFileTree(HWND hParent){
-	hTree=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
-		WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
-		0,0,0,0,
-		hParent,0,hInst,0);
-	OldFileTreeViewProc=(WNDPROC)GetWindowLongPtr(hTree,GWLP_WNDPROC);
-	SetWindowLongPtr(hTree,GWLP_WNDPROC,(long)FileTreeViewProc);
+FileListTreeViewCtrl::FileListTreeViewCtrl( HWND hParent )
+	: CTreeViewCtrl()
+{
+	this->Create( hParent, NULL, NULL, 
+		WS_CHILD | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS,
+		WS_EX_CLIENTEDGE
+	);
+
+	OldFileTreeViewProc=(WNDPROC)this->GetWindowLongPtr(GWLP_WNDPROC);
+	this->SetWindowLongPtr(GWLP_WNDPROC,(long)FileTreeViewProc);
 
 	//イメージリスト読み込み、設定
@@ -154,30 +158,36 @@
 	ImageList_AddIcon(hImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_FOLDER_OPEN)));
 	ImageList_AddIcon(hImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_TEXTDOCUMENT)));
-	TreeView_SetImageList(hTree,hImageList,TVSIL_NORMAL);
-}
-CFileTree::~CFileTree(){
-	DestroyWindow(hTree);
+	this->SetImageList(hImageList,TVSIL_NORMAL);
+}
+FileListTreeViewCtrl::~FileListTreeViewCtrl()
+{
+	this->DestroyWindow();
 	ImageList_Destroy(hImageList);
 }
 
-void CFileTree::ContextMenu(POINT *pPos){
+void FileListTreeViewCtrl::ContextMenu(POINT *pPos)
+{
 	//右クリックによるメニューを表示
 	TV_HITTESTINFO tvHitTestInfo;
 	tvHitTestInfo.pt=*pPos;
-	ScreenToClient(hTree,&tvHitTestInfo.pt);
-
-	HTREEITEM hTreeItem;
-	hTreeItem=TreeView_HitTest(hTree,&tvHitTestInfo);
+	this->ScreenToClient(&tvHitTestInfo.pt);
+
+	HTREEITEM hTreeItem = this->HitTest(&tvHitTestInfo);
 	if(hTreeItem){
-		TreeView_SelectItem(hTree,hTreeItem);
+		this->SelectItem(hTreeItem);
 
 		extern HMENU hFileTreeMenuBase;
-		if(TreeView_GetRoot(hTree)==hTreeItem)
-			TrackPopupMenu(GetSubMenu(hFileTreeMenuBase,0),TPM_LEFTALIGN,pPos->x,pPos->y,0,hTree,0);
-		else TrackPopupMenu(GetSubMenu(hFileTreeMenuBase,1),TPM_LEFTALIGN,pPos->x,pPos->y,0,hTree,0);
+		if(this->GetRootItem()==hTreeItem)
+		{
+			TrackPopupMenu(GetSubMenu(hFileTreeMenuBase,0),TPM_LEFTALIGN,pPos->x,pPos->y,0,this->m_hWnd,0);
+		}
+		else
+		{
+			TrackPopupMenu(GetSubMenu(hFileTreeMenuBase,1),TPM_LEFTALIGN,pPos->x,pPos->y,0,this->m_hWnd,0);
+		}
 	}
 }
 
-HTREEITEM CFileTree::insert(char *str){
+HTREEITEM FileListTreeViewCtrl::insert(char *str){
 	//////////////////////
 	//ツリービューに追加
@@ -188,11 +198,7 @@
 	tv.item.iImage=2;
 	tv.item.iSelectedImage=2;
-	tv.hParent=TreeView_GetRoot(hTree);
+	tv.hParent=this->GetRootItem();
 	tv.item.pszText=str;
 
-	return TreeView_InsertItem(hTree,&tv);
-}
-
-void CFileTree::resize(int x,int y,int cx,int cy){
-	MoveWindow(hTree,x,y,cx,cy,1);
-}
+	return this->InsertItem(&tv);
+}
