The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Eric4ever on March 07, 2006, 07:22:43 AM

Title: How to Change Application Language
Post by: Eric4ever on March 07, 2006, 07:22:43 AM
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?
Title: Re: How to Change Application Language
Post by: akane on March 07, 2006, 08:35:02 AM
If you have an OOP with same method as any api (SetThreadLocale) calling to SetThreadLocale from within oop' method will first search the method names.
:: - says to the parser - do not call any method, this is a function

also invoke SetThreadLocale(...)
MAKELCID is just an wrapper of MAKELONG(word low, word hi)
Title: Re: How to Change Application Language
Post by: Mark Jones on March 07, 2006, 07:59:51 PM
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_52lh.asp


Also note, "Windows 95/98/Me: Unsupported."
Title: Re: How to Change Application Language
Post by: Eric4ever on March 08, 2006, 02:20:48 AM
Quote from: akane on March 07, 2006, 08:35:02 AM
If you have an OOP with same method as any api (SetThreadLocale) calling to SetThreadLocale from within oop' method will first search the method names.
:: - says to the parser - do not call any method, this is a function

also invoke SetThreadLocale(...)
MAKELCID is just an wrapper of MAKELONG(word low, word hi)

akthor & Mark Jones: Thank you all:U, but I can not catch you... :( , I read the win32.hlp file and I know the SetThreadLocale function, I also  know the Parameters of MAKELCID and MAKELANGID macro, I just don't know how to use them?
coud you please explain it more detailedly? some codes fragment better..
Title: Re: How to Change Application Language
Post by: Light-I on March 08, 2006, 10:47:58 AM
This is some code... ;):MAKELANGID PROTO :USHORT,:USHORT
MAKELCID PROTO :WORD,:WORD

MAKELANGID proc usPrimaryLanguage:USHORT, usSubLanguage:USHORT
movzx eax, usPrimaryLanguage
movzx ebx, usSubLanguage
shl ebx, 10
or eax, ebx
ret
MAKELANGID endp
MAKELCID proc wLanguageID:WORD, wSortID:WORD
movzx eax, wSortID
movzx ebx, wLanguageID
shl eax, 16
or eax, ebx
ret
MAKELCID endp
Both procedures returns result in eax, as seen in C ;).
Also we can wrap MAKELCID into one :MAKELCID_Imed PROTO :USHORT,:USHORT,:WORD

MAKELCID_Imed proc  usPrimaryLanguage:USHORT, usSubLanguage:USHORT, wSortID:WORD
movzx eax, usSubLanguage
movzx ebx, usPrimaryLanguage
shl eax, 10
or eax, ebx
and ebx, 0FFFFh
movzx eax, wSortID
shl eax, 16
or eax, ebx
ret
MAKELCID_Imed endp
Title: Re: How to Change Application Language
Post by: Eric4ever on March 09, 2006, 02:46:29 AM
I used the "MAKELCID_Imed" proc but errors happen:

Assembling: test.asm
test.asm(17) : error A2006: undefined symbol : USHORT
test.asm(17) : error A2195: parameter or local cannot have void type
test.asm(17) : error A2129: VARARG parameter must be last parameter
test.asm(86) : error A2195: parameter or local cannot have void type
test.asm(86) : error A2111: conflicting parameter definition
test.asm(87) : error A2006: undefined symbol : usSubLanguage
test.asm(88) : error A2006: undefined symbol : usPrimaryLanguage
test.asm(92) : error A2006: undefined symbol : wSortID
NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x1'
Stop.


Do I Missed some inc/lib files?
Title: Re: How to Change Application Language
Post by: PBrennick on March 09, 2006, 04:12:46 AM
Eric4ever,
As far as USHORT is concerned, read http://msdn.microsoft.com/library/default.asp?url=/library/en-us/jscript7/html/jsdatushort.asp

About the error while trying to run cmd.exe - well that command only runs on an NT type of machine.  What OS are you using?

Paul
Title: Re: How to Change Application Language
Post by: Eric4ever on March 09, 2006, 10:49:12 AM
Quote from: PBrennick on March 09, 2006, 04:12:46 AM
Eric4ever,
As far as USHORT is concerned, read http://msdn.microsoft.com/library/default.asp?url=/library/en-us/jscript7/html/jsdatushort.asp

About the error while trying to run cmd.exe - well that command only runs on an NT type of machine.  What OS are you using?

Paul


Thank you, PBrennick :lol, I'm just a recruit of Win32 assembler  :toothy, so please forgive my simple question...

I'm using the Win 2003 server...
Title: Re: How to Change Application Language
Post by: PBrennick on March 09, 2006, 04:03:16 PM
Eric4ever,
A lot of times, if you fix one error; a lot of the other errors go away.  That is why I pointed you to USHORT first.

Paul