Function to get the regional format settings
Moderator: Rathinagiri
Function to get the regional format settings
Dear All,
Is there any functions to get the regional format settings of the OS ?
TIA
best rgds
Chang
Is there any functions to get the regional format settings of the OS ?
TIA
best rgds
Chang
Just Hmg It !
- dragancesu
- Posts: 925
- Joined: Mon Jun 24, 2013 11:53 am
- DBs Used: DBF, MySQL, Oracle
- Location: Subotica, Serbia
Re: Function to get the regional format settings
Windows Registry contain data what you need, just read
Re: Function to get the regional format settings
Yes, Win API function - GetLocaleInfo (or GetLocaleInfoEx): https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Re: Function to get the regional format settings
Thanks for the replies,
but how to do it with Hmg ?
an samples ?
TIA
but how to do it with Hmg ?
an samples ?
TIA
Just Hmg It !
Re: Function to get the regional format settings
Suppose you want to know Country value from Registry, try working example
Code: Select all
/*
* HMG - Harbour Win32 GUI library Demo
*
* Copyright 2002-2008 Roberto Lopez <mail.box.hmg@gmail.com>
* http://www.hmgforum.com//
* bpd2000
*/
#include "hmg.ch"
PROCEDURE Main()
ReadRegistryTest()
Return nil
Procedure ReadRegistryTest()
private reg_key := 'HKEY_CURRENT_USER\Control Panel\International\sCountry'
reg_key_value := win_regRead ( reg_key)
MsgInfo ( reg_key_value, 'Reg_key_value' )
Return
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
Re: Function to get the regional format settings
Thanks Krzysztof.KDJ wrote: ↑Sun Apr 01, 2018 10:33 amYes, Win API function - GetLocaleInfo (or GetLocaleInfoEx): https://msdn.microsoft.com/en-us/librar ... s.85).aspx
I did something like this:
Code: Select all
#include "hmg.ch"
#include "hmgwinnls.ch" //Constants for HMG_GetLocaleInfo
Function Main
cDec := HMG_GetLocaleInfo( LOCALE_SDECIMAL )
cNeg := HMG_GetLocaleInfo( LOCALE_SNEGATIVESIGN )
cTho := HMG_GetLocaleInfo( LOCALE_STHOUSAND )
cGro := HMG_GetLocaleInfo( LOCALE_SGROUPING )
DEFINE WINDOW frm1 AT 159 , 333 WIDTH 397 HEIGHT 416 MAIN
@ 30, 30 LABEL Label_1 VALUE "Decimal symbol:" AUTOSIZE
@ 30,190 LABEL Label_1a VALUE cDec BACKCOLOR WHITE
@ 60, 30 LABEL Label_2 VALUE "No. of digits after decimal:" AUTOSIZE
@ 60,190 LABEL Label_2a VALUE HMG_GetLocaleInfo( LOCALE_IDIGITS ) BACKCOLOR WHITE
@ 90, 30 LABEL Label_3 VALUE "Digit grouping symbol:" AUTOSIZE
@ 90,190 LABEL Label_3a VALUE cTho BACKCOLOR WHITE
@120, 30 LABEL Label_4 VALUE "Digit grouping:" AUTOSIZE
@120,190 LABEL Label_4a VALUE IF(cGro = '0', '123456789', ;
IF(cGro == '3;0', '123'+cTho+'456'+cTho+'789', ;
IF(cGro == '3;0;0', '123456'+cTho+'789', ;
IF(cGro == '3;2;0', '12'+cTho+'34'+cTho+'56'+cTho+'789', 'Invalid' )))) BACKCOLOR WHITE
@150, 30 LABEL Label_5 VALUE "Negative sign symbol:" AUTOSIZE
@150,190 LABEL Label_5a VALUE cNeg BACKCOLOR WHITE
@180, 30 LABEL Label_6 VALUE "Negative number format:" AUTOSIZE
@180,190 LABEL Label_6a VALUE IF(HMG_GetLocaleInfo( LOCALE_INEGNUMBER ) ='0', '(1'+cDec+'1)' , ;
IF(HMG_GetLocaleInfo( LOCALE_INEGNUMBER ) ='1', cNeg+'1'+cDec+'1', ;
IF(HMG_GetLocaleInfo( LOCALE_INEGNUMBER ) ='2', cNeg+' 1'+cDec+'1', ;
IF(HMG_GetLocaleInfo( LOCALE_INEGNUMBER ) ='3', '1'+cDec+'1'+cNeg, ;
IF(HMG_GetLocaleInfo( LOCALE_INEGNUMBER ) ='4', '1'+cDec+'1 '+cNeg, 'Invalid' ))))) BACKCOLOR WHITE
@210, 30 LABEL Label_7 VALUE "Display leading zeros:" AUTOSIZE
@210,190 LABEL Label_7a VALUE IF( HMG_GetLocaleInfo( LOCALE_ILZERO ) = '0', '' , '0') + cDec + '7' BACKCOLOR WHITE
@240, 30 LABEL Label_8 VALUE "List separator:" AUTOSIZE
@240,190 LABEL Label_8a VALUE HMG_GetLocaleInfo( LOCALE_SLIST ) BACKCOLOR WHITE
@270, 30 LABEL Label_9 VALUE "Measurement system:" AUTOSIZE
@270,190 LABEL Label_9a VALUE IF(HMG_GetLocaleInfo( LOCALE_IMEASURE ) = '0', 'Metric', 'U.S.') BACKCOLOR WHITE
@300, 30 LABEL Label_10 VALUE "Standard digits:" AUTOSIZE
@300,190 LABEL Label_10a VALUE HMG_GetLocaleInfo( LOCALE_SNATIVEDIGITS ) BACKCOLOR WHITE
@330, 30 LABEL Label_11 VALUE "Use native digits:" AUTOSIZE
@330,190 LABEL Label_11a VALUE IF(HMG_GetLocaleInfo( LOCALE_IDIGITSUBSTITUTION ) = '0', 'Context-based', ;
IF(HMG_GetLocaleInfo( LOCALE_IDIGITSUBSTITUTION ) = '1', 'Never', ;
IF(HMG_GetLocaleInfo( LOCALE_IDIGITSUBSTITUTION ) = '2', 'Native', 'Invalid'))) BACKCOLOR WHITE
END WINDOW
CENTER WINDOW frm1
ACTIVATE WINDOW frm1
Return Nil
#pragma BEGINDUMP
#define COMPILE_HMG_UNICODE
#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"
#include <windows.h>
#include "hbapi.h"
#include "hbvm.h"
#include "hbstack.h"
HB_FUNC ( HMG_GETLOCALEINFO )
{
INT LCType = hb_parni (1);
LPTSTR cText;
cText = ( LPTSTR ) hb_xgrab( 128 );
GetLocaleInfo( LOCALE_USER_DEFAULT, LCType, cText, 128 );
HMG_retc( cText );
hb_xfree( cText );
}
#pragma ENDDUMP
Re: Function to get the regional format settings
I have compiled it with HMG 3.4.4 32-bit, Win-7 64-bit, and all works properly:
Re: Function to get the regional format settings
Well now I have a riddle .
I recompiled on a different machine (Win10-32bit) and the characters are displayed correctly .
On this computer, where characters are incorrectly displayed, the system Win10-64bit is brand new and the original unmodified hmg3.4.4 installed.
I recompiled on a different machine (Win10-32bit) and the characters are displayed correctly .
On this computer, where characters are incorrectly displayed, the system Win10-64bit is brand new and the original unmodified hmg3.4.4 installed.