News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How to Change Application Language

Started by Eric4ever, March 07, 2006, 07:22:43 AM

Previous topic - Next topic

Eric4ever

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?

akane

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)

Mark Jones

"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Eric4ever

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..

Light-I

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

Eric4ever

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?

PBrennick

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
The GeneSys Project is available from:
The Repository or My crappy website

Eric4ever

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...

PBrennick

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
The GeneSys Project is available from:
The Repository or My crappy website