win 0.3.24 → 0.3.25

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY CHANGED
@@ -90,3 +90,7 @@
90
90
  == 0.3.24 / 2010-06-21
91
91
 
92
92
  * Menu::DeleteMenu function added
93
+
94
+ == 0.3.25 / 2010-10-17
95
+
96
+ * Minor refactoring
data/README.rdoc CHANGED
@@ -1,9 +1,8 @@
1
1
  = win
2
+ by: Arvicco
3
+ url: http://github.com/arvicco/win
2
4
 
3
- by: Arvicco
4
- url: http://github.com/arvicco/win
5
-
6
- == DESCRIPTION
5
+ == SUMMARY
7
6
 
8
7
  A collection of Windows API functions predefined for you using FFI. In addition to
9
8
  straightforward (CamelCase) API wrappers, it also strives to provide more Ruby-like
@@ -12,7 +11,7 @@ sensible return values (false/true instead of 0/nonzero for test functions, etc)
12
11
 
13
12
  This is still work in progress, only a small portion of Windows API wrapped so far...
14
13
 
15
- == SUMMARY
14
+ == DESCRIPTION
16
15
 
17
16
  So you want to write a simple program that makes some Windows API function calls.
18
17
  You searched MSDN high and low and you know exactly what functions you need.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.24
1
+ 0.3.25
data/lib/win.rb CHANGED
@@ -19,5 +19,5 @@ end # module WinGui
19
19
 
20
20
  # Require all ruby source files located under directory lib/win_gui
21
21
  # If you need files in specific order, you should specify it here before the glob
22
- WinGui.require_libs %W[**/*]
22
+ Win.require_libs %W[**/*]
23
23
 
data/lib/win/gui/menu.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'win/library'
2
2
  #require 'win/gui/window'
3
- #require 'win/gui/message' # needed because SC_... constants defined there
3
+ #require 'win/gui/message' # needed because of SC_... constants defined there ?
4
4
 
5
5
  module Win
6
6
  module Gui
@@ -438,7 +438,39 @@ module Win
438
438
  # :call-seq:
439
439
  # menu_handle = create_menu()
440
440
  #
441
- function :CreateMenu, [], :HMENU
441
+ function :CreateMenu, [], :HMENU, fails: 0
442
+
443
+ ##
444
+ # The CreatePopupMenu function creates a drop-down menu, submenu, or shortcut menu. The menu is
445
+ # initially empty. You can insert or append menu items by using the InsertMenuItem function. You can
446
+ # also use the InsertMenu function to insert menu items and the AppendMenu function to append menu items.
447
+ #
448
+ # [*Syntax*] HMENU CreatePopupMenu( void );
449
+ #
450
+ # *Returns*:: If the function succeeds, the return value is a handle to the newly created menu.
451
+ # If the function fails, the return value is NULL. To get extended error information, call GetLastError.
452
+ # ---
453
+ # *Remarks*:
454
+ # The application can add the new menu to an existing menu, or it can display a shortcut menu by calling
455
+ # the TrackPopupMenuEx or TrackPopupMenu functions.
456
+ # Resources associated with a menu that is assigned to a window are freed automatically. If the menu is
457
+ # not assigned to a window, an application must free system resources associated with the menu before
458
+ # closing. An application frees menu resources by calling the DestroyMenu function.
459
+ # ---
460
+ # Minimum DLL Version user32.dll
461
+ # Header Declared in Winuser.h, include Windows.h
462
+ # Import library User32.lib
463
+ # Minimum operating systems Windows 95, Windows NT 3.1
464
+ # Unicode Implemented as Unicode version.
465
+ # ---
466
+ # *See* *Also*:
467
+ # AppendMenu, CreateMenu, DestroyMenu, InsertMenu, SetMenu, TrackPopupMenu, TrackPopupMenuEx, InsertMenuItem
468
+ #
469
+ # :call-seq:
470
+ # success = create_popup_menu()
471
+ #
472
+ function :CreatePopupMenu, [], :HMENU, fails: 0
473
+
442
474
 
443
475
  ##
444
476
  # The DestroyMenu function destroys the specified menu and frees any memory that the menu occupies.
@@ -709,7 +741,6 @@ module Win
709
741
 
710
742
  function :CheckMenuItem, 'LII', 'L'
711
743
  function :CheckMenuRadioItem, 'LIIII', :int8, boolean: true
712
- function :CreatePopupMenu, [], 'L'
713
744
  function :DrawMenuBar, 'L', :int8, boolean: true
714
745
  function :EnableMenuItem, 'LII', :int8, boolean: true
715
746
  function :EndMenu, [], :int8, boolean: true
@@ -425,7 +425,6 @@ module Win
425
425
  &->(api, handle, msg, w_param, l_param, data=0, &block){
426
426
  api.call(handle, msg, w_param, l_param, block, data)}
427
427
 
428
-
429
428
  ##
430
429
  # The PostMessage function places (posts) a message in the message queue associated with the thread that
431
430
  # created the specified window and returns without waiting for the thread to process the message.
@@ -800,5 +799,4 @@ module Win
800
799
  function :WaitMessage, 'V', 'B'
801
800
  end
802
801
  end
803
- end
804
-
802
+ end
@@ -189,7 +189,7 @@ module Win
189
189
  # the return value is *true*. If the window is not a child or descendant window of
190
190
  # the specified parent window, the return value is *false*.
191
191
  # :call-seq:
192
- # child?( win_handle )
192
+ # child?( parent_handle, win_handle )
193
193
  #
194
194
  function :IsChild, [:HWND, :HWND], :int, boolean: true
195
195
 
data/lib/win/library.rb CHANGED
@@ -242,12 +242,12 @@ module Win
242
242
  UNICODE_STRING: :pointer, # Pointer to some string structure??
243
243
  USHORT: :ushort, # Unsigned SHORT. The range is 0 through 65535 decimal.
244
244
  USN: :ulong_long, # Update sequence number (USN).
245
- VOID: [], # Any type ? Only use it to indicate no arguments or no return value
246
245
  WCHAR: :ushort, # 16-bit Unicode character. For more information, see Character Sets Used By Fonts.
247
246
  # In WinNT.h: typedef wchar_t WCHAR;
