Changeset 651 in dev for trunk/ab5.0/abdev/abdev/FileTree.cpp
- Timestamp:
- Jun 17, 2008, 9:30:54 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/abdev/FileTree.cpp
r620 r651 3 3 #include "common.h" 4 4 5 CFileTree*pobj_FileTree;5 FileListTreeViewCtrl *pobj_FileTree; 6 6 7 7 WNDPROC OldFileTreeViewProc; … … 17 17 switch(message){ 18 18 case WM_INITDIALOG: 19 SetPosCenter(hwnd); 20 21 hTreeItem=TreeView_GetSelection(pobj_FileTree->hTree); 22 23 char *path; 24 path=projectInfo.pobj_DBFileInfo->GetPath(hTreeItem); 25 26 //絶対パス、相対パスを表示 27 lstrcpy(temporary,path); 28 lstrcpy( temporary, projectInfo.GetWorkDir().GetFullPath( temporary ).c_str() ); 29 SetDlgItemText(hwnd,IDC_USING_FILE,temporary); 30 SetDlgItemText(hwnd,IDC_DEFINED_FILE,path); 31 32 //最終更新日時を表示 33 hFile=CreateFile(temporary,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); 34 if(hFile==INVALID_HANDLE_VALUE){ 35 //"エラー" 36 lstrcpy(temporary,STRING_ERROR); 37 } 38 else{ 39 GetFileTime(hFile,NULL,NULL,&LastWriteTime); 40 FileTimeToLocalFileTime(&LastWriteTime,&LocalTime); 41 FileTimeToSystemTime(&LocalTime,&SystemTime); 42 if(SystemTime.wHour>=12){ 43 //"午後 " 44 lstrcpy(temporary,STRING_AFTERNOON); 45 lstrcat(temporary," "); 46 SystemTime.wHour-=12; 19 { 20 SetPosCenter(hwnd); 21 22 hTreeItem = pobj_FileTree->GetSelectedItem(); 23 24 std::string tempPath = projectInfo.pobj_DBFileInfo->GetPath(hTreeItem); 25 26 //絶対パス、相対パスを表示 27 lstrcpy( temporary, tempPath.c_str() ); 28 lstrcpy( temporary, projectInfo.GetWorkDir().GetFullPath( temporary ).c_str() ); 29 SetDlgItemText(hwnd,IDC_USING_FILE,temporary); 30 SetDlgItemText(hwnd,IDC_DEFINED_FILE,tempPath.c_str()); 31 32 //最終更新日時を表示 33 hFile=CreateFile(temporary,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); 34 if(hFile==INVALID_HANDLE_VALUE){ 35 //"エラー" 36 lstrcpy(temporary,STRING_ERROR); 47 37 } 48 38 else{ 49 //"午前 " 50 lstrcpy(temporary,STRING_MORNING); 51 lstrcat(temporary," "); 39 GetFileTime(hFile,NULL,NULL,&LastWriteTime); 40 FileTimeToLocalFileTime(&LastWriteTime,&LocalTime); 41 FileTimeToSystemTime(&LocalTime,&SystemTime); 42 if(SystemTime.wHour>=12){ 43 //"午後 " 44 lstrcpy(temporary,STRING_AFTERNOON); 45 lstrcat(temporary," "); 46 SystemTime.wHour-=12; 47 } 48 else{ 49 //"午前 " 50 lstrcpy(temporary,STRING_MORNING); 51 lstrcat(temporary," "); 52 } 53 sprintf(temporary+5,"%02d:%02d:%02d %04d/%02d/%02d", 54 SystemTime.wHour,SystemTime.wMinute,SystemTime.wSecond, 55 SystemTime.wYear,SystemTime.wMonth,SystemTime.wDay); 56 CloseHandle(hFile); 52 57 } 53 sprintf(temporary+5,"%02d:%02d:%02d %04d/%02d/%02d", 54 SystemTime.wHour,SystemTime.wMinute,SystemTime.wSecond, 55 SystemTime.wYear,SystemTime.wMonth,SystemTime.wDay); 56 CloseHandle(hFile); 57 } 58 SetDlgItemText(hwnd,IDC_UPDATE_TIME,temporary); 59 60 61 ////////////// 62 // 形式を表示 63 ////////////// 64 i=GetFileExtension(path); 65 66 //"Basic プログラム" 67 if(i==FT_BASICPROGRAM) lstrcpy(temporary,STRING_FILETYPE_BASICPROGRAM); 68 //"サブ プログラム" 69 else if(i==FT_SUBPROGRAM) lstrcpy(temporary,STRING_FILETYPE_SUBPROGRAM); 70 //"テキスト ドキュメント" 71 else if(i==FT_TEXT) lstrcpy(temporary,STRING_FILETYPE_TEXT); 72 //"判別できません" 73 else lstrcpy(temporary,STRING_FILETYPE_UNKNOWN); 74 75 SetDlgItemText(hwnd,IDC_FILETYPE,temporary); 76 77 break; 58 SetDlgItemText(hwnd,IDC_UPDATE_TIME,temporary); 59 60 61 ////////////// 62 // 形式を表示 63 ////////////// 64 i=GetFileExtension(tempPath.c_str()); 65 66 //"Basic プログラム" 67 if(i==FT_BASICPROGRAM) lstrcpy(temporary,STRING_FILETYPE_BASICPROGRAM); 68 //"サブ プログラム" 69 else if(i==FT_SUBPROGRAM) lstrcpy(temporary,STRING_FILETYPE_SUBPROGRAM); 70 //"テキスト ドキュメント" 71 else if(i==FT_TEXT) lstrcpy(temporary,STRING_FILETYPE_TEXT); 72 //"判別できません" 73 else lstrcpy(temporary,STRING_FILETYPE_UNKNOWN); 74 75 SetDlgItemText(hwnd,IDC_FILETYPE,temporary); 76 77 break; 78 } 78 79 case WM_COMMAND: 79 80 switch(LOWORD(wParam)){ … … 93 94 HTREEITEM hTreeItem; 94 95 char temporary[MAX_PATH]; 95 char *path;96 96 switch(message){ 97 97 case WM_COMMAND: … … 104 104 break; 105 105 case IDM_FILETREE_OPEN: 106 hTreeItem=TreeView_GetSelection(hwnd); 107 108 path=projectInfo.pobj_DBFileInfo->GetPath(hTreeItem); 109 if(!path) break; 110 111 lstrcpy(temporary,path); 112 lstrcpy( temporary, projectInfo.GetWorkDir().GetFullPath( temporary ).c_str() ); 113 OpenFileWithExtension(temporary); 114 break; 106 { 107 hTreeItem=TreeView_GetSelection(hwnd); 108 109 std::string tempPath = projectInfo.pobj_DBFileInfo->GetPath(hTreeItem); 110 111 lstrcpy( temporary, tempPath.c_str() ); 112 lstrcpy( temporary, projectInfo.GetWorkDir().GetFullPath( temporary ).c_str() ); 113 OpenFileWithExtension(temporary); 114 break; 115 } 115 116 case IDM_FILETREE_DELETE: 116 117 hTreeItem=TreeView_GetSelection(hwnd); … … 141 142 } 142 143 143 CFileTree::CFileTree(HWND hParent){ 144 hTree=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"", 145 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS, 146 0,0,0,0, 147 hParent,0,hInst,0); 148 OldFileTreeViewProc=(WNDPROC)GetWindowLongPtr(hTree,GWLP_WNDPROC); 149 SetWindowLongPtr(hTree,GWLP_WNDPROC,(long)FileTreeViewProc); 144 FileListTreeViewCtrl::FileListTreeViewCtrl( HWND hParent ) 145 : CTreeViewCtrl() 146 { 147 this->Create( hParent, NULL, NULL, 148 WS_CHILD | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS, 149 WS_EX_CLIENTEDGE 150 ); 151 152 OldFileTreeViewProc=(WNDPROC)this->GetWindowLongPtr(GWLP_WNDPROC); 153 this->SetWindowLongPtr(GWLP_WNDPROC,(long)FileTreeViewProc); 150 154 151 155 //イメージリスト読み込み、設定 … … 154 158 ImageList_AddIcon(hImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_FOLDER_OPEN))); 155 159 ImageList_AddIcon(hImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_TEXTDOCUMENT))); 156 TreeView_SetImageList(hTree,hImageList,TVSIL_NORMAL); 157 } 158 CFileTree::~CFileTree(){ 159 DestroyWindow(hTree); 160 this->SetImageList(hImageList,TVSIL_NORMAL); 161 } 162 FileListTreeViewCtrl::~FileListTreeViewCtrl() 163 { 164 this->DestroyWindow(); 160 165 ImageList_Destroy(hImageList); 161 166 } 162 167 163 void CFileTree::ContextMenu(POINT *pPos){ 168 void FileListTreeViewCtrl::ContextMenu(POINT *pPos) 169 { 164 170 //右クリックによるメニューを表示 165 171 TV_HITTESTINFO tvHitTestInfo; 166 172 tvHitTestInfo.pt=*pPos; 167 ScreenToClient(hTree,&tvHitTestInfo.pt); 168 169 HTREEITEM hTreeItem; 170 hTreeItem=TreeView_HitTest(hTree,&tvHitTestInfo); 173 this->ScreenToClient(&tvHitTestInfo.pt); 174 175 HTREEITEM hTreeItem = this->HitTest(&tvHitTestInfo); 171 176 if(hTreeItem){ 172 TreeView_SelectItem(hTree,hTreeItem);177 this->SelectItem(hTreeItem); 173 178 174 179 extern HMENU hFileTreeMenuBase; 175 if(TreeView_GetRoot(hTree)==hTreeItem) 176 TrackPopupMenu(GetSubMenu(hFileTreeMenuBase,0),TPM_LEFTALIGN,pPos->x,pPos->y,0,hTree,0); 177 else TrackPopupMenu(GetSubMenu(hFileTreeMenuBase,1),TPM_LEFTALIGN,pPos->x,pPos->y,0,hTree,0); 180 if(this->GetRootItem()==hTreeItem) 181 { 182 TrackPopupMenu(GetSubMenu(hFileTreeMenuBase,0),TPM_LEFTALIGN,pPos->x,pPos->y,0,this->m_hWnd,0); 183 } 184 else 185 { 186 TrackPopupMenu(GetSubMenu(hFileTreeMenuBase,1),TPM_LEFTALIGN,pPos->x,pPos->y,0,this->m_hWnd,0); 187 } 178 188 } 179 189 } 180 190 181 HTREEITEM CFileTree::insert(char *str){191 HTREEITEM FileListTreeViewCtrl::insert(char *str){ 182 192 ////////////////////// 183 193 //ツリービューに追加 … … 188 198 tv.item.iImage=2; 189 199 tv.item.iSelectedImage=2; 190 tv.hParent= TreeView_GetRoot(hTree);200 tv.hParent=this->GetRootItem(); 191 201 tv.item.pszText=str; 192 202 193 return TreeView_InsertItem(hTree,&tv); 194 } 195 196 void CFileTree::resize(int x,int y,int cx,int cy){ 197 MoveWindow(hTree,x,y,cx,cy,1); 198 } 203 return this->InsertItem(&tv); 204 }
Note:
See TracChangeset
for help on using the changeset viewer.