4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "ResourceLoader.hpp"
32 static HINSTANCE ResourceLoaderInstance
;
35 ResourceLoader::Init(HINSTANCE hInstance
)
37 assert(ResourceLoaderInstance
== NULL
);
39 ResourceLoaderInstance
= hInstance
;
44 #include "resource_data.h"
51 ResourceLoader::Load(const TCHAR
*name
, const TCHAR
*type
)
54 assert(ResourceLoaderInstance
!= NULL
);
56 HRSRC resource
= ::FindResource(ResourceLoaderInstance
, name
, type
);
58 return Data((const void *)NULL
, 0);
60 DWORD size
= ::SizeofResource(ResourceLoaderInstance
, resource
);
62 return Data((const void *)NULL
, 0);
64 HGLOBAL handle
= ::LoadResource(ResourceLoaderInstance
, resource
);
66 return Data((const void *)NULL
, 0);
68 LPVOID data
= LockResource(handle
);
70 return Data((const void *)NULL
, 0);
72 return std::pair
<const void *, size_t>(data
, size
);
75 for (unsigned i
= 0; named_resources
[i
].data
!= NULL
; ++i
)
76 if (_tcscmp(named_resources
[i
].name
, name
) == 0)
77 return Data(named_resources
[i
].data
, named_resources
[i
].size
);
79 return Data((const void *)NULL
, 0);
84 ResourceLoader::Load(unsigned id
)
87 return Load(MAKEINTRESOURCE(id
), RT_BITMAP
);
90 for (unsigned i
= 0; numeric_resources
[i
].data
!= NULL
; ++i
)
91 if (numeric_resources
[i
].id
== id
)
92 return Data(numeric_resources
[i
].data
, numeric_resources
[i
].size
);
94 return Data((const void *)NULL
, 0);
100 ResourceLoader::LoadBitmap2(unsigned id
)
102 return ::LoadBitmap(ResourceLoaderInstance
, MAKEINTRESOURCE(id
));
106 #ifdef HAVE_AYGSHELL_DLL
107 #include "OS/AYGShellDLL.hpp"
110 ResourceLoader::SHLoadImageResource(unsigned id
)
112 const AYGShellDLL ayg_shell_dll
;
113 return ayg_shell_dll
.SHLoadImageResource(ResourceLoaderInstance
, id
);