248
247
  #WINAPI: K, # Calling convention for system functions. WinDef.h: define WINAPI __stdcall
249
248
  WORD: :ushort, # 16-bit unsigned integer. The range is 0 through 65535 decimal.
250
- WPARAM: :uint # Message parameter. WinDef.h as follows: typedef UINT_PTR WPARAM;
249
+ WPARAM: :uint, # Message parameter. WinDef.h as follows: typedef UINT_PTR WPARAM;
250
+ VOID: [], # Any type ? Only use it to indicate no arguments or no return value
251
251
  }
252
252
 
253
253
  ##
@@ -259,7 +259,7 @@ module Win
259
259
  # and (optionally) transforms the result before returning it. If a block is attached to
260
260
  # method invocation, raw result is yielded to this block before final transformation take place
261
261
  # - Defines aliases for enhanced method with more Rubyesque names for getters, setters and tests:
262
- # GetWindowText -> window_test, SetWindowText -> window_text=, IsZoomed -> zoomed?
262
+ # GetWindowText -> window_text, SetWindowText -> window_text=, IsZoomed -> zoomed?
263
263
  # ---
264
264
  # You may modify default behavior of defined method by providing optional *def_block* to function definition.
265
265
  # If you do so, snake_case method is defined based on your *def_block*. It receives callable API
@@ -282,6 +282,7 @@ module Win
282
282
  # :alias(es):: Provides additional alias(es) for defined method
283
283
  # :boolean:: Forces method to return true/false instead of nonzero/zero
284
284
  # :fails:: Forces method to return nil if function result is equal to following error code
285
+ # :alternative:: Alternative signature for this function
285
286
  #
286
287
  def function(name, params, returns, options={}, &def_block)
287
288
  snake_name, camel_name, effective_names, aliases = generate_names(name, options)
@@ -297,7 +298,7 @@ module Win
297
298
  #
298
299
  def try_function(name, params, returns, options={}, &def_block)
299
300
  begin
300
- function name, params, returns, options={}, &def_block
301
+ function name, params, returns, options, &def_block
301
302
  rescue Win::Errors::NotFoundError
302
303
  "This platform does not support function #{name}"
303
304
  end
@@ -359,7 +360,11 @@ module Win
359
360
  public snake_name
360
361
 
361
362
  # Define (instance method!) aliases, if any
362
- aliases.each {|ali| alias_method ali, snake_name }
363
+ aliases.each do |ali|
364
+ alias_method ali, snake_name
365
+ module_function ali
366
+ public ali
367
+ end
363
368
  end
364
369
 
365
370
  # Generates possible effective names for function in Win32 dll (name+A/W),
