Changeset 789 in dev for branches/egtra/ab5.0/abdev
- Timestamp:
- Jan 30, 2011, 2:19:10 AM (14 years ago)
- Location:
- branches/egtra/ab5.0/abdev
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/egtra/ab5.0/abdev/ab-test/ab-test.cpp
r782 r789 72 72 BOOST_CHECK_EQUAL(bmpL.LockBits(&rc, Gdiplus::ImageLockModeRead, PixelFormat32bppARGB, &bdL), Gdiplus::Ok); 73 73 BOOST_CHECK_EQUAL(bmpR.LockBits(&rc, Gdiplus::ImageLockModeRead, PixelFormat32bppARGB, &bdR), Gdiplus::Ok); 74 74 75 75 AB_SCOPE_EXIT({bmpL.UnlockBits(&bdL);}); 76 76 AB_SCOPE_EXIT({bmpR.UnlockBits(&bdR);}); … … 94 94 } 95 95 96 BOOST_AUTO_TEST_CASE( ResourceLoading ) 96 UniqueHModule LoadABModule(LPCWSTR name) 97 { 98 TCHAR moduleName[MAX_PATH]; 99 ::GetModuleFileName(nullptr, moduleName, MAX_PATH); 100 101 auto systemDir = fs::path(moduleName).parent_path().parent_path() / L"build/release/system"; 102 103 UniqueHModule hmodRes(::LoadLibraryExW((systemDir / name).wstring().c_str(), nullptr, LOAD_LIBRARY_AS_DATAFILE)); 104 BOOST_CHECK(hmodRes != nullptr); 105 return hmodRes; 106 } 107 108 BOOST_AUTO_TEST_CASE( IconResourceLoading ) 97 109 { 98 110 Gdiplus::GdiplusStartupInput gdiplusStartupInput; … … 102 114 AB_SCOPE_EXIT_2(std::bind(Gdiplus::GdiplusShutdown, gdiplusToken)); 103 115 104 TCHAR moduleName[MAX_PATH]; 105 ::GetModuleFileName(nullptr, moduleName, MAX_PATH); 116 UniqueHModule hmodRes = LoadABModule(L"res.dll"); 106 117 107 auto systemDir = fs::path(moduleName).parent_path().parent_path() / "build/release/system"; 118 auto hBasicProgramIconL = (HICON)::LoadImage(hmodRes.get(), MAKEINTRESOURCE(IDI_BASICPROGRAM), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); 119 auto hBasicProgramIconR = abres::LoadIcon(hmodRes.get(), IDI_BASICPROGRAM, 16, 16, LR_DEFAULTCOLOR); 108 120 109 UniqueHModule hmodRes(::LoadLibraryExW((systemDir / "res.dll").wstring().c_str(), nullptr, LOAD_LIBRARY_AS_DATAFILE));110 BOOST_CHECK(h modRes!= nullptr);121 BOOST_CHECK(hBasicProgramIconL != nullptr); 122 BOOST_CHECK(hBasicProgramIconR != nullptr); 111 123 112 auto hBasicProgramIconTarget = (HICON)LoadImage(hmodRes.get(), MAKEINTRESOURCE(IDI_BASICPROGRAM), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); 113 auto hBasicProgramIcon = abres::LoadIcon(hmodRes.get(), IDI_BASICPROGRAM, 16, 16, LR_DEFAULTCOLOR); 124 BOOST_CHECK(IconEquals(hBasicProgramIconL, hBasicProgramIconR)); 114 125 115 BOOST_CHECK(hBasicProgramIconTarget != nullptr);116 BOOST_CHECK(hBasicProgramIcon != nullptr);126 auto hcurL = ::LoadCursor(hmodRes.get(), MAKEINTRESOURCE(IDC_CURSOR_PEN)); 127 auto hcurR = abres::LoadCursor(hmodRes.get(), IDC_CURSOR_PEN); 117 128 118 BOOST_CHECK(IconEquals(hBasicProgramIconTarget, hBasicProgramIcon)); 129 BOOST_CHECK(hcurL != nullptr); 130 BOOST_CHECK(hcurR != nullptr); 119 131 132 //BOOST_CHECK(IconEquals(hcurL, hcurR)); 120 133 } 134 135 BOOST_AUTO_TEST_CASE( StringResourceLoading ) 136 { 137 UniqueHModule hmodRes = LoadABModule(L"res.dll"); 138 139 WCHAR strL[1024]; 140 ::LoadStringW(hmodRes.get(), IDS_DEV_GROUP, strL, ARRAYSIZE(strL)); 141 142 boost::optional<std::wstring> strR = abres::LoadString(hmodRes.get(), IDS_DEV_GROUP); 143 144 BOOST_CHECK(!!strR); 145 BOOST_CHECK(strL == *strR); 146 } -
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 -
branches/egtra/ab5.0/abdev/abdev/DialogBoxes.cpp
r786 r789 2039 2039 #ifndef THETEXT 2040 2040 //ライブラリ開発チーム 2041 LoadString(hResInst,IDS_DEV_GROUP,temporary,1024); 2042 SetDlgItemText(hwnd,IDC_DEV_GROUP,temporary); 2041 boost::optional<std::wstring> devGroup = ActiveBasic::Resource::LoadString(hResInst, IDS_DEV_GROUP); 2042 if (devGroup) 2043 { 2044 SetDlgItemTextW(hwnd, IDC_DEV_GROUP, devGroup->c_str()); 2045 } 2043 2046 #endif 2044 2047 ApplyDialogTexture(hwnd);
Note:
See TracChangeset
for help on using the changeset viewer.