added function to load localized dialog

pull/1/head
Heiko Hund 2009-01-16 22:54:50 +00:00
parent 523a7a1e2e
commit d46af68a82
2 changed files with 24 additions and 8 deletions

View File

@ -25,7 +25,7 @@
static const LANGID defaultLangId = MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL);
static HRSRC
FindLangResource(HINSTANCE instance, PTSTR resType, PTSTR resId, LANGID langId)
FindResourceLang(HINSTANCE instance, PTSTR resType, PTSTR resId, LANGID langId)
{
HRSRC res;
@ -45,14 +45,14 @@ FindLangResource(HINSTANCE instance, PTSTR resType, PTSTR resId, LANGID langId)
int
LoadLangString(HINSTANCE instance, UINT stringId, LANGID langId, PTSTR buffer, int bufferSize)
LoadStringLang(HINSTANCE instance, UINT stringId, LANGID langId, PTSTR buffer, int bufferSize)
{
PWCH entry;
PTSTR resBlockId = MAKEINTRESOURCE(stringId / 16 + 1);
int resIndex = stringId & 15;
/* find resource block for string */
HRSRC res = FindLangResource(instance, RT_STRING, resBlockId, langId);
HRSRC res = FindResourceLang(instance, RT_STRING, resBlockId, langId);
if (res == NULL)
return 0;
@ -90,10 +90,10 @@ LoadLangString(HINSTANCE instance, UINT stringId, LANGID langId, PTSTR buffer, i
HICON
LoadLangIcon(HINSTANCE instance, PTSTR iconId, LANGID langId)
LoadIconLang(HINSTANCE instance, PTSTR iconId, LANGID langId)
{
/* find group icon resource */
HRSRC res = FindLangResource(instance, RT_GROUP_ICON, iconId, langId);
HRSRC res = FindResourceLang(instance, RT_GROUP_ICON, iconId, langId);
if (res == NULL)
return NULL;
@ -106,7 +106,7 @@ LoadLangIcon(HINSTANCE instance, PTSTR iconId, LANGID langId)
return NULL;
/* find the actual icon */
res = FindLangResource(instance, RT_ICON, MAKEINTRESOURCE(id), langId);
res = FindResourceLang(instance, RT_ICON, MAKEINTRESOURCE(id), langId);
if (res == NULL)
return NULL;
@ -120,3 +120,18 @@ LoadLangIcon(HINSTANCE instance, PTSTR iconId, LANGID langId)
return CreateIconFromResource(resInfo, resSize, TRUE, 0x30000);
}
INT_PTR
DialogBoxLang(HINSTANCE instance, PTSTR dialogId, LANGID langId, HWND parentWnd, DLGPROC dialogFunc)
{
/* find dialog resource */
HRSRC res = FindResourceLang(instance, RT_DIALOG, dialogId, langId);
if (res == NULL)
return -1;
HGLOBAL resInfo = LoadResource(instance, res);
if (resInfo == NULL)
return -1;
return DialogBoxIndirect(instance, resInfo, parentWnd, dialogFunc);
}

View File

@ -19,5 +19,6 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
int LoadLangString(HINSTANCE, UINT, LANGID, PTSTR, int);
HICON LoadLangIcon(HINSTANCE, PTSTR, LANGID);
int LoadStringLang(HINSTANCE, UINT, LANGID, PTSTR, int);
HICON LoadIconLang(HINSTANCE, PTSTR, LANGID);
INT_PTR DialogBoxLang(HINSTANCE, LPCTSTR, LANGID, HWND, DLGPROC);