Changeset 786 in dev for branches/egtra/ab5.0/abdev/abdev-impl/Resource/Load.cpp
- Timestamp:
- Jan 30, 2011, 12:58:28 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/egtra/ab5.0/abdev/abdev-impl/Resource/Load.cpp
r782 r786 1 1 #include "stdafx.h" 2 #include <map> 3 #include <tuple> 4 #include <Resource/Load.h> 2 5 3 6 namespace ActiveBasic { namespace Resource { 4 7 8 namespace { 9 10 template<typename Map, typename Key, typename AddValueFunctor> 11 typename 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 26 HICON 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 5 41 HICON LoadIcon(HINSTANCE hinst, USHORT id, int cxDesired, int cyDesired, UINT load) 6 42 { 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 } 10 45 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); 46 HICON LoadIcon(HINSTANCE hinst, USHORT id) 47 { 48 return LoadIconCursorImpl(hinst, id, 32, 32, LR_SHARED, true); 49 } 15 50 16 return CreateIconFromResourceEx(reinterpret_cast<PBYTE>(pResourceIcon), 17 SizeofResource(hinst, hrsrcIcon), TRUE, 0x00030000, cxDesired, cyDesired, load); 51 HCURSOR LoadCursor(HINSTANCE hinst, USHORT id) 52 { 53 return LoadIconCursorImpl(hinst, id, 32, 32, LR_SHARED, false); 18 54 } 19 55
Note:
See TracChangeset
for help on using the changeset viewer.