Ignore:
Timestamp:
Jun 17, 2008, 9:30:54 PM (16 years ago)
Author:
dai_9181
Message:

・BreakPoint周りをリファクタリング
・FileTree周りをリファクタリング

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/abdev/FileTree.cpp

    r620 r651  
    33#include "common.h"
    44
    5 CFileTree *pobj_FileTree;
     5FileListTreeViewCtrl *pobj_FileTree;
    66
    77WNDPROC OldFileTreeViewProc;
     
    1717    switch(message){
    1818        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);
    4737                }
    4838                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);
    5257                }
    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            }
    7879        case WM_COMMAND:
    7980            switch(LOWORD(wParam)){
     
    9394    HTREEITEM hTreeItem;
    9495    char temporary[MAX_PATH];
    95     char *path;
    9696    switch(message){
    9797        case WM_COMMAND:
     
    104104                    break;
    105105                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                    }
    115116                case IDM_FILETREE_DELETE:
    116117                    hTreeItem=TreeView_GetSelection(hwnd);
     
    141142}
    142143
    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);
     144FileListTreeViewCtrl::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);
    150154
    151155    //イメージリスト読み込み、設定
     
    154158    ImageList_AddIcon(hImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_FOLDER_OPEN)));
    155159    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}
     162FileListTreeViewCtrl::~FileListTreeViewCtrl()
     163{
     164    this->DestroyWindow();
    160165    ImageList_Destroy(hImageList);
    161166}
    162167
    163 void CFileTree::ContextMenu(POINT *pPos){
     168void FileListTreeViewCtrl::ContextMenu(POINT *pPos)
     169{
    164170    //右クリックによるメニューを表示
    165171    TV_HITTESTINFO tvHitTestInfo;
    166172    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);
    171176    if(hTreeItem){
    172         TreeView_SelectItem(hTree,hTreeItem);
     177        this->SelectItem(hTreeItem);
    173178
    174179        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        }
    178188    }
    179189}
    180190
    181 HTREEITEM CFileTree::insert(char *str){
     191HTREEITEM FileListTreeViewCtrl::insert(char *str){
    182192    //////////////////////
    183193    //ツリービューに追加
     
    188198    tv.item.iImage=2;
    189199    tv.item.iSelectedImage=2;
    190     tv.hParent=TreeView_GetRoot(hTree);
     200    tv.hParent=this->GetRootItem();
    191201    tv.item.pszText=str;
    192202
    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.