PowerBuilder 10 Get and Set System Language

Today I wanted to retrieve the selected system language from PowerBuilder 10. To accomplish that I had to do some search in the web. After a long period I found this post in Google Groups.

It seems that Powerbuilder datawindow fields do have their onwn charset defined in font.charset property. If you change the language in a field, when this field loses focus (for example with a tab press), the selected language is changed back to system default.

This becomes quite annoying, especially when you have to access large datawindow forms via keyboard.
To retrieve the current system language and change it, you have to use Win32 GetKeyboardLayout and ActivateKeyboardLayout functions which are defined in user32.dll.

My machine uses two charsets, English (EN) and Greek (EL). So I followed these steps:

1.Define Win32 functions in Global External Functions

Function long GetKeyboardLayout  (long IdThread) Library "user32.dll"
Function long ActivateKeyboardLayout (long HKL, long flags) Library "user32.dll"

2.Define Global Variables
Note: I found the numeric language values by calling GetKeyboardLayout.

Constant long KLF_REORDER = 8
Constant long LANG_US_ENGLISH = 67699721
Constant long LANG_EL_GREEK = 67634184
long CurrentLanguage

3.Use the functions to retrieve current selected System Language or change it

// get and display current System Language
MessageBox('Keyboard language',GetKeyboardLayout(0))

// set System Language to Greek
ActivateKeyboardLayout(LANG_EL_GREEK , KLF_REORDER)
Advertisements

About cmanios

programming
This entry was posted in PowerBuilder and tagged , , , , . Bookmark the permalink.

2 Responses to PowerBuilder 10 Get and Set System Language

  1. Ranjit says:

    THANK YOU VERY MUCH. IT WORKS

  2. Christos says:

    Thanks , this was very helpful.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s