Changeset 789 in dev for branches/egtra/ab5.0/abdev/abdev-impl
- Timestamp:
- Jan 30, 2011, 2:19:10 AM (14 years ago)
- Location:
- branches/egtra/ab5.0/abdev/abdev-impl/Resource
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/egtra/ab5.0/abdev/abdev-impl/Resource/Load.cpp
r786 r789 1 1 #include "stdafx.h" 2 #include <map>3 #include <tuple>4 2 #include <Resource/Load.h> 5 3 … … 54 52 } 55 53 54 // 文字列リソースの読み込みについては以下を参照。 55 // How To Use LoadResource to Load Strings from a String Table 56 // http://support.microsoft.com/kb/200893/en-us 57 boost::optional<std::wstring> LoadString(HINSTANCE hinst, USHORT id) 58 { 59 UINT idRsrcBlk = id / 16 + 1; 60 int strIndex = id % 16; 61 62 auto hrsrc = FindResourceEx(hinst, RT_STRING, MAKEINTRESOURCE(idRsrcBlk), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)); 63 if (hrsrc == nullptr) 64 return boost::none; 65 66 auto hRes = LoadResource(hinst, hrsrc); 67 if (hRes == nullptr) 68 return boost::none; 69 LPCWSTR p = static_cast<LPCWSTR>(LockResource(hRes)); 70 if (p == nullptr) 71 return boost::none; 72 73 for (int i = 0; i < strIndex; ++i) 74 { 75 UINT length = *p++; 76 p += length; 77 } 78 79 UINT cch = *p++; 80 if (cch == 0) 81 { 82 return boost::none; 83 } 84 else 85 { 86 return std::wstring(p, cch); 87 } 88 } 89 56 90 }} 57 91 -
branches/egtra/ab5.0/abdev/abdev-impl/Resource/Load.h
r786 r789 3 3 #include <memory> 4 4 #include <windows.h> 5 #include <boost/optional.hpp> 5 6 6 7 namespace ActiveBasic { namespace Resource { … … 10 11 11 12 HCURSOR LoadCursor(HINSTANCE hinst, USHORT id); 13 14 boost::optional<std::wstring> LoadString(HINSTANCE hinst, USHORT id); 12 15 13 16 struct IconDeleter
Note:
See TracChangeset
for help on using the changeset viewer.