Ignore:
Timestamp:
Jan 30, 2011, 2:19:10 AM (14 years ago)
Author:
イグトランス (egtra)
Message:

LoadString代替関数の実装

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/egtra/ab5.0/abdev/ab-test/ab-test.cpp

    r782 r789  
    7272        BOOST_CHECK_EQUAL(bmpL.LockBits(&rc, Gdiplus::ImageLockModeRead, PixelFormat32bppARGB, &bdL), Gdiplus::Ok);
    7373        BOOST_CHECK_EQUAL(bmpR.LockBits(&rc, Gdiplus::ImageLockModeRead, PixelFormat32bppARGB, &bdR), Gdiplus::Ok);
    74        
     74
    7575        AB_SCOPE_EXIT({bmpL.UnlockBits(&bdL);});
    7676        AB_SCOPE_EXIT({bmpR.UnlockBits(&bdR);});
     
    9494}
    9595
    96 BOOST_AUTO_TEST_CASE( ResourceLoading )
     96UniqueHModule 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
     108BOOST_AUTO_TEST_CASE( IconResourceLoading )
    97109{
    98110    Gdiplus::GdiplusStartupInput gdiplusStartupInput;
     
    102114    AB_SCOPE_EXIT_2(std::bind(Gdiplus::GdiplusShutdown, gdiplusToken));
    103115
    104     TCHAR moduleName[MAX_PATH];
    105     ::GetModuleFileName(nullptr, moduleName, MAX_PATH);
     116    UniqueHModule hmodRes = LoadABModule(L"res.dll");
    106117
    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);
    108120
    109     UniqueHModule hmodRes(::LoadLibraryExW((systemDir / "res.dll").wstring().c_str(), nullptr, LOAD_LIBRARY_AS_DATAFILE));
    110     BOOST_CHECK(hmodRes != nullptr);
     121    BOOST_CHECK(hBasicProgramIconL != nullptr);
     122    BOOST_CHECK(hBasicProgramIconR != nullptr);
    111123
    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));
    114125
    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);
    117128
    118     BOOST_CHECK(IconEquals(hBasicProgramIconTarget, hBasicProgramIcon));
     129    BOOST_CHECK(hcurL != nullptr);
     130    BOOST_CHECK(hcurR != nullptr);
    119131
     132    //BOOST_CHECK(IconEquals(hcurL, hcurR));
    120133}
     134
     135BOOST_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}
Note: See TracChangeset for help on using the changeset viewer.