@@ -0,0 +1,585 @@
1
+ require 'win/library'
2
+
3
+ module Win
4
+
5
+ # Contains various functions and constants related to LOCALE and TIME ZONES.
6
+ #
7
+ module National
8
+ extend Win::Library
9
+ # Code page identifiers. Used for get_acp_string method.
10
+ CODE_PAGE = {
11
+ 037 => 'IBM EBCDIC = U.S./Canada',
12
+ 437 => 'OEM = United States',
13
+ 500 => 'IBM EBCDIC - International',
14
+ 708 => 'Arabic - ASMO 708',
15
+ 709 => 'Arabic - ASMO 449+, BCON V4',
16
+ 710 => 'Arabic - Transparent Arabic',
17
+ 720 => 'Arabic - Transparent ASMO',
18
+ 737 => 'OEM - Greek (formerly 437G)',
19
+ 775 => 'OEM - Baltic',
20
+ 850 => 'OEM - Multilingual Latin I',
21
+ 852 => 'OEM - Latin II',
22
+ 855 => 'OEM - Cyrillic (primarily Russian)',
23
+ 857 => 'OEM - Turkish',
24
+ 858 => 'OEM - Multilingual Latin I + Euro symbol',
25
+ 860 => 'OEM - Portuguese',
26
+ 861 => 'OEM - Icelandic',
27
+ 862 => 'OEM - Hebrew',
28
+ 863 => 'OEM - Canadian-French',
29
+ 864 => 'OEM - Arabic',
30
+ 865 => 'OEM - Nordic',
31
+ 866 => 'OEM - Russian',
32
+ 869 => 'OEM - Modern Greek',
33
+ 870 => 'IBM EBCDIC - Multilingual/ROECE (Latin-2)',
34
+ 874 => 'ANSI/OEM - Thai (same as 28605, ISO 8859-15)',
35
+ 875 => 'IBM EBCDIC - Modern Greek',
36
+ 932 => 'ANSI/OEM - Japanese, Shift-JIS',
37
+ 936 => 'ANSI/OEM - Simplified Chinese (PRC, Singapore)',
38
+ 949 => 'ANSI/OEM - Korean (Unified Hangul Code)',
39
+ 950 => 'ANSI/OEM - Traditional Chinese (Taiwan; Hong Kong SAR, PRC)',
40
+ 1026 => 'IBM EBCDIC - Turkish (Latin-5)',
41
+ 1047 => 'IBM EBCDIC - Latin 1/Open System',
42
+ 1140 => 'IBM EBCDIC - U.S./Canada (037 + Euro symbol)',
43
+ 1141 => 'IBM EBCDIC - Germany (20273 + Euro symbol)',
44
+ 1142 => 'IBM EBCDIC - Denmark/Norway (20277 + Euro symbol)',
45
+ 1143 => 'IBM EBCDIC - Finland/Sweden (20278 + Euro symbol)',
46
+ 1144 => 'IBM EBCDIC - Italy (20280 + Euro symbol)',
47
+ 1145 => 'IBM EBCDIC - Latin America/Spain (20284 + Euro symbol)',
48
+ 1146 => 'IBM EBCDIC - United Kingdom (20285 + Euro symbol)',
49
+ 1147 => 'IBM EBCDIC - France (20297 + Euro symbol)',
50
+ 1148 => 'IBM EBCDIC - International (500 + Euro symbol)',
51
+ 1149 => 'IBM EBCDIC - Icelandic (20871 + Euro symbol)',
52
+ 1200 => 'Unicode UCS-2 Little-Endian (BMP of ISO 10646)',
53
+ 1201 => 'Unicode UCS-2 Big-Endian',
54
+ 1250 => 'ANSI - Central European',
55
+ 1251 => 'ANSI - Cyrillic',
56
+ 1252 => 'ANSI - Latin I',
57
+ 1253 => 'ANSI - Greek',
58
+ 1254 => 'ANSI - Turkish',
59
+ 1255 => 'ANSI - Hebrew',
60
+ 1256 => 'ANSI - Arabic',
61
+ 1257 => 'ANSI - Baltic',
62
+ 1258 => 'ANSI/OEM - Vietnamese',
63
+ 1361 => 'Korean (Johab)',
64
+ 10000 => 'MAC - Roman',
65
+ 10001 => 'MAC - Japanese',
66
+ 10002 => 'MAC - Traditional Chinese (Big5)',
67
+ 10003 => 'MAC - Korean',
68
+ 10004 => 'MAC - Arabic',
69
+ 10005 => 'MAC - Hebrew',
70
+ 10006 => 'MAC - Greek I',
71
+ 10007 => 'MAC - Cyrillic',
72
+ 10008 => 'MAC - Simplified Chinese (GB 2312)',
73
+ 10010 => 'MAC - Romania',
74
+ 10017 => 'MAC - Ukraine',
75
+ 10021 => 'MAC - Thai',
76
+ 10029 => 'MAC - Latin II',
77
+ 10079 => 'MAC - Icelandic',
78
+ 10081 => 'MAC - Turkish',
79
+ 10082 => 'MAC - Croatia',
80
+ 12000 => 'Unicode UCS-4 Little-Endian',
81
+ 12001 => 'Unicode UCS-4 Big-Endian',
82
+ 20000 => 'CNS - Taiwan',
83
+ 20001 => 'TCA - Taiwan',
84
+ 20002 => 'Eten - Taiwan',
85
+ 20003 => 'IBM5550 - Taiwan',
86
+ 20004 => 'TeleText - Taiwan',
87
+ 20005 => 'Wang - Taiwan',
88
+ 20105 => 'IA5 IRV International Alphabet No. 5 (7-bit)',
89
+ 20106 => 'IA5 German (7-bit)',
90
+ 20107 => 'IA5 Swedish (7-bit)',
91
+ 20108 => 'IA5 Norwegian (7-bit)',
92
+ 20127 => 'US-ASCII (7-bit)',
93
+ 20261 => 'T.61',
94
+ 20269 => 'ISO 6937 Non-Spacing Accent',
95
+ 20273 => 'IBM EBCDIC - Germany',
96
+ 20277 => 'IBM EBCDIC - Denmark/Norway',
97
+ 20278 => 'IBM EBCDIC - Finland/Sweden',
98
+ 20280 => 'IBM EBCDIC - Italy',
99
+ 20284 => 'IBM EBCDIC - Latin America/Spain',
100
+ 20285 => 'IBM EBCDIC - United Kingdom',
101
+ 20290 => 'IBM EBCDIC - Japanese Katakana Extended',
102
+ 20297 => 'IBM EBCDIC - France',
103
+ 20420 => 'IBM EBCDIC - Arabic',
104
+ 20423 => 'IBM EBCDIC - Greek',
105
+ 20424 => 'IBM EBCDIC - Hebrew',
106
+ 20833 => 'IBM EBCDIC - Korean Extended',
107
+ 20838 => 'IBM EBCDIC - Thai',
108
+ 20866 => 'Russian - KOI8-R',
109
+ 20871 => 'IBM EBCDIC - Icelandic',
110
+ 20880 => 'IBM EBCDIC - Cyrillic (Russian)',
111
+ 20905 => 'IBM EBCDIC - Turkish',
112
+ 20924 => 'IBM EBCDIC - Latin-1/Open System (1047 + Euro symbol)',
113
+ 20932 => 'JIS X 0208-1990 & 0121-1990',
114
+ 20936 => 'Simplified Chinese (GB2312)',
115
+ 21025 => 'IBM EBCDIC - Cyrillic (Serbian, Bulgarian)',
116
+ 21027 => '(deprecated)',
117
+ 21866 => 'Ukrainian (KOI8-U)',
118
+ 28591 => 'ISO 8859-1 Latin I',
119
+ 28592 => 'ISO 8859-2 Central Europe',
120
+ 28593 => 'ISO 8859-3 Latin 3',
121
+ 28594 => 'ISO 8859-4 Baltic',
122
+ 28595 => 'ISO 8859-5 Cyrillic',
123
+ 28596 => 'ISO 8859-6 Arabic',
124
+ 28597 => 'ISO 8859-7 Greek',
125
+ 28598 => 'ISO 8859-8 Hebrew',
126
+ 28599 => 'ISO 8859-9 Latin 5',
127
+ 28605 => 'ISO 8859-15 Latin 9',
128
+ 29001 => 'Europa 3',
129
+ 38598 => 'ISO 8859-8 Hebrew',
130
+ 50220 => 'ISO 2022 Japanese with no halfwidth Katakana',
131
+ 50221 => 'ISO 2022 Japanese with halfwidth Katakana',
132
+ 50222 => 'ISO 2022 Japanese JIS X 0201-1989',
133
+ 50225 => 'ISO 2022 Korean',
134
+ 50227 => 'ISO 2022 Simplified Chinese',
135
+ 50229 => 'ISO 2022 Traditional Chinese',
136
+ 50930 => 'Japanese (Katakana) Extended',
137
+ 50931 => 'US/Canada and Japanese',
138
+ 50933 => 'Korean Extended and Korean',
139
+ 50935 => 'Simplified Chinese Extended and Simplified Chinese',
140
+ 50936 => 'Simplified Chinese',
141
+ 50937 => 'US/Canada and Traditional Chinese',
142
+ 50939 => 'Japanese (Latin) Extended and Japanese',
143
+ 51932 => 'EUC - Japanese',
144
+ 51936 => 'EUC - Simplified Chinese',
145
+ 51949 => 'EUC - Korean',
146
+ 51950 => 'EUC - Traditional Chinese',
147
+ 52936 => 'HZ-GB2312 Simplified Chinese',
148
+ 54936 => 'Windows XP: GB18030 Simplified Chinese (4 Byte)',
149
+ 57002 => 'ISCII Devanagari',
150
+ 57003 => 'ISCII Bengali',
151
+ 57004 => 'ISCII Tamil',
152
+ 57005 => 'ISCII Telugu',
153
+ 57006 => 'ISCII Assamese',
154
+ 57007 => 'ISCII Oriya',
155
+ 57008 => 'ISCII Kannada',
156
+ 57009 => 'ISCII Malayalam',
157
+ 57010 => 'ISCII Gujarati',
158
+ 57011 => 'ISCII Punjabi',
159
+ 65000 => 'Unicode UTF-7',
160
+ 65001 => 'Unicode UTF-8'
161
+ }
162
+
163
+ LANG_NEUTRAL = 0x00
164
+ LANG_INVARIANT = 0x7f
165
+
166
+ LANG_AFRIKAANS = 0x36
167
+ LANG_ALBANIAN = 0x1c
168
+ LANG_ARABIC = 0x01
169
+ LANG_ARMENIAN = 0x2b
170
+ LANG_ASSAMESE = 0x4d
171
+ LANG_AZERI = 0x2c
172
+ LANG_BASQUE = 0x2d
173
+ LANG_BELARUSIAN = 0x23
174
+ LANG_BENGALI = 0x45
175
+ LANG_BOSNIAN = 0x1a
176
+ LANG_BULGARIAN = 0x02
177
+ LANG_CATALAN = 0x03
178
+ LANG_CHINESE = 0x04
179
+ LANG_CROATIAN = 0x1a
180
+ LANG_CZECH = 0x05
181
+ LANG_DANISH = 0x06
182
+ LANG_DIVEHI = 0x65
183
+ LANG_DUTCH = 0x13
184
+ LANG_ENGLISH = 0x09
185
+ LANG_ESTONIAN = 0x25
186
+ LANG_FAEROESE = 0x38
187
+ LANG_FARSI = 0x29
188
+ LANG_FINNISH = 0x0b
189
+ LANG_FRENCH = 0x0c
190
+ LANG_GALICIAN = 0x56
191
+ LANG_GEORGIAN = 0x37
192
+ LANG_GERMAN = 0x07
193
+ LANG_GREEK = 0x08
194
+ LANG_GUJARATI = 0x47
195
+ LANG_HEBREW = 0x0d
196
+ LANG_HINDI = 0x39
197
+ LANG_HUNGARIAN = 0x0e
198
+ LANG_ICELANDIC = 0x0f
199
+ LANG_INDONESIAN = 0x21
200
+ LANG_ITALIAN = 0x10
201
+ LANG_JAPANESE = 0x11
202
+ LANG_KANNADA = 0x4b
203
+ LANG_KASHMIRI = 0x60
204
+ LANG_KAZAK = 0x3f
205
+ LANG_KONKANI = 0x57
206
+ LANG_KOREAN = 0x12
207
+ LANG_KYRGYZ = 0x40
208
+ LANG_LATVIAN = 0x26
209
+ LANG_LITHUANIAN = 0x27
210
+ LANG_MACEDONIAN = 0x2f
211
+ LANG_MALAY = 0x3e
212
+ LANG_MALAYALAM = 0x4c
213
+ LANG_MALTESE = 0x3a
214
+ LANG_MANIPURI = 0x58
215
+ LANG_MAORI = 0x81
216
+ LANG_MARATHI = 0x4e
217
+ LANG_MONGOLIAN = 0x50
218
+ LANG_NEPALI = 0x61
219
+ LANG_NORWEGIAN = 0x14
220
+ LANG_ORIYA = 0x48
221
+ LANG_POLISH = 0x15
222
+ LANG_PORTUGUESE = 0x16
223
+ LANG_PUNJABI = 0x46
224
+ LANG_QUECHUA = 0x6b
225
+ LANG_ROMANIAN = 0x18
226
+ LANG_RUSSIAN = 0x19
227
+ LANG_SAMI = 0x3b
228
+ LANG_SANSKRIT = 0x4f
229
+ LANG_SERBIAN = 0x1a
230
+ LANG_SINDHI = 0x59
231
+ LANG_SLOVAK = 0x1b
232
+ LANG_SLOVENIAN = 0x24
233
+ LANG_SOTHO = 0x6c
234
+ LANG_SPANISH = 0x0a
235
+ LANG_SWAHILI = 0x41
236
+ LANG_SWEDISH = 0x1d
237
+ LANG_SYRIAC = 0x5a
238
+ LANG_TAMIL = 0x49
239
+ LANG_TATAR = 0x44
240
+ LANG_TELUGU = 0x4a
241
+ LANG_THAI = 0x1e
242
+ LANG_TSWANA = 0x32
243
+ LANG_TURKISH = 0x1f
244
+ LANG_UKRAINIAN = 0x22
245
+ LANG_URDU = 0x20
246
+ LANG_UZBEK = 0x43
247
+ LANG_VIETNAMESE = 0x2a
248
+ LANG_WELSH = 0x52
249
+ LANG_XHOSA = 0x34
250
+ LANG_ZULU = 0x35
251
+
252
+ SUBLANG_NEUTRAL = 0x00 # language neutral
253
+ SUBLANG_DEFAULT = 0x01 # user default
254
+ SUBLANG_SYS_DEFAULT = 0x02 # system default
255
+
256
+ SUBLANG_ARABIC_SAUDI_ARABIA = 0x01 # Arabic (Saudi Arabia)
257
+ SUBLANG_ARABIC_IRAQ = 0x02 # Arabic (Iraq)
258
+ SUBLANG_ARABIC_EGYPT = 0x03 # Arabic (Egypt)
259
+ SUBLANG_ARABIC_LIBYA = 0x04 # Arabic (Libya)
260
+ SUBLANG_ARABIC_ALGERIA = 0x05 # Arabic (Algeria)
261
+ SUBLANG_ARABIC_MOROCCO = 0x06 # Arabic (Morocco)
262
+ SUBLANG_ARABIC_TUNISIA = 0x07 # Arabic (Tunisia)
263
+ SUBLANG_ARABIC_OMAN = 0x08 # Arabic (Oman)
264
+ SUBLANG_ARABIC_YEMEN = 0x09 # Arabic (Yemen)
265
+ SUBLANG_ARABIC_SYRIA = 0x0a # Arabic (Syria)
266
+ SUBLANG_ARABIC_JORDAN = 0x0b # Arabic (Jordan)
267
+ SUBLANG_ARABIC_LEBANON = 0x0c # Arabic (Lebanon)
268
+ SUBLANG_ARABIC_KUWAIT = 0x0d # Arabic (Kuwait)
269
+ SUBLANG_ARABIC_UAE = 0x0e # Arabic (U.A.E)
270
+ SUBLANG_ARABIC_BAHRAIN = 0x0f # Arabic (Bahrain)
271
+ SUBLANG_ARABIC_QATAR = 0x10 # Arabic (Qatar)
272
+ SUBLANG_AZERI_LATIN = 0x01 # Azeri (Latin)
273
+ SUBLANG_AZERI_CYRILLIC = 0x02 # Azeri (Cyrillic)
274
+ SUBLANG_CHINESE_TRADITIONAL = 0x01 # Chinese (Taiwan)
275
+ SUBLANG_CHINESE_SIMPLIFIED = 0x02 # Chinese (PR China)
276
+ SUBLANG_CHINESE_HONGKONG = 0x03 # Chinese (Hong Kong S.A.R., P.R.C.)
277
+ SUBLANG_CHINESE_SINGAPORE = 0x04 # Chinese (Singapore)
278
+ SUBLANG_CHINESE_MACAU = 0x05 # Chinese (Macau S.A.R.)
279
+ SUBLANG_CROATIAN_CROATIA = 0x01 # Croatian (Croatia)
280
+ SUBLANG_DUTCH = 0x01 # Dutch
281
+ SUBLANG_DUTCH_BELGIAN = 0x02 # Dutch (Belgian)
282
+ SUBLANG_ENGLISH_US = 0x01 # English (USA)
283
+ SUBLANG_ENGLISH_UK = 0x02 # English (UK)
284
+ SUBLANG_ENGLISH_AUS = 0x03 # English (Australian)
285
+ SUBLANG_ENGLISH_CAN = 0x04 # English (Canadian)
286
+ SUBLANG_ENGLISH_NZ = 0x05 # English (New Zealand)
287
+ SUBLANG_ENGLISH_EIRE = 0x06 # English (Irish)
288
+ SUBLANG_ENGLISH_SOUTH_AFRICA = 0x07 # English (South Africa)
289
+ SUBLANG_ENGLISH_JAMAICA = 0x08 # English (Jamaica)
290
+ SUBLANG_ENGLISH_CARIBBEAN = 0x09 # English (Caribbean)
291
+ SUBLANG_ENGLISH_BELIZE = 0x0a # English (Belize)
292
+ SUBLANG_ENGLISH_TRINIDAD = 0x0b # English (Trinidad)
293
+ SUBLANG_ENGLISH_ZIMBABWE = 0x0c # English (Zimbabwe)
294
+ SUBLANG_ENGLISH_PHILIPPINES = 0x0d # English (Philippines)
295
+ SUBLANG_FRENCH = 0x01 # French
296
+ SUBLANG_FRENCH_BELGIAN = 0x02 # French (Belgian)
297
+ SUBLANG_FRENCH_CANADIAN = 0x03 # French (Canadian)
298
+ SUBLANG_FRENCH_SWISS = 0x04 # French (Swiss)
299
+ SUBLANG_FRENCH_LUXEMBOURG = 0x05 # French (Luxembourg)
300
+ SUBLANG_FRENCH_MONACO = 0x06 # French (Monaco)
301
+ SUBLANG_GERMAN = 0x01 # German
302
+ SUBLANG_GERMAN_SWISS = 0x02 # German (Swiss)
303
+ SUBLANG_GERMAN_AUSTRIAN = 0x03 # German (Austrian)
304
+ SUBLANG_GERMAN_LUXEMBOURG = 0x04 # German (Luxembourg)
305
+ SUBLANG_GERMAN_LIECHTENSTEIN = 0x05 # German (Liechtenstein)
306
+ SUBLANG_ITALIAN = 0x01 # Italian
307
+ SUBLANG_ITALIAN_SWISS = 0x02 # Italian (Swiss)
308
+ SUBLANG_KASHMIRI_SASIA = 0x02 # Kashmiri (South Asia)
309
+ SUBLANG_KASHMIRI_INDIA = 0x02 # For app compatibility only
310
+ SUBLANG_KOREAN = 0x01 # Korean (Extended Wansung)
311
+ SUBLANG_LITHUANIAN = 0x01 # Lithuanian
312
+ SUBLANG_MALAY_MALAYSIA = 0x01 # Malay (Malaysia)
313
+ SUBLANG_MALAY_BRUNEI_DARUSSALAM = 0x02 # Malay (Brunei Darussalam)
314
+ SUBLANG_NEPALI_INDIA = 0x02 # Nepali (India)
315
+ SUBLANG_NORWEGIAN_BOKMAL = 0x01 # Norwegian (Bokmal)
316
+ SUBLANG_NORWEGIAN_NYNORSK = 0x02 # Norwegian (Nynorsk)
317
+ SUBLANG_PORTUGUESE = 0x02 # Portuguese
318
+ SUBLANG_PORTUGUESE_BRAZILIAN = 0x01 # Portuguese (Brazilian)
319
+ SUBLANG_QUECHUA_BOLIVIA = 0x01 # Quechua (Bolivia)
320
+ SUBLANG_QUECHUA_ECUADOR = 0x02 # Quechua (Ecuador)
321
+ SUBLANG_QUECHUA_PERU = 0x03 # Quechua (Peru)
322
+ SUBLANG_SAMI_NORTHERN_NORWAY = 0x01 # Northern Sami (Norway)
323
+ SUBLANG_SAMI_NORTHERN_SWEDEN = 0x02 # Northern Sami (Sweden)
324
+ SUBLANG_SAMI_NORTHERN_FINLAND = 0x03 # Northern Sami (Finland)
325
+ SUBLANG_SAMI_LULE_NORWAY = 0x04 # Lule Sami (Norway)
326
+ SUBLANG_SAMI_LULE_SWEDEN = 0x05 # Lule Sami (Sweden)
327
+ SUBLANG_SAMI_SOUTHERN_NORWAY = 0x06 # Southern Sami (Norway)
328
+ SUBLANG_SAMI_SOUTHERN_SWEDEN = 0x07 # Southern Sami (Sweden)
329
+ SUBLANG_SAMI_SKOLT_FINLAND = 0x08 # Skolt Sami (Finland)
330
+ SUBLANG_SAMI_INARI_FINLAND = 0x09 # Inari Sami (Finland)
331
+ SUBLANG_SERBIAN_LATIN = 0x02 # Serbian (Latin)
332
+ SUBLANG_SERBIAN_CYRILLIC = 0x03 # Serbian (Cyrillic)
333
+ SUBLANG_SPANISH = 0x01 # Spanish (Castilian)
334
+ SUBLANG_SPANISH_MEXICAN = 0x02 # Spanish (Mexican)
335
+ SUBLANG_SPANISH_MODERN = 0x03 # Spanish (Modern)
336
+ SUBLANG_SPANISH_GUATEMALA = 0x04 # Spanish (Guatemala)
337
+ SUBLANG_SPANISH_COSTA_RICA = 0x05 # Spanish (Costa Rica)
338
+ SUBLANG_SPANISH_PANAMA = 0x06 # Spanish (Panama)
339
+ SUBLANG_SPANISH_VENEZUELA = 0x08 # Spanish (Venezuela)
340
+ SUBLANG_SPANISH_COLOMBIA = 0x09 # Spanish (Colombia)
341
+ SUBLANG_SPANISH_PERU = 0x0a # Spanish (Peru)
342
+ SUBLANG_SPANISH_ARGENTINA = 0x0b # Spanish (Argentina)
343
+ SUBLANG_SPANISH_ECUADOR = 0x0c # Spanish (Ecuador)
344
+ SUBLANG_SPANISH_CHILE = 0x0d # Spanish (Chile)
345
+ SUBLANG_SPANISH_URUGUAY = 0x0e # Spanish (Uruguay)
346
+ SUBLANG_SPANISH_PARAGUAY = 0x0f # Spanish (Paraguay)
347
+ SUBLANG_SPANISH_BOLIVIA = 0x10 # Spanish (Bolivia)
348
+ SUBLANG_SPANISH_EL_SALVADOR = 0x11 # Spanish (El Salvador)
349
+ SUBLANG_SPANISH_HONDURAS = 0x12 # Spanish (Honduras)
350
+ SUBLANG_SPANISH_NICARAGUA = 0x13 # Spanish (Nicaragua)
351
+ SUBLANG_SPANISH_PUERTO_RICO = 0x14 # Spanish (Puerto Rico)
352
+ SUBLANG_SWEDISH = 0x01 # Swedish
353
+ SUBLANG_SWEDISH_FINLAND = 0x02 # Swedish (Finland)
354
+ SUBLANG_URDU_PAKISTAN = 0x01 # Urdu (Pakistan)
355
+ SUBLANG_URDU_INDIA = 0x02 # Urdu (India)
356
+ SUBLANG_UZBEK_LATIN = 0x01 # Uzbek (Latin)
357
+ SUBLANG_UZBEK_CYRILLIC = 0x02 # Uzbek (Cyrillic)
358
+
359
+ LOCALE_NOUSEROVERRIDE = 0x80000000
360
+ LOCALE_USE_CP_ACP = 0x40000000
361
+ LOCALE_RETURN_NUMBER = 0x20000000
362
+
363
+ LOCALE_ILANGUAGE = 0x00000001 # Language ID
364
+ LOCALE_SLANGUAGE = 0x00000002 # Localized name of language
365
+ LOCALE_SENGLANGUAGE = 0x00001001 # English name of language
366
+ LOCALE_SABBREVLANGNAME = 0x00000003 # Abbreviated language name
367
+ LOCALE_SNATIVELANGNAME = 0x00000004 # Native name of language
368
+
369
+ LOCALE_ICOUNTRY = 0x00000005 # Country code
370
+ LOCALE_SCOUNTRY = 0x00000006 # Localized name of country
371
+ LOCALE_SENGCOUNTRY = 0x00001002 # English name of country
372
+ LOCALE_SABBREVCTRYNAME = 0x00000007 # Abbreviated country name
373
+ LOCALE_SNATIVECTRYNAME = 0x00000008 # Native name of country
374
+
375
+ LOCALE_IDEFAULTLANGUAGE = 0x00000009 # default language id
376
+ LOCALE_IDEFAULTCOUNTRY = 0x0000000A # default country code
377
+ LOCALE_IDEFAULTCODEPAGE = 0x0000000B # default oem code page
378
+ LOCALE_IDEFAULTANSICODEPAGE = 0x00001004 # default ansi code page
379
+ LOCALE_IDEFAULTMACCODEPAGE = 0x00001011 # default mac code page
380
+
381
+ LOCALE_SLIST = 0x0000000C # list item separator
382
+ LOCALE_IMEASURE = 0x0000000D # 0 = metric, 1 = US
383
+
384
+ LOCALE_SDECIMAL = 0x0000000E # decimal separator
385
+ LOCALE_STHOUSAND = 0x0000000F # thousand separator
386
+ LOCALE_SGROUPING = 0x00000010 # digit grouping
387
+ LOCALE_IDIGITS = 0x00000011 # number of fractional digits
388
+ LOCALE_ILZERO = 0x00000012 # leading zeros for decimal
389
+ LOCALE_INEGNUMBER = 0x00001010 # negative number mode
390
+ LOCALE_SNATIVEDIGITS = 0x00000013 # native ascii 0-9
391
+
392
+ LOCALE_SCURRENCY = 0x00000014 # local monetary symbol
393
+ LOCALE_SINTLSYMBOL = 0x00000015 # intl monetary symbol
394
+ LOCALE_SMONDECIMALSEP = 0x00000016 # monetary decimal separator
395
+ LOCALE_SMONTHOUSANDSEP = 0x00000017 # monetary thousand separator
396
+ LOCALE_SMONGROUPING = 0x00000018 # monetary grouping
397
+ LOCALE_ICURRDIGITS = 0x00000019 # # local monetary digits
398
+ LOCALE_IINTLCURRDIGITS = 0x0000001A # # intl monetary digits
399
+ LOCALE_ICURRENCY = 0x0000001B # positive currency mode
400
+ LOCALE_INEGCURR = 0x0000001C # negative currency mode
401
+
402
+ LOCALE_SDATE = 0x0000001D # date separator
403
+ LOCALE_STIME = 0x0000001E # time separator
404
+ LOCALE_SSHORTDATE = 0x0000001F # short date format string
405
+ LOCALE_SLONGDATE = 0x00000020 # long date format string
406
+ LOCALE_STIMEFORMAT = 0x00001003 # time format string
407
+ LOCALE_IDATE = 0x00000021 # short date format ordering
408
+ LOCALE_ILDATE = 0x00000022 # long date format ordering
409
+ LOCALE_ITIME = 0x00000023 # time format specifier
410
+ LOCALE_ITIMEMARKPOSN = 0x00001005 # time marker position
411
+ LOCALE_ICENTURY = 0x00000024 # century format specifier (short date)
412
+ LOCALE_ITLZERO = 0x00000025 # leading zeros in time field
413
+ LOCALE_IDAYLZERO = 0x00000026 # leading zeros in day field (short date)
414
+ LOCALE_IMONLZERO = 0x00000027 # leading zeros in month field (short date)
415
+ LOCALE_S1159 = 0x00000028 # AM designator
416
+ LOCALE_S2359 = 0x00000029 # PM designator
417
+
418
+ LOCALE_ICALENDARTYPE = 0x00001009 # type of calendar specifier
419
+ LOCALE_IOPTIONALCALENDAR = 0x0000100B # additional calendar types specifier
420
+ LOCALE_IFIRSTDAYOFWEEK = 0x0000100C # first day of week specifier
421
+ LOCALE_IFIRSTWEEKOFYEAR = 0x0000100D # first week of year specifier
422
+
423
+ LOCALE_SDAYNAME1 = 0x0000002A # long name for Monday
424
+ LOCALE_SDAYNAME2 = 0x0000002B # long name for Tuesday
425
+ LOCALE_SDAYNAME3 = 0x0000002C # long name for Wednesday
426
+ LOCALE_SDAYNAME4 = 0x0000002D # long name for Thursday
427
+ LOCALE_SDAYNAME5 = 0x0000002E # long name for Friday
428
+ LOCALE_SDAYNAME6 = 0x0000002F # long name for Saturday
429
+ LOCALE_SDAYNAME7 = 0x00000030 # long name for Sunday
430
+ LOCALE_SABBREVDAYNAME1 = 0x00000031 # abbreviated name for Monday
431
+ LOCALE_SABBREVDAYNAME2 = 0x00000032 # abbreviated name for Tuesday
432
+ LOCALE_SABBREVDAYNAME3 = 0x00000033 # abbreviated name for Wednesday
433
+ LOCALE_SABBREVDAYNAME4 = 0x00000034 # abbreviated name for Thursday
434
+ LOCALE_SABBREVDAYNAME5 = 0x00000035 # abbreviated name for Friday
435
+ LOCALE_SABBREVDAYNAME6 = 0x00000036 # abbreviated name for Saturday
436
+ LOCALE_SABBREVDAYNAME7 = 0x00000037 # abbreviated name for Sunday
437
+ LOCALE_SMONTHNAME1 = 0x00000038 # long name for January
438
+ LOCALE_SMONTHNAME2 = 0x00000039 # long name for February
439
+ LOCALE_SMONTHNAME3 = 0x0000003A # long name for March
440
+ LOCALE_SMONTHNAME4 = 0x0000003B # long name for April
441
+ LOCALE_SMONTHNAME5 = 0x0000003C # long name for May
442
+ LOCALE_SMONTHNAME6 = 0x0000003D # long name for June
443
+ LOCALE_SMONTHNAME7 = 0x0000003E # long name for July
444
+ LOCALE_SMONTHNAME8 = 0x0000003F # long name for August
445
+ LOCALE_SMONTHNAME9 = 0x00000040 # long name for September
446
+ LOCALE_SMONTHNAME10 = 0x00000041 # long name for October
447
+ LOCALE_SMONTHNAME11 = 0x00000042 # long name for November
448
+ LOCALE_SMONTHNAME12 = 0x00000043 # long name for December
449
+ LOCALE_SMONTHNAME13 = 0x0000100E # long name for 13th month (if exists)
450
+ LOCALE_SABBREVMONTHNAME1 = 0x00000044 # abbreviated name for January
451
+ LOCALE_SABBREVMONTHNAME2 = 0x00000045 # abbreviated name for February
452
+ LOCALE_SABBREVMONTHNAME3 = 0x00000046 # abbreviated name for March
453
+ LOCALE_SABBREVMONTHNAME4 = 0x00000047 # abbreviated name for April
454
+ LOCALE_SABBREVMONTHNAME5 = 0x00000048 # abbreviated name for May
455
+ LOCALE_SABBREVMONTHNAME6 = 0x00000049 # abbreviated name for June
456
+ LOCALE_SABBREVMONTHNAME7 = 0x0000004A # abbreviated name for July
457
+ LOCALE_SABBREVMONTHNAME8 = 0x0000004B # abbreviated name for August
458
+ LOCALE_SABBREVMONTHNAME9 = 0x0000004C # abbreviated name for September
459
+ LOCALE_SABBREVMONTHNAME10 = 0x0000004D # abbreviated name for October
460
+ LOCALE_SABBREVMONTHNAME11 = 0x0000004E # abbreviated name for November
461
+ LOCALE_SABBREVMONTHNAME12 = 0x0000004F # abbreviated name for December
462
+ LOCALE_SABBREVMONTHNAME13 = 0x0000100F # abbreviated name for 13th month (if exists)
463
+
464
+ LOCALE_SPOSITIVESIGN = 0x00000050 # positive sign
465
+ LOCALE_SNEGATIVESIGN = 0x00000051 # negative sign
466
+ LOCALE_IPOSSIGNPOSN = 0x00000052 # positive sign position
467
+ LOCALE_INEGSIGNPOSN = 0x00000053 # negative sign position
468
+ LOCALE_IPOSSYMPRECEDES = 0x00000054 # mon sym precedes pos amt
469
+ LOCALE_IPOSSEPBYSPACE = 0x00000055 # mon sym sep by space from pos amt
470
+ LOCALE_INEGSYMPRECEDES = 0x00000056 # mon sym precedes neg amt
471
+ LOCALE_INEGSEPBYSPACE = 0x00000057 # mon sym sep by space from neg amt
472
+
473
+ LOCALE_FONTSIGNATURE = 0x00000058 # font signature
474
+ LOCALE_SISO639LANGNAME = 0x00000059 # ISO abbreviated language name
475
+ LOCALE_SISO3166CTRYNAME = 0x0000005A # ISO abbreviated country name
476
+
477
+ LOCALE_IDEFAULTEBCDICCODEPAGE = 0x00001012 # default ebcdic code page
478
+ LOCALE_IPAPERSIZE = 0x0000100A # 1 = letter, 5 = legal, 8 = a3, 9 = a4
479
+ LOCALE_SENGCURRNAME = 0x00001007 # english name of currency
480
+ LOCALE_SNATIVECURRNAME = 0x00001008 # native name of currency
481
+ LOCALE_SYEARMONTH = 0x00001006 # year month format string
482
+ LOCALE_SSORTNAME = 0x00001013 # sort name
483
+ LOCALE_IDIGITSUBSTITUTION = 0x00001014 # 0 = context, 1 = none, 2 = national
484
+
485
+ TIME_NOMINUTESORSECONDS = 0x00000001 # do not use minutes or seconds
486
+ TIME_NOSECONDS = 0x00000002 # do not use seconds
487
+ TIME_NOTIMEMARKER = 0x00000004 # do not use time marker
488
+ TIME_FORCE24HOURFORMAT = 0x00000008 # always use 24 hour format
489
+
490
+ DATE_SHORTDATE = 0x00000001 # use short date picture
491
+ DATE_LONGDATE = 0x00000002 # use long date picture
492
+ DATE_USE_ALT_CALENDAR = 0x00000004 # use alternate calendar (if any)
493
+
494
+ DATE_YEARMONTH = 0x00000008 # use year month picture
495
+ DATE_LTRREADING = 0x00000010 # add marks for left to right reading order layout
496
+ DATE_RTLREADING = 0x00000020 # add marks for right to left reading order layout
497
+
498
+ SORT_DEFAULT = 0x0 # sorting default
499
+
500
+ SORT_JAPANESE_XJIS = 0x0 # Japanese XJIS order
501
+ SORT_JAPANESE_UNICODE = 0x1 # Japanese Unicode order
502
+
503
+ SORT_CHINESE_BIG5 = 0x0 # Chinese BIG5 order
504
+ SORT_CHINESE_PRCP = 0x0 # PRC Chinese Phonetic order
505
+ SORT_CHINESE_UNICODE = 0x1 # Chinese Unicode order
506
+ SORT_CHINESE_PRC = 0x2 # PRC Chinese Stroke Count order
507
+ SORT_CHINESE_BOPOMOFO = 0x3 # Traditional Chinese Bopomofo order
508
+
509
+ SORT_KOREAN_KSC = 0x0 # Korean KSC order
510
+ SORT_KOREAN_UNICODE = 0x1 # Korean Unicode order
511
+
512
+ SORT_GERMAN_PHONE_BOOK = 0x1 # German Phone Book order
513
+
514
+ SORT_HUNGARIAN_DEFAULT = 0x0 # Hungarian Default order
515
+ SORT_HUNGARIAN_TECHNICAL = 0x1 # Hungarian Technical order
516
+
517
+ SORT_GEORGIAN_TRADITIONAL = 0x0 # Georgian Traditional order
518
+ SORT_GEORGIAN_MODERN = 0x1 # Georgian Modern order
519
+
520
+ LANG_SYSTEM_DEFAULT = 2048
521
+ LANG_USER_DEFAULT = 1024
522
+ LOCALE_SYSTEM_DEFAULT = 2048
523
+ LOCALE_USER_DEFAULT = 1024
524
+ LOCALE_INVARIANT = 8323072
525
+
526
+ # Untested
527
+
528
+ ##
529
+ function :CompareString, 'LLPIPI', 'I'
530
+ ##
531
+ function :GetACP, 'V', 'I'
532
+ ##
533
+ function :GetCPInfo, 'LP', :int8, boolean: true
534
+ ##
535
+ function :GetCPInfoEx, 'LLP', :int8, boolean: true
536
+ ##
537
+ function :GetCurrencyFormat, 'LLPPPI', 'I'
538
+ ##
539
+ function :GetDateFormat, 'LLPPPI', 'I'
540
+ ##
541
+ function :GetLocaleInfo, 'LLPL', 'I'
542
+ ##
543
+ function :GetSystemDefaultLangID, 'V', 'L'
544
+ ##
545
+ function :GetSystemDefaultLCID, 'V', 'L'
546
+ ##
547
+ function :GetUserDefaultLangID, 'V', 'L'
548
+ ##
549
+ function :GetUserDefaultLCID, 'V', 'L'
550
+
551
+ ##
552
+ try_function :AdjustCalendarDate, 'PLP', :int8, boolean: true
553
+ ##
554
+ try_function :GetCurrencyFormatEx, 'PLPPPI', 'I'
555
+ ##
556
+ try_function :GetDateFormatEx, 'SLPSPIS', 'I'
557
+
558
+ # TODO: Define specific callbacks before defining functions (no generic callbacks in FFI)
559
+ # function :EnumDateFormats, 'KLL', :int8, boolean: true
560
+ # function :EnumDateFormatsEx, 'KLL', :int8, boolean: true
561
+ # function :EnumSystemCodePages, 'KL', 'L'
562
+ # function :EnumSystemLocales, 'KL', 'L'
563
+ # function :EnumTimeFormats, 'KLL', :int8, boolean: true
564
+ # try_function :EnumTimeFormatsEx, 'KSLP', :int8, boolean: true
565
+
566
+ # Convenience method for converting the results of the GetACP(
567
+ # function to a human readable string.
568
+ #
569
+ def get_acp_string
570
+ CODE_PAGE[GetACP.call]
571
+ end
572
+
573
+ # Equivalent of the MAKELCID macro in WinNT.h
574
+ #
575
+ def MAKELCID srtid, lgid
576
+ srtid << 16 | lgid
577
+ end
578
+
579
+ # Equivalent of the MAKELANGID macro in WinNT.h
580
+ #
581
+ def MAKELANGID x, s
582
+ s << 10 | x
583
+ end
584
+ end
585
+ end