Changeset 786 in dev


Ignore:
Timestamp:
Jan 30, 2011, 12:58:28 AM (14 years ago)
Author:
イグトランス (egtra)
Message:

abdevにおいて、resについてアイコン・カーソルを自前関数での読込へ変更。

Location:
branches/egtra/ab5.0/abdev
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/egtra/ab5.0/abdev/abdev-impl/Resource/Load.cpp

    r782 r786  
    11#include "stdafx.h"
     2#include <map>
     3#include <tuple>
     4#include <Resource/Load.h>
    25
    36namespace ActiveBasic { namespace Resource {
    47
     8namespace {
     9
     10template<typename Map, typename Key, typename AddValueFunctor>
     11typename Map::iterator GetCacheFromMap(Map& map, Key key, AddValueFunctor f)
     12{
     13    auto low = map.lower_bound(key);
     14    if (low != map.end() && map.key_comp()(key, low->first))
     15    {
     16        return low;
     17    }
     18    else
     19    {
     20        typedef typename Map::key_type key_type;
     21        typedef typename Map::value_type value_type;
     22        return map.insert(low, std::make_pair(std::move(key), f()));
     23    }
     24}
     25
     26HICON LoadIconCursorImpl(HINSTANCE hinst, USHORT id, int cxDesired, int cyDesired, UINT load, bool isIcon)
     27{
     28    auto hrsrc = FindResource(hinst, MAKEINTRESOURCE(id), isIcon ? RT_GROUP_ICON : RT_GROUP_CURSOR);
     29    auto pResource = LockResource(LoadResource(hinst, hrsrc));
     30
     31    auto idIcon = LookupIconIdFromDirectoryEx(reinterpret_cast<PBYTE>(pResource), isIcon, cxDesired, cyDesired, load);
     32    auto hrsrcIcon = FindResource(hinst, MAKEINTRESOURCE(idIcon), isIcon ? RT_ICON : RT_CURSOR);
     33    auto pResourceIcon = LockResource(LoadResource(hinst, hrsrcIcon));
     34
     35    return CreateIconFromResourceEx(reinterpret_cast<PBYTE>(pResourceIcon),
     36        SizeofResource(hinst, hrsrcIcon), isIcon, 0x00030000, cxDesired, cyDesired, load);
     37}
     38
     39}
     40
    541HICON LoadIcon(HINSTANCE hinst, USHORT id, int cxDesired, int cyDesired, UINT load)
    642{
    7     auto hrsrc = FindResource(hinst, MAKEINTRESOURCE(id), RT_GROUP_ICON);
    8     auto hMem = LoadResource(hinst, hrsrc);
    9     auto pResource = LockResource(hMem);
     43    return LoadIconCursorImpl(hinst, id, cxDesired, cyDesired, load, true);
     44}
    1045
    11     auto idIcon = LookupIconIdFromDirectoryEx(reinterpret_cast<PBYTE>(pResource), TRUE, cxDesired, cyDesired, load);
    12     auto hrsrcIcon = FindResource(hinst, MAKEINTRESOURCE(idIcon), MAKEINTRESOURCE(RT_ICON));
    13     auto hIconMem = LoadResource(hinst, hrsrcIcon);
    14     auto pResourceIcon = LockResource(hIconMem);
     46HICON LoadIcon(HINSTANCE hinst, USHORT id)
     47{
     48    return LoadIconCursorImpl(hinst, id, 32, 32, LR_SHARED, true);
     49}
    1550
    16     return CreateIconFromResourceEx(reinterpret_cast<PBYTE>(pResourceIcon),
    17         SizeofResource(hinst, hrsrcIcon), TRUE, 0x00030000, cxDesired, cyDesired, load);
     51HCURSOR LoadCursor(HINSTANCE hinst, USHORT id)
     52{
     53    return LoadIconCursorImpl(hinst, id, 32, 32, LR_SHARED, false);
    1854}
    1955
  • branches/egtra/ab5.0/abdev/abdev-impl/Resource/Load.h

    r784 r786  
    77
    88HICON LoadIcon(HINSTANCE hinst, USHORT id, int cxDesired, int cyDesired, UINT load = 0);
     9HICON LoadIcon(HINSTANCE hinst, USHORT id);
     10
     11HCURSOR LoadCursor(HINSTANCE hinst, USHORT id);
    912
    1013struct IconDeleter
  • branches/egtra/ab5.0/abdev/abdev/Complement.cpp

    r655 r786  
    754754            hImageList=ImageList_Create(16, 16, ILC_COLOR24, 7, 0);
    755755            ListView_SetImageList(hListView, hImageList, LVSIL_SMALL);
    756             ImageList_AddIcon(hImageList, LoadIcon(hResInst, MAKEINTRESOURCE(IDI_MEMBER_PRIVATE_VARIABLE)));
    757             ImageList_AddIcon(hImageList, LoadIcon(hResInst, MAKEINTRESOURCE(IDI_MEMBER_PUBLIC_VARIABLE)));
    758             ImageList_AddIcon(hImageList, LoadIcon(hResInst, MAKEINTRESOURCE(IDI_MEMBER_PRIVATE_FUNCTION)));
    759             ImageList_AddIcon(hImageList, LoadIcon(hResInst, MAKEINTRESOURCE(IDI_MEMBER_PUBLIC_FUNCTION)));
    760             ImageList_AddIcon(hImageList, LoadIcon(hResInst, MAKEINTRESOURCE(IDI_PAIRSTATEMENT)));
    761             ImageList_AddIcon(hImageList, LoadIcon(hResInst, MAKEINTRESOURCE(IDI_HTML_GENERAL_PARAMETER)));
    762             ImageList_AddIcon(hImageList, LoadIcon(hResInst, MAKEINTRESOURCE(IDI_HTML_PARAMETER)));
     756            ImageList_AddIcon(hImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_MEMBER_PRIVATE_VARIABLE));
     757            ImageList_AddIcon(hImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_MEMBER_PUBLIC_VARIABLE));
     758            ImageList_AddIcon(hImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_MEMBER_PRIVATE_FUNCTION));
     759            ImageList_AddIcon(hImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_MEMBER_PUBLIC_FUNCTION));
     760            ImageList_AddIcon(hImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_PAIRSTATEMENT));
     761            ImageList_AddIcon(hImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_HTML_GENERAL_PARAMETER));
     762            ImageList_AddIcon(hImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_HTML_PARAMETER));
    763763
    764764            return 0;
  • branches/egtra/ab5.0/abdev/abdev/DialogBoxes.cpp

    r763 r786  
    630630            ImageList_AddIcon(hImageList, LoadIcon(hInst, MAKEINTRESOURCE(IDI_FILE_BAS)));
    631631            ImageList_AddIcon(hImageList, LoadIcon(hInst, MAKEINTRESOURCE(IDI_FILE_SBP)));
    632             ImageList_AddIcon(hImageList, LoadIcon(hResInst, MAKEINTRESOURCE(IDI_NEWFILE_PJ)));
    633             ImageList_AddIcon(hImageList, LoadIcon(hResInst, MAKEINTRESOURCE(IDI_NEWFILE_TEXT)));
    634             ImageList_AddIcon(hImageList, LoadIcon(hResInst, MAKEINTRESOURCE(IDI_NEWFILE_HTML)));
    635             ImageList_AddIcon(hImageList, LoadIcon(hResInst, MAKEINTRESOURCE(IDI_NEWFILE_ICON)));
     632            ImageList_AddIcon(hImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_NEWFILE_PJ));
     633            ImageList_AddIcon(hImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_NEWFILE_TEXT));
     634            ImageList_AddIcon(hImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_NEWFILE_HTML));
     635            ImageList_AddIcon(hImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_NEWFILE_ICON));
    636636
    637637
  • branches/egtra/ab5.0/abdev/abdev/FileTree.cpp

    r705 r786  
    160160    //イメージリスト読み込み、設定
    161161    hImageList=ImageList_Create(16,16,ILC_COLOR24|ILC_MASK,3,0);
    162     ImageList_AddIcon(hImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_FOLDER_CLOSE)));
    163     ImageList_AddIcon(hImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_FOLDER_OPEN)));
    164     ImageList_AddIcon(hImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_TEXTDOCUMENT)));
     162    ImageList_AddIcon(hImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_FOLDER_CLOSE));
     163    ImageList_AddIcon(hImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_FOLDER_OPEN));
     164    ImageList_AddIcon(hImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_TEXTDOCUMENT));
    165165    this->SetImageList(hImageList,TVSIL_NORMAL);
    166166}
  • branches/egtra/ab5.0/abdev/abdev/IconEditor_Main.cpp

    r629 r786  
    11991199                InvalidateRect(hwnd,NULL,0);
    12001200
    1201                 SetCursor(LoadCursor(hResInst,MAKEINTRESOURCE(IDC_CURSOR_PEN)));
     1201                SetCursor(ActiveBasic::Resource::LoadCursor(hResInst, IDC_CURSOR_PEN));
    12021202            }
    12031203            else if(MdiInfo[WndNum]->MdiIconEditInfo->NowTool==IDC_TOOL_FILL){
     
    12141214                    InvalidateRect(hwnd,NULL,0);
    12151215                }
    1216                 SetCursor(LoadCursor(hResInst,MAKEINTRESOURCE(IDC_CURSOR_FILL)));
     1216                SetCursor(ActiveBasic::Resource::LoadCursor(hResInst, IDC_CURSOR_FILL));
    12171217            }
    12181218            else if(MdiInfo[WndNum]->MdiIconEditInfo->NowTool==IDC_TOOL_LINE||
     
    14961496                }
    14971497                else if(MdiInfo[WndNum]->MdiIconEditInfo->NowTool==IDC_TOOL_PEN)
    1498                     SetCursor(LoadCursor(hResInst,MAKEINTRESOURCE(IDC_CURSOR_PEN)));
     1498                    SetCursor(ActiveBasic::Resource::LoadCursor(hResInst, IDC_CURSOR_PEN));
    14991499                else if(MdiInfo[WndNum]->MdiIconEditInfo->NowTool==IDC_TOOL_FILL)
    1500                     SetCursor(LoadCursor(hResInst,MAKEINTRESOURCE(IDC_CURSOR_FILL)));
     1500                    SetCursor(ActiveBasic::Resource::LoadCursor(hResInst, IDC_CURSOR_FILL));
    15011501                else if(MdiInfo[WndNum]->MdiIconEditInfo->NowTool==IDC_TOOL_LINE||
    15021502                    MdiInfo[WndNum]->MdiIconEditInfo->NowTool==IDC_TOOL_RECTANGLE||
  • branches/egtra/ab5.0/abdev/abdev/Print.cpp

    r763 r786  
    421421            //拡大・縮小アイコンを表示
    422422            SendDlgItemMessage(hwnd,IDC_ZOOMOUT,BM_SETIMAGE,IMAGE_ICON ,
    423                 (LPARAM)LoadImage(hResInst,MAKEINTRESOURCE(IDI_ZOOMOUT),IMAGE_ICON,16,16,LR_SHARED));
     423                reinterpret_cast<LPARAM>(ActiveBasic::Resource::LoadIcon(hResInst, IDI_ZOOMOUT, 16, 16, LR_SHARED)));
    424424            SendDlgItemMessage(hwnd,IDC_ZOOMIN,BM_SETIMAGE,IMAGE_ICON ,
    425                 (LPARAM)LoadImage(hResInst,MAKEINTRESOURCE(IDI_ZOOMIN),IMAGE_ICON,16,16,LR_SHARED));
     425                reinterpret_cast<LPARAM>(ActiveBasic::Resource::LoadIcon(hResInst, IDI_ZOOMIN, 16, 16, LR_SHARED)));
    426426            iZoomNowPage=ZOOM_INIT;
    427427
  • branches/egtra/ab5.0/abdev/abdev/ProjectControl.cpp

    r705 r786  
    466466            //イメージリスト読み込み、設定
    467467            hProcedureTreeViewImageList=ImageList_Create(16,16,ILC_COLOR24|ILC_MASK,8,0);
    468             ImageList_AddIcon(hProcedureTreeViewImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_FOLDER_CLOSE)));
    469             ImageList_AddIcon(hProcedureTreeViewImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_FOLDER_OPEN)));
    470             ImageList_AddIcon(hProcedureTreeViewImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_PROCEDURE)));
    471             ImageList_AddIcon(hProcedureTreeViewImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_PROGRAM_FOLDER)));
    472             ImageList_AddIcon(hProcedureTreeViewImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_MEMBER_PUBLIC_VARIABLE)));
    473             ImageList_AddIcon(hProcedureTreeViewImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_MEMBER_PUBLIC_FUNCTION)));
    474             ImageList_AddIcon(hProcedureTreeViewImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_MEMBER_PRIVATE_VARIABLE)));
    475             ImageList_AddIcon(hProcedureTreeViewImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_MEMBER_PRIVATE_FUNCTION)));
     468            ImageList_AddIcon(hProcedureTreeViewImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_FOLDER_CLOSE));
     469            ImageList_AddIcon(hProcedureTreeViewImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_FOLDER_OPEN));
     470            ImageList_AddIcon(hProcedureTreeViewImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_PROCEDURE));
     471            ImageList_AddIcon(hProcedureTreeViewImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_PROGRAM_FOLDER));
     472            ImageList_AddIcon(hProcedureTreeViewImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_MEMBER_PUBLIC_VARIABLE));
     473            ImageList_AddIcon(hProcedureTreeViewImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_MEMBER_PUBLIC_FUNCTION));
     474            ImageList_AddIcon(hProcedureTreeViewImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_MEMBER_PRIVATE_VARIABLE));
     475            ImageList_AddIcon(hProcedureTreeViewImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_MEMBER_PRIVATE_FUNCTION));
    476476            TreeView_SetImageList(hProcedureTreeView,hProcedureTreeViewImageList,TVSIL_NORMAL);
    477477
     
    485485            //イメージリスト読み込み、設定
    486486            hMaterialTreeViewImageList=ImageList_Create(16,16,ILC_COLOR24|ILC_MASK,3,0);
    487             ImageList_AddIcon(hMaterialTreeViewImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_FOLDER_CLOSE)));
    488             ImageList_AddIcon(hMaterialTreeViewImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_FOLDER_OPEN)));
    489             ImageList_AddIcon(hMaterialTreeViewImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_WINDOW)));
    490             ImageList_AddIcon(hMaterialTreeViewImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_MENU)));
    491             ImageList_AddIcon(hMaterialTreeViewImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_FILE_ICON)));
    492             ImageList_AddIcon(hMaterialTreeViewImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_FILE_BMP)));
    493             ImageList_AddIcon(hMaterialTreeViewImageList,LoadIcon(hResInst,MAKEINTRESOURCE(IDI_FILE_CURSOR)));
     487            ImageList_AddIcon(hMaterialTreeViewImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_FOLDER_CLOSE));
     488            ImageList_AddIcon(hMaterialTreeViewImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_FOLDER_OPEN));
     489            ImageList_AddIcon(hMaterialTreeViewImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_WINDOW));
     490            ImageList_AddIcon(hMaterialTreeViewImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_MENU));
     491            ImageList_AddIcon(hMaterialTreeViewImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_FILE_ICON));
     492            ImageList_AddIcon(hMaterialTreeViewImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_FILE_BMP));
     493            ImageList_AddIcon(hMaterialTreeViewImageList, ActiveBasic::Resource::LoadIcon(hResInst, IDI_FILE_CURSOR));
    494494            TreeView_SetImageList(hMaterialTreeView,hMaterialTreeViewImageList,TVSIL_NORMAL);
    495495
  • branches/egtra/ab5.0/abdev/abdev/SubOperation.cpp

    r784 r786  
    838838    extern HICON hOwnerIcon,hBasicProgramIcon,hTextDocumentIcon,hWindowDocumentIcon;
    839839    hOwnerIcon=(HICON)LoadImage(hInst,MAKEINTRESOURCE(IDI_MAIN),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
    840     hBasicProgramIcon=(HICON)LoadImage(hResInst,MAKEINTRESOURCE(IDI_BASICPROGRAM),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
    841     hTextDocumentIcon=(HICON)LoadImage(hResInst,MAKEINTRESOURCE(IDI_TEXTDOCUMENT),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
    842     hWindowDocumentIcon=(HICON)LoadImage(hResInst,MAKEINTRESOURCE(IDI_WINDOW),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
     840    hBasicProgramIcon=ActiveBasic::Resource::LoadIcon(hResInst, IDI_BASICPROGRAM, 16, 16, LR_DEFAULTCOLOR);
     841    hTextDocumentIcon=ActiveBasic::Resource::LoadIcon(hResInst,IDI_TEXTDOCUMENT,16,16,LR_DEFAULTCOLOR);
     842    hWindowDocumentIcon=ActiveBasic::Resource::LoadIcon(hResInst,IDI_WINDOW,16,16,LR_DEFAULTCOLOR);
    843843
    844844
  • branches/egtra/ab5.0/abdev/abdev/TextEditor_MouseEvent.cpp

    r629 r786  
    6969
    7070        //カーソルを矢印マークにする
    71         SetCursor(LoadCursor(hResInst,MAKEINTRESOURCE(IDC_CURSOR_ARROW_TO_RIGHT)));
     71        SetCursor(ActiveBasic::Resource::LoadCursor(hResInst, IDC_CURSOR_ARROW_TO_RIGHT));
    7272
    7373        GetNaturalCaretPos_Click(WndNum,
     
    129129
    130130        //カーソルを矢印マークにする
    131         SetCursor(LoadCursor(hResInst,MAKEINTRESOURCE(IDC_CURSOR_ARROW_TO_RIGHT)));
     131        SetCursor(ActiveBasic::Resource::LoadCursor(hResInst, IDC_CURSOR_ARROW_TO_RIGHT));
    132132    }
    133133
     
    255255
    256256            //カーソルを矢印マークにする
    257             SetCursor(LoadCursor(hResInst,MAKEINTRESOURCE(IDC_CURSOR_ARROW_TO_RIGHT)));
     257            SetCursor(ActiveBasic::Resource::LoadCursor(hResInst, IDC_CURSOR_ARROW_TO_RIGHT));
    258258
    259259            return;
     
    321321
    322322        //カーソルを矢印マーク(デフォルト)にする
    323         SetCursor(LoadCursor(hResInst,MAKEINTRESOURCE(IDC_CURSOR_ARROW_TO_RIGHT)));
     323        SetCursor(ActiveBasic::Resource::LoadCursor(hResInst, IDC_CURSOR_ARROW_TO_RIGHT));
    324324
    325325        return;
  • branches/egtra/ab5.0/abdev/abdev/abdev.cpp

    r780 r786  
    914914    SHFILEINFO shfi;
    915915    if(filepath)
     916    {
    916917        SHGetFileInfo(filepath, FILE_ATTRIBUTE_ARCHIVE, &shfi, sizeof(SHFILEINFO), SHGFI_ICON | SHGFI_SMALLICON );
    917     else shfi.hIcon=(HICON)LoadImage(hResInst,MAKEINTRESOURCE(IDI_TEXTDOCUMENT),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);;
     918    }
     919    else
     920    {
     921        shfi.hIcon = ActiveBasic::Resource::LoadIcon(hResInst, IDI_TEXTDOCUMENT, 16, 16, LR_DEFAULTCOLOR);
     922    }
    918923    mdic.lParam=(LPARAM)shfi.hIcon;
    919924
Note: See TracChangeset for help on using the changeset viewer.