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

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

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.