How to realize multiple-language in masm?Is there any good tutorals or examples?

The code below is a C++ eaxmple:

// <B>Place this code in InitInstance()</B>
m_lang = GetProfileInt("General","Language",0);
  if (m_lang == 0) {
    // switch language to english
    ::SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH,
                      SUBLANG_DEFAULT),SORT_DEFAULT));
  }
  else {
    // switch language to german
    ::SetThreadLocale(MAKELCID(MAKELANGID(LANG_GERMAN,
                      SUBLANG_DEFAULT),SORT_DEFAULT));
  }
  //
  //
  // Add a menu or a toolbar button and attach this method

  void CLanguageApp::OnLanguageTogglelanguage()
  {
    if (m_lang == 0) {
      WriteProfileInt("General","Language",1);
    }
    else {
      WriteProfileInt("General","Language",0);
    }
    AfxMessageBox(IDS_RESTART); // tell the user to restart the application
  }

//


But I don't know how change
::SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT),SORT_DEFAULT)); 
to the assembler format,Is there a better method to do it?
Posted on 2006-03-07 01:19:34 by Eric4ever
if I remember correctly, the SetThreadLocale function is not available for Win9x. I used to load string resources "by hand", this is not so difficult, you have to:


// calc STRINGTABLE id from string id

dwTable = (idName / 16) + 1 ;
dwString = idName - ((dwTable - 1) * 16) ;

hResource = FindResourceEx (hmodMain, RT_STRING, dwTable, wMainLang) ;
hRes = LoadResource (hmodMain, hResource) ;
pszRes = LockResource (hRes) ;

// position to text

for (dwLoop = 0 ; dwLoop < dwString ; dwLoop ++) {

dwLen = * ((WORD *) pszRes) ++ ;
((WORD *) pszRes) += dwLen ;
}


with this you can switch the main language wMainLanguage to get the corresponding string resource.
Posted on 2006-03-07 03:54:38 by beaster
beaster: Thank you :), but I can not catch you...,coud you please explain it more detailedly? some codes fragment better..

There are not only strings but also menu, text and Button, how to change the language of them? Is there a good method?

in rc

DLG_MAIN DIALOGEX 40, 55, 597, 322
LTEXT          "some infomation message",-1,219,51,20,9
DEFPUSHBUTTON  "RUN",IDRUN,315,279,41,13
IDM_MAIN menu discardable
{
(omit)
}

in asm

.const
szMsg0 db 'Message 1 to show in the edittext',0
Posted on 2006-03-07 21:03:17 by Eric4ever
you are right, this was only half of the truth..

I have more functions, that load resources directly, here is the (sorry C style) way:

LoadLangMenu:
hResource = FindResourceEx (hmodMain, RT_MENU, idMenu, wMainLang) ;
hRes = LoadResource (hmodMain, hResource) ;
pxRes = (MENUTEMPLATE *) LockResource (hRes) ;
* phmenuLoad = LoadMenuIndirect (pxRes) ;

LoadLangDialog:
hResource = FindResourceEx (hmodMain, RT_DIALOG, idDialog, wMainLang) ;
hRes = LoadResource (hmodMain, hResource) ;
pxRes = (DLGTEMPLATE *) LockResource (hRes) ;
return DialogBoxIndirectParam (hmodMain, pxRes, hwndParent, pfnDialog, dwUser) ;
Posted on 2006-03-08 13:52:56 by beaster