home *** CD-ROM | disk | FTP | other *** search
/ Dan Appleman's Visual Bas…s Guide to the Win32 API / Dan.Applmans.Visual.Basic.5.0.Programmers.Guide.To.The.Win32.API.1997.Ziff-Davis.Press.CD / VB5PG32.mdf / vbpg32 / samples5 / ch06 / ex6b.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-02-16  |  7.1 KB  |  126 lines

  1. VERSION 5.00
  2. Begin VB.Form Ex6b 
  3.    Caption         =   "Chapter 6 examples #2"
  4.    ClientHeight    =   3390
  5.    ClientLeft      =   1110
  6.    ClientTop       =   1515
  7.    ClientWidth     =   6270
  8.    LinkTopic       =   "Form1"
  9.    PaletteMode     =   1  'UseZOrder
  10.    ScaleHeight     =   3390
  11.    ScaleWidth      =   6270
  12.    Begin VB.ListBox List2 
  13.       Height          =   2760
  14.       Left            =   2880
  15.       TabIndex        =   2
  16.       Top             =   420
  17.       Width           =   2415
  18.    End
  19.    Begin VB.ListBox List1 
  20.       Height          =   2760
  21.       Left            =   300
  22.       TabIndex        =   0
  23.       Top             =   420
  24.       Width           =   1995
  25.    End
  26.    Begin VB.Label Label2 
  27.       Caption         =   "Calendar && Date Formats"
  28.       Height          =   255
  29.       Left            =   2880
  30.       TabIndex        =   3
  31.       Top             =   120
  32.       Width           =   2415
  33.    End
  34.    Begin VB.Label Label1 
  35.       Caption         =   "Locales"
  36.       Height          =   255
  37.       Left            =   300
  38.       TabIndex        =   1
  39.       Top             =   120
  40.       Width           =   1635
  41.    End
  42. Attribute VB_Name = "Ex6b"
  43. Attribute VB_GlobalNameSpace = False
  44. Attribute VB_Creatable = False
  45. Attribute VB_PredeclaredId = True
  46. Attribute VB_Exposed = False
  47. ' Copyright 
  48.  1997 by Desaware Inc. All Rights Reserved
  49. Option Explicit
  50. Private Declare Function EnumSystemLocales Lib "kernel32" Alias "EnumSystemLocalesA" (ByVal lpLocaleEnumProc As Long, ByVal dwFlags As Long) As Long
  51. Private Declare Function EnumCalendarInfo Lib "kernel32" Alias "EnumCalendarInfoA" (ByVal lpCalInfoEnumProc As Long, ByVal Locale As Long, ByVal Calendar As Long, ByVal CalType As Long) As Long
  52. Private Declare Function EnumDateFormats Lib "kernel32" Alias "EnumDateFormatsA" (ByVal lpDateFmtEnumProc As Long, ByVal Locale As Long, ByVal dwFlags As Long) As Long
  53. Private Declare Function GetCurrencyFormatBynum Lib "kernel32" Alias "GetCurrencyFormatA" (ByVal Locale As Long, ByVal dwFlags As Long, ByVal lpValue As String, ByVal lpFormat As Long, ByVal lpCurrencyStr As String, ByVal cchCurrency As Long) As Long
  54. Private Declare Function GetLastError Lib "kernel32" () As Long
  55. Private Const LCID_SUPPORTED = 2
  56. Private Const LOCALE_SYSTEM_DEFAULT = &H800
  57. Private Const ENUM_ALL_CALENDARS = &HFFFF                '  enumerate all calendars
  58. Private Const DATE_LONGDATE = &H2         '  use long date picture
  59. Private Const CAL_ICALINTVALUE = &H1                     '  calendar type
  60. Private Const CAL_SCALNAME = &H2                         '  native name of calendar
  61. Private Const CAL_IYEAROFFSETRANGE = &H3                 '  starting years of eras
  62. Private Const CAL_SERASTRING = &H4                       '  era name for IYearOffsetRanges
  63. Private Const CAL_SSHORTDATE = &H5                       '  Integer date format string
  64. Private Const CAL_SLONGDATE = &H6                        '  long date format string
  65. Private Const CAL_SDAYNAME1 = &H7                        '  native name for Monday
  66. Private Const CAL_SDAYNAME2 = &H8                        '  native name for Tuesday
  67. Private Const CAL_SDAYNAME3 = &H9                        '  native name for Wednesday
  68. Private Const CAL_SDAYNAME4 = &HA                        '  native name for Thursday
  69. Private Const CAL_SDAYNAME5 = &HB                        '  native name for Friday
  70. Private Const CAL_SDAYNAME6 = &HC                        '  native name for Saturday
  71. Private Const CAL_SDAYNAME7 = &HD                        '  native name for Sunday
  72. Private Const CAL_SABBREVDAYNAME1 = &HE                  '  abbreviated name for Monday
  73. Private Const CAL_SABBREVDAYNAME2 = &HF                  '  abbreviated name for Tuesday
  74. Private Const CAL_SABBREVDAYNAME3 = &H10                 '  abbreviated name for Wednesday
  75. Private Const CAL_SABBREVDAYNAME4 = &H11                 '  abbreviated name for Thursday
  76. Private Const CAL_SABBREVDAYNAME5 = &H12                 '  abbreviated name for Friday
  77. Private Const CAL_SABBREVDAYNAME6 = &H13                 '  abbreviated name for Saturday
  78. Private Const CAL_SABBREVDAYNAME7 = &H14                 '  abbreviated name for Sunday
  79. Private Const CAL_SMONTHNAME1 = &H15                     '  native name for January
  80. Private Const CAL_SMONTHNAME2 = &H16                     '  native name for February
  81. Private Const CAL_SMONTHNAME3 = &H17                     '  native name for March
  82. Private Const CAL_SMONTHNAME4 = &H18                     '  native name for April
  83. Private Const CAL_SMONTHNAME5 = &H19                     '  native name for May
  84. Private Const CAL_SMONTHNAME6 = &H1A                     '  native name for June
  85. Private Const CAL_SMONTHNAME7 = &H1B                     '  native name for July
  86. Private Const CAL_SMONTHNAME8 = &H1C                     '  native name for August
  87. Private Const CAL_SMONTHNAME9 = &H1D                     '  native name for September
  88. Private Const CAL_SMONTHNAME10 = &H1E                    '  native name for October
  89. Private Const CAL_SMONTHNAME11 = &H1F                    '  native name for November
  90. Private Const CAL_SMONTHNAME12 = &H20                    '  native name for December
  91. Private Const CAL_SMONTHNAME13 = &H21                    '  native name for 13th month (if any)
  92. Private Const CAL_SABBREVMONTHNAME1 = &H22               '  abbreviated name for January
  93. Private Const CAL_SABBREVMONTHNAME2 = &H23               '  abbreviated name for February
  94. Private Const CAL_SABBREVMONTHNAME3 = &H24               '  abbreviated name for March
  95. Private Const CAL_SABBREVMONTHNAME4 = &H25               '  abbreviated name for April
  96. Private Const CAL_SABBREVMONTHNAME5 = &H26               '  abbreviated name for May
  97. Private Const CAL_SABBREVMONTHNAME6 = &H27               '  abbreviated name for June
  98. Private Const CAL_SABBREVMONTHNAME7 = &H28               '  abbreviated name for July
  99. Private Const CAL_SABBREVMONTHNAME8 = &H29               '  abbreviated name for August
  100. Private Const CAL_SABBREVMONTHNAME9 = &H2A               '  abbreviated name for September
  101. Private Const CAL_SABBREVMONTHNAME10 = &H2B              '  abbreviated name for October
  102. Private Const CAL_SABBREVMONTHNAME11 = &H2C              '  abbreviated name for November
  103. Private Const CAL_SABBREVMONTHNAME12 = &H2D              '  abbreviated name for December
  104. Private Const CAL_SABBREVMONTHNAME13 = &H2E              '  abbreviated name for 13th month (if any)
  105. Private Sub Form_Load()
  106.     Dim dl&
  107.     List1.Clear
  108.     dl& = EnumSystemLocales(AddressOf Callback1_EnumFormats, LCID_SUPPORTED)
  109. End Sub
  110. Private Sub List1_Click()
  111.     Dim dl&
  112.     Dim selloc&
  113.     Dim resbuf$
  114.     List2.Clear
  115.     If List1.ListIndex >= 0 Then
  116.         selloc& = Val("&H" & List1.Text)
  117.     Else
  118.         selloc& = LOCALE_SYSTEM_DEFAULT
  119.     End If
  120.     dl& = EnumCalendarInfo(AddressOf Callback2_EnumFormats, selloc, ENUM_ALL_CALENDARS, CAL_SCALNAME)
  121.     dl& = EnumDateFormats(AddressOf Callback2_EnumFormats, selloc, DATE_LONGDATE)
  122.     resbuf$ = String$(50, 0)
  123.     dl& = GetCurrencyFormatBynum(selloc&, 0, "2423.22", 0, resbuf$, 49)
  124.     If dl& > 0 Then List2.AddItem Left$(resbuf$, dl&)
  125. End Sub
  126.