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 / samples4 / ch06 / ex6b.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-02-16  |  7.7 KB  |  149 lines

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