Database4YoU

Home ] Up ] News ] Applications ] YU applications ]

 

 

 

TMKeyboardLayoutCB v 1.0

Freeware without source!

TMKeyboardLayoutCB is TCustomComboBox descendant which will enable your end user to select the appropriate keyboard layout from the list of languages installed on system as he/she can do it from the taskbar if this option is available! Problem lies in the fact that you don't know what and when it is happening and sometimes you need much more, you need to control the process!

Some applications, like address books etc., needs at least two different keyboard layouts, one for entering names in native language and another one for e-mail or web addresses. If your application have to deal with names from different countries, the only way is to use Unicode charset and different languages, fonts and keyboard layouts.

Some languages also have sub languages or scripts, like Serbian -> Latin / Cyril, that do need some kind of translations from one script to another. It would be nice if windows sends you a message about sub language change only, wouldn't it. Also, you may want to change the font or its charset when the default keyboard layout for a group of controls is changing.

To finish the job and save it all in some database, you might need some other locale info, like country name & code, ANSI or OEM code page, language name or even language native name.

Properties Events Download Feedback

Description

When your application starts and TMKeyboardLayoutCB is loaded, it gets the list of all keyboard layouts available and fills combo box Items property with its names. You can save,  restore or change actual keyboard layout when appropriate.


Description  Events Download Feedback

Properties

Items

Items property should be considered read only. When you put the component on the form for the first time it's empty because Items are filled later in Loaded method and not stored with form at all. That's because Items are supposed to be filled during runtime with keyboard layouts of running system, not the developers one. As you close and reopen the form, Items are loaded and you can see and even change it's contents but without any effect, it is not stored!

Besides all standard combo box properties, there are two groups of properties introduced in TMKeyboardLayoutCB, As soon as user chooses from combo appropriate keyboard layout, all introduced properties are properly filled regardless of active  keyboard layout.

Keyboard

public property

SelectedLayout: HKL { Keyboard layout }

published properties:

Language:string  { Keyboard language }

Layout:string { Keyboard layout }

PhysicalLayout:string NB: might not always be the same as Layout !

LayoutFile:string  is here just in case you know how to deal with it.

LanguageID, SubLanguageID : integer.
SubLanguageID is the only way for you to know which script is used under the same language.

Locale properties are strings describing the selected layout, not the active one.

LanguageID:string   { Language ID  }
LanguageLocName:string   { Localized name of language }
LanguageEnName:string   { English name of language }
LanguageAbbName:string   { Abbreviated language name }
LanguageNativeName:string   { Native name of language }

CountryCode:string   { country code }
CountryLocName:string   { Localized name of country }
CountryEnName:string   { English name of country }
CountryAbbName: string  { Abbreviated country name }
CountryNativeName: string  { Native name of country }

DefLanguageID: string  { default language id }
DefCountryCode: string  { default country code }
DefOEMCodePage: string  { default OEM  code page }
DefANSICodePage: string  { default ANSI code page }
DefMACCodePage: string  { default MAC code page }


Description Properties  Download Feedback

Events

There are only three events introduced but very hard to find elsewhere!

OnChange is changed!
 
It is fired whenever user chooses new keyboard layout from combo, but the event handler receives var CanChange: Boolean and if you want to really change the keyboard layout you have to set CanChange to true. It's false by default.

If you have several combos of this kind, you'll prefer if the user just choose appropriate layouts for some component groups, not to change it at the moment. You'll have to apply this changes later when those groups get the focus, instead.

This might be done in an OnEnter event of TWinControl with
ActivateKeboardLayout(TMKeyboardLayoutCB1.Keyboard.SelectedLayout)
 
OnLanguageChange is activated after OnChange, if the language is changed!

It receives OldKeyboardLayout, NewKeyboardLayout: HKL and you may want to change fonts for some controls, save old state etc.
OnSubLanguageChange is activated only if the language remains the same but the sub language is changed.  Keyboard layout is changed, but not the language itself and OnLanguageChange is NOT activated at all.
This would be the right time to change at least font charset or apply script translations if necessary.


Description Properties Events  Feedback

Demo project is included in the archive, but this picture can give you a clue what is this about! Pay attention that the language is the same (Serbian) in both cases,  sublanguage is different (Latin / Cyrillic) and the physicall keyboard layout can be different (Croatian / Serbian) from the language layout!

Download  TMKeyboardLayoutCB10.zip ~ Kb

Source available on purchase Price: US $ 29.
Back to top

Copyright © 2001 Database4YoU                 Last modified: May 06, 2001