win32api4ruby 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,389 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ require 'win32api4ruby/base'
4
+
5
+ module Win32api4ruby
6
+ class Gdi < Base
7
+ extend FFI::Library
8
+ ffi_lib 'gdi32'
9
+ ffi_convention :stdcall
10
+
11
+
12
+ R2_BLACK = 1 # 0
13
+ R2_NOTMERGEPEN = 2 # DPon
14
+ R2_MASKNOTPEN = 3 # DPna
15
+ R2_NOTCOPYPEN = 4 # PN
16
+ R2_MASKPENNOT = 5 # PDna
17
+ R2_NOT = 6 # Dn
18
+ R2_XORPEN = 7 # DPx
19
+ R2_NOTMASKPEN = 8 # DPan
20
+ R2_MASKPEN = 9 # DPa
21
+ R2_NOTXORPEN = 10 # DPxn
22
+ R2_NOP = 11 # D
23
+ R2_MERGENOTPEN = 12 # DPno
24
+ R2_COPYPEN = 13 # P
25
+ R2_MERGEPENNOT = 14 # PDno
26
+ R2_MERGEPEN = 15 # DPo
27
+ R2_WHITE = 16 # 1
28
+ R2_LAST = 16
29
+ SRCCOPY = 0x00CC0020 # dest = source
30
+ SRCPAINT = 0x00EE0086 # dest = source OR dest
31
+ SRCAND = 0x008800C6 # dest = source AND dest
32
+ SRCINVERT = 0x00660046 # dest = source XOR dest
33
+ SRCERASE = 0x00440328 # dest = source AND (NOT dest )
34
+ NOTSRCCOPY = 0x00330008 # dest = (NOT source)
35
+ NOTSRCERASE = 0x001100A6 # dest = (NOT src) AND (NOT dest)
36
+ MERGECOPY = 0x00C000CA # dest = (source AND pattern)
37
+ MERGEPAINT = 0x00BB0226 # dest = (NOT source) OR dest
38
+ PATCOPY = 0x00F00021 # dest = pattern
39
+ PATPAINT = 0x00FB0A09 # dest = DPSnoo
40
+ PATINVERT = 0x005A0049 # dest = pattern XOR dest
41
+ DSTINVERT = 0x00550009 # dest = (NOT dest)
42
+ BLACKNESS = 0x00000042 # dest = BLACK
43
+ WHITENESS = 0x00FF0062 # dest = WHITE
44
+ #if(WINVER >= 0x0500)
45
+ NOMIRRORBITMAP = 0x80000000 # Do not Mirror the bitmap in this call
46
+ CAPTUREBLT = 0x40000000 # Include layered windows
47
+ #endif # WINVER >= 0x0500
48
+
49
+ DIB_RGB_COLORS = 0
50
+ DIB_PAL_COLORS = 1
51
+
52
+ BI_RGB = 0
53
+ BI_RLE8 = 1
54
+ BI_RLE4 = 2
55
+ BI_BITFIELDS = 3
56
+ BI_JPEG = 4
57
+ BI_PNG = 5
58
+
59
+ PASSTHROUGH = 19
60
+ QUERYESCSUPPORT = 8
61
+
62
+ #the functions that wrap the Win32API calls enforce type checking on arguments
63
+ # (through #check). This is to be consistent with the Win32API which will assume
64
+ # different arguments are calling different functions, throwing wacky errors
65
+ #API WRAPPERS
66
+
67
+ attach_function :CreateCompatibleBitmap, [ :handle, :int, :int ], :handle
68
+ def self.create_compatible_bitmap(hdc, nWidth, nHeight)
69
+ #~ HBITMAP CreateCompatibleBitmap(
70
+ #~ __in HDC hdc,
71
+ #~ __in int nWidth,
72
+ #~ __in int nHeight
73
+ #~ );
74
+ exception_for_0{
75
+ CreateCompatibleBitmap(hdc, nWidth, nHeight)
76
+ }
77
+ end
78
+
79
+ attach_function :CreateBitmap, [ :int, :int, :uint, :uint, :pointer ], :handle
80
+ def self.create_bitmap(nWidth, nHeight, cPlanes, cBitsPerPel, lpvBits)
81
+ #~ HBITMAP CreateBitmap(
82
+ #~ __in int nWidth,
83
+ #~ __in int nHeight,
84
+ #~ __in UINT cPlanes,
85
+ #~ __in UINT cBitsPerPel,
86
+ #~ __in const VOID *lpvBits
87
+ #~ );
88
+ exception_for_0{
89
+ CreateBitmap(nWidth, nHeight, cPlanes, cBitsPerPel, lpvBits)
90
+ }
91
+ end
92
+
93
+ attach_function :SetDIBits, [ :handle, :handle, :uint, :uint, :pointer, :pointer, :uint ], :int
94
+ def self.set_dibits(hdc, hbmp, uStartScan, cScanLines, lpvBits, lpbmi, fuColorUse)
95
+ #~ int SetDIBits(
96
+ #~ __in HDC hdc,
97
+ #~ __in HBITMAP hbmp,
98
+ #~ __in UINT uStartScan,
99
+ #~ __in UINT cScanLines,
100
+ #~ __in const VOID *lpvBits,
101
+ #~ __in const BITMAPINFO *lpbmi,
102
+ #~ __in UINT fuColorUse
103
+ #~ );
104
+ exception_for_0{
105
+ SetDIBits(hdc, hbmp, uStartScan, cScanLines, lpvBits, lpbmi, fuColorUse)
106
+ }
107
+ end
108
+
109
+ attach_function :SetDIBitsToDevice, [ :handle, :int, :int, :uint, :uint, :int, :int, :uint, :uint, :pointer, :pointer, :uint ], :int
110
+ def self.set_dibits_to_device(hdc, xDest, yDest, dwWidth, dwHeight, xSrc, ySrc, uStartScan, cScanLines, lpvBits, lpbmi, fuColorUse)
111
+ #~ int SetDIBitsToDevice(
112
+ #~ __in HDC hdc,
113
+ #~ __in int XDest,
114
+ #~ __in int YDest,
115
+ #~ __in DWORD dwWidth,
116
+ #~ __in DWORD dwHeight,
117
+ #~ __in int XSrc,
118
+ #~ __in int YSrc,
119
+ #~ __in UINT uStartScan,
120
+ #~ __in UINT cScanLines,
121
+ #~ __in const VOID *lpvBits,
122
+ #~ __in const BITMAPINFO *lpbmi,
123
+ #~ __in UINT fuColorUse
124
+ #~ );
125
+ exception_for_negative{
126
+ SetDIBitsToDevice(hdc, xDest, yDest, dwWidth, dwHeight, xSrc, ySrc, uStartScan, cScanLines, lpvBits, lpbmi, fuColorUse)
127
+ }
128
+ end
129
+
130
+
131
+ attach_function :BitBlt, [ :handle, :int, :int, :int, :int, :handle, :int, :int, :uint32 ], :int
132
+ def self.bit_blt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop)
133
+ #~ BOOL BitBlt(
134
+ #~ __in HDC hdcDest,
135
+ #~ __in int nXDest,
136
+ #~ __in int nYDest,
137
+ #~ __in int nWidth,
138
+ #~ __in int nHeight,
139
+ #~ __in HDC hdcSrc,
140
+ #~ __in int nXSrc,
141
+ #~ __in int nYSrc,
142
+ #~ __in DWORD dwRop
143
+ #~ );
144
+ exception_for_0{
145
+ BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop)
146
+ }
147
+ end
148
+
149
+
150
+ attach_function :TextOutW, [ :handle, :int, :int, :pointer, :int ], :int
151
+ attach_function :TextOutA, [ :handle, :int, :int, :pointer, :int ], :int
152
+ def self.text_out(hdc, nXStart, nYStart, lpString, cbString)
153
+ #~ BOOL TextOut(
154
+ #~ __in HDC hdc,
155
+ #~ __in int nXStart,
156
+ #~ __in int nYStart,
157
+ #~ __in LPCTSTR lpString,
158
+ #~ __in int cbString
159
+ #~ );
160
+ exception_for_0{
161
+ args = hdc, nXStart, nYStart, lpString, cbString
162
+ unicode ? TextOutW(*args) : TextOutA(*args)
163
+ }
164
+ end
165
+
166
+
167
+ attach_function :SelectObject, [ :handle, :handle ], :handle
168
+ def self.select_object(hdc, hgdiobj)
169
+ #~ HGDIOBJ SelectObject(
170
+ #~ HDC hdc,
171
+ #~ HGDIOBJ hgdiobj
172
+ #~ );
173
+ exception_for_0{
174
+ SelectObject(hdc, hgdiobj)
175
+ }
176
+ end
177
+
178
+
179
+ attach_function :SelectObject, [ :handle, :int, :pointer ], :int
180
+ def self.get_object(hgdiobj, cbBuffer, lpvObject)
181
+ #~ int GetObject(
182
+ #~ __in HGDIOBJ hgdiobj,
183
+ #~ __in int cbBuffer,
184
+ #~ __out LPVOID lpvObject
185
+ #~ );
186
+ exception_for_0{
187
+ GetObject(hgdiobj, cbBuffer, lpvObject)
188
+ }
189
+ end
190
+
191
+
192
+ attach_function :DeleteDC, [ :handle ], :int
193
+ # nur bei CreateDC verwenden
194
+ def self.delete_dc(hDC)
195
+ #~ BOOL DeleteDC(
196
+ #~ __in HDC hdc
197
+ #~ );
198
+
199
+ exception_for_0{
200
+ DeleteDC(hDC)
201
+ }
202
+ end
203
+
204
+
205
+ attach_function :DeleteObject, [ :handle ], :int
206
+ # nur bei CreateDC verwenden
207
+ def self.delete_object(hDC)
208
+ #~ BOOL DeleteDC(
209
+ #~ __in HDC hdc
210
+ #~ );
211
+
212
+ exception_for_0{
213
+ DeleteObject(hDC)
214
+ }
215
+ end
216
+
217
+
218
+ attach_function :CreateCompatibleDC, [ :handle ], :handle
219
+ def self.create_compatible_dc(hdc)
220
+ #~ HDC CreateCompatibleDC(
221
+ #~ __in HDC hdc
222
+ #~ );
223
+ exception_for_0{
224
+ CreateCompatibleDC(hdc)
225
+ }
226
+ end
227
+
228
+
229
+ attach_function :CreateDCW, [ :pointer, :pointer, :pointer, :pointer ], :handle
230
+ attach_function :CreateDCA, [ :pointer, :pointer, :pointer, :pointer ], :handle
231
+ def self.create_dc(lpszDriver, lpszDevice, lpszOutput, lpInitData)
232
+ #~ HDC CreateDC(
233
+ #~ LPCTSTR lpszDriver,
234
+ #~ __in LPCTSTR lpszDevice,
235
+ #~ LPCTSTR lpszOutput,
236
+ #~ __in const DEVMODE *lpInitData
237
+ #~ );
238
+
239
+ #~ hDC = CreateDC( 0, sPrnName, 0, dm );
240
+ exception_for_0{
241
+ args = lpszDriver, lpszDevice, lpszOutput, lpInitData
242
+ unicode ? CreateDCW(*args) : CreateDCA(*args)
243
+ }
244
+ end
245
+
246
+
247
+ attach_function :AbortDoc, [ :handle ], :int
248
+ def self.abort_doc(hPrinter)
249
+ #~ int AbortDoc(
250
+ #~ __in HDC hdc
251
+ #~ );
252
+ exception_for_0{
253
+ AbortDoc(hPrinter)
254
+ }
255
+ end
256
+
257
+
258
+ attach_function :StartDocW, [ :handle, :pointer ], :int
259
+ attach_function :StartDocA, [ :handle, :pointer ], :int
260
+ def self.start_doc(hPrinter, pDocInfo)
261
+ exception_for_0{
262
+ args = hPrinter, pDocInfo
263
+ unicode ? StartDocW(*args) : StartDocA(*args)
264
+ }
265
+ end
266
+
267
+
268
+ attach_function :EndDoc, [ :handle ], :int
269
+ def self.end_doc(hPrinter)
270
+ exception_for_0{
271
+ EndDoc(hPrinter)
272
+ }
273
+ end
274
+
275
+
276
+ attach_function :StartPage, [ :handle ], :int
277
+ def self.start_page(hPrinter)
278
+ exception_for_0{
279
+ StartPage(hPrinter)
280
+ }
281
+ end
282
+
283
+
284
+ attach_function :EndPage, [ :handle ], :int
285
+ def self.end_page(hPrinter)
286
+ #~ int EndPage(
287
+ #~ __in HDC hdc
288
+ #~ );
289
+ exception_for_0{
290
+ EndPage(hPrinter)
291
+ }
292
+ end
293
+
294
+
295
+ attach_function :CreateFontW, [ :int, :int, :int, :int, :int, :ulong, :ulong, :ulong, :ulong, :ulong, :ulong, :ulong, :ulong, :pointer ], :handle
296
+ attach_function :CreateFontA, [ :int, :int, :int, :int, :int, :ulong, :ulong, :ulong, :ulong, :ulong, :ulong, :ulong, :ulong, :pointer ], :handle
297
+ def self.create_font(nHeight, nWidth, nEscapement, nOrientation, fnWeight, fdwItalic, fdwUnderline, fdwStrikeOut, fdwCharSet, fdwOutputPrecision, fdwClipPrecision, fdwQuality, fdwPitchAndFamily, lpszFace)
298
+ #~ HFONT CreateFont(
299
+ #~ __in int nHeight,
300
+ #~ __in int nWidth,
301
+ #~ __in int nEscapement,
302
+ #~ __in int nOrientation,
303
+ #~ __in int fnWeight,
304
+ #~ __in DWORD fdwItalic,
305
+ #~ __in DWORD fdwUnderline,
306
+ #~ __in DWORD fdwStrikeOut,
307
+ #~ __in DWORD fdwCharSet,
308
+ #~ __in DWORD fdwOutputPrecision,
309
+ #~ __in DWORD fdwClipPrecision,
310
+ #~ __in DWORD fdwQuality,
311
+ #~ __in DWORD fdwPitchAndFamily,
312
+ #~ __in LPCTSTR lpszFace
313
+ #~ );
314
+ exception_for_0{
315
+ args = nHeight, nWidth, nEscapement, nOrientation, fnWeight, fdwItalic, fdwUnderline, fdwStrikeOut, fdwCharSet, fdwOutputPrecision, fdwClipPrecision, fdwQuality, fdwPitchAndFamily, lpszFace
316
+ unicode ? CreateFontW(*args) : CreateFontA(*args)
317
+ }
318
+ end
319
+
320
+ attach_function :Escape, [ :handle, :int, :int, :pointer, :pointer ], :int
321
+ def self.escape(hdc, nEscape, lpvInData, lpvOutData)
322
+ #~ int Escape(
323
+ #~ __in HDC hdc,
324
+ #~ __in int nEscape,
325
+ #~ __in int cbInput,
326
+ #~ __in LPCSTR lpvInData,
327
+ #~ __out LPVOID lpvOutData
328
+ #~ );
329
+ cbInput = lpvInData.length
330
+ exception_for_0{
331
+ Escape(hdc, nEscape, cbInput, lpvInData, lpvOutData)
332
+ }
333
+ end
334
+
335
+ class BITMAPINFOHEADER < FFI::Struct
336
+ # BITMAPINFOHEADER {
337
+ # DWORD biSize;
338
+ # LONG biWidth;
339
+ # LONG biHeight;
340
+ # WORD biPlanes;
341
+ # WORD biBitCount;
342
+ # DWORD biCompression;
343
+ # DWORD biSizeImage;
344
+ # LONG biXPelsPerMeter;
345
+ # LONG biYPelsPerMeter;
346
+ # DWORD biClrUsed;
347
+ # DWORD biClrImportant;
348
+ # }
349
+ layout :biSize, :uint32,
350
+ :biWidth, :long,
351
+ :biHeight, :long,
352
+ :biPlanes, :uint16,
353
+ :biBitCount, :uint16,
354
+ :biCompression, :uint32,
355
+ :biSizeImage, :uint32,
356
+ :biXPelsPerMeter, :long,
357
+ :biYPelsPerMeter, :long,
358
+ :biClrUsed, :uint32,
359
+ :biClrImportant, :uint32
360
+ end
361
+
362
+ def self.create_BITMAPINFOHEADER(data_or_size=nil)
363
+ ptrdata = create_struct(BITMAPINFOHEADER, data_or_size)
364
+ ptrdata[:biSize] = ptrdata.pointer.size
365
+ return ptrdata
366
+ end
367
+
368
+ class DOCINFO < FFI::Struct
369
+ # struct {
370
+ # int cbSize;
371
+ # LPCTSTR lpszDocName;
372
+ # LPCTSTR lpszOutput;
373
+ # LPCTSTR lpszDatatype;
374
+ # DWORD fwType;
375
+ # } DOCINFO
376
+ layout :cbSize, :int,
377
+ :lpszDocName, :pointer,
378
+ :lpszOutput, :pointer,
379
+ :lpszDatatype, :pointer,
380
+ :fwType, :uint32
381
+ end
382
+
383
+ def self.create_DOCINFO(data_or_size=nil)
384
+ ptrdata = create_struct(DOCINFO, data_or_size)
385
+ ptrdata[:cbSize] = ptrdata.pointer.size
386
+ return ptrdata
387
+ end
388
+ end
389
+ end
@@ -0,0 +1,66 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ require 'win32api4ruby/base'
4
+
5
+ module Win32api4ruby
6
+ class Kernel < Base
7
+ extend FFI::Library
8
+ ffi_lib 'kernel32'
9
+ ffi_convention :stdcall
10
+
11
+ #the functions that wrap the Win32API calls enforce type checking on arguments
12
+ # (through #check). This is to be consistent with the Win32API which will assume
13
+ # different arguments are calling different functions, throwing wacky errors
14
+ #API WRAPPERS
15
+ attach_function :GlobalLock, [ :handle ], :pointer
16
+ def self.global_lock(hMovableMemory)
17
+ exception_for_0{
18
+ GlobalLock(hMovableMemory)
19
+ }
20
+ end
21
+
22
+ attach_function :GlobalUnlock, [ :handle ], :long
23
+ def self.global_unlock(hMovableMemory)
24
+ GlobalUnlock(hMovableMemory)
25
+ end
26
+
27
+ attach_function :GlobalFree, [ :handle ], :handle
28
+ def self.global_free(hMovableMemory)
29
+ exception_for_non_0{
30
+ GlobalFree(hMovableMemory)
31
+ }
32
+ end
33
+
34
+ def self.get_last_error()
35
+ FFI.errno
36
+ end
37
+
38
+ attach_function :SetLastError, [:long], :long
39
+ def self.set_last_error(v)
40
+ check(v, Integer)
41
+ SetLastError(v)
42
+ end
43
+
44
+ attach_function :FormatMessageW, [:long, :pointer, :long, :long, :pointer, :long, :pointer], :long
45
+ attach_function :FormatMessageA, [:long, :pointer, :long, :long, :pointer, :long, :pointer], :long
46
+ def self.format_message(dwFlags, lpSource, dwMessageID, dwLanguageID, lpBuffer, nSize, arguments)
47
+ check(dwFlags,Integer);
48
+ check(lpSource,String);
49
+ check(dwMessageID,Integer)
50
+ check(dwLanguageID,Integer); check(lpBuffer,FFI::AbstractMemory);
51
+ check(nSize,Integer);
52
+ check(arguments,String)
53
+ args = dwFlags, lpSource, dwMessageID, dwLanguageID, lpBuffer, nSize, arguments
54
+ unicode ? FormatMessageW(*args) : FormatMessageA(*args)
55
+ end
56
+ # --------------------------------------------------------------------------------------------------------------
57
+ def self.with_global_lock(handle)
58
+ begin
59
+ globalMemory = global_lock(handle)
60
+ yield globalMemory
61
+ ensure
62
+ global_free(handle)
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,182 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ require 'win32api4ruby/base'
4
+
5
+
6
+ module Win32api4ruby
7
+ class User < Base
8
+ extend FFI::Library
9
+ ffi_lib 'user32'
10
+ ffi_convention :stdcall
11
+
12
+ IMAGE_ENHMETAFILE = 3
13
+ LR_DEFAULTCOLOR = 0x00000000
14
+ LR_MONOCHROME = 0x00000001
15
+ LR_COLOR = 0x00000002
16
+ LR_COPYRETURNORG = 0x00000004
17
+ LR_COPYDELETEORG = 0x00000008
18
+ LR_LOADFROMFILE = 0x00000010
19
+ LR_LOADTRANSPARENT = 0x00000020
20
+ LR_DEFAULTSIZE = 0x00000040
21
+ LR_VGACOLOR = 0x00000080
22
+ LR_LOADMAP3DCOLORS = 0x00001000
23
+ LR_CREATEDIBSECTION = 0x00002000
24
+ LR_COPYFROMRESOURCE = 0x00004000
25
+ LR_SHARED = 0x00008000
26
+
27
+ DI_MASK = 0x0001
28
+ DI_IMAGE = 0x0002
29
+ DI_NORMAL = 0x0003
30
+ DI_COMPAT = 0x0004
31
+ DI_DEFAULTSIZE = 0x0008
32
+ #if(_WIN32_WINNT >= 0x0501)
33
+ DI_NOMIRROR = 0x0010
34
+ #endif /* _WIN32_WINNT >= 0x0501 */
35
+
36
+ IMAGE_BITMAP = 0
37
+ IMAGE_ICON = 1
38
+ IMAGE_CURSOR = 2
39
+
40
+ WS_VISIBLE = 0x10000000
41
+
42
+ #the functions that wrap the Win32API calls enforce type checking on arguments
43
+ # (through #check). This is to be consistent with the Win32API which will assume
44
+ # different arguments are calling different functions, throwing wacky errors
45
+ #API WRAPPERS
46
+ # --------------------------------------------------------------------------------------------------------------
47
+ attach_function :LoadImageW, [ :handle, :pointer, :uint, :int, :int, :uint ], :handle
48
+ attach_function :LoadImageA, [ :handle, :pointer, :uint, :int, :int, :uint ], :handle
49
+ def self.load_image(hinst, lpszName, uType, cxDesired, cyDesired, fuLoad)
50
+ #~ HANDLE LoadImage(
51
+ #~ HINSTANCE hinst,
52
+ #~ LPCTSTR lpszName,
53
+ #~ UINT uType,
54
+ #~ int cxDesired,
55
+ #~ int cyDesired,
56
+ #~ UINT fuLoad
57
+ #~ );
58
+ exception_for_0{
59
+ args = hinst, lpszName, uType, cxDesired, cyDesired, fuLoad
60
+ unicode ? LoadImageW(*args) : LoadImageA(*args)
61
+ }
62
+ end
63
+ #--------------------------------------------------------------------------------------------------------------
64
+
65
+ attach_function :DrawTextW, [ :handle, :pointer, :int, :pointer, :uint ], :int
66
+ attach_function :DrawTextA, [ :handle, :pointer, :int, :pointer, :uint ], :int
67
+ def self.draw_text(hdc, lpchText, nCount, lpRect, uFormat)
68
+ #~ int DrawText(
69
+ #~ __in HDC hDC,
70
+ #~ __inout LPCTSTR lpchText,
71
+ #~ __in int nCount,
72
+ #~ __inout LPRECT lpRect,
73
+ #~ __in UINT uFormat
74
+ #~ );
75
+ exception_for_0{
76
+ args = hdc, lpchText, nCount, lpRect, uFormat
77
+ unicode ? DrawTextW(*args) : DrawTextA(*args)
78
+ }
79
+ end
80
+ #--------------------------------------------------------------------------------------------------------------
81
+
82
+ attach_function :CallWindowProcW, [ :pointer, :handle, :uint, :int, :int ], :lresult
83
+ attach_function :CallWindowProcA, [ :pointer, :handle, :uint, :int, :int ], :lresult
84
+ def self.call_window_proc(lpPrevWndFunc, hWnd, msg, wParam, lParam)
85
+ #~ LRESULT CallWindowProc(
86
+ #~ WNDPROC lpPrevWndFunc,
87
+ #~ HWND hWnd,
88
+ #~ UINT Msg,
89
+ #~ WPARAM wParam,
90
+ #~ LPARAM lParam
91
+ #~ );
92
+ args = lpPrevWndFunc, hWnd, msg, wParam, lParam
93
+ unicode ? CallWindowProc(*args) : CallWindowProcA(*args)
94
+ end
95
+ #--------------------------------------------------------------------------------------------------------------
96
+
97
+ attach_function :SetWindowLongW, [ :handle, :int, :long ], :long
98
+ attach_function :SetWindowLongA, [ :handle, :int, :long ], :long
99
+ def self.set_window_long(hWnd, nIndex, dwNewLong)
100
+ #~ LONG SetWindowLong(
101
+ #~ HWND hWnd,
102
+ #~ int nIndex,
103
+ #~ LONG dwNewLong
104
+ #~ );
105
+ exception_for_nil{
106
+ args = hWnd, nIndex, dwNewLong
107
+ unicode ? SetWindowLongW(*args) : SetWindowLongA(*args)
108
+ }
109
+ end
110
+
111
+ attach_function :CreateWindowExW, [ :uint32, :pointer, :pointer, :uint32, :int, :int, :int, :int, :handle, :handle, :handle, :pointer ], :handle
112
+ attach_function :CreateWindowExA, [ :uint32, :pointer, :pointer, :uint32, :int, :int, :int, :int, :handle, :handle, :handle, :pointer ], :handle
113
+ def self.create_window_ex(dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam=nil)
114
+ #~ HWND CreateWindow(
115
+ #~ DWORD dwExStyle,
116
+ #~ LPCTSTR lpClassName,
117
+ #~ LPCTSTR lpWindowName,
118
+ #~ DWORD dwStyle,
119
+ #~ int x,
120
+ #~ int y,
121
+ #~ int nWidth,
122
+ #~ int nHeight,
123
+ #~ HWND hWndParent,
124
+ #~ HMENU hMenu,
125
+ #~ HINSTANCE hInstance,
126
+ #~ LPVOID lpParam
127
+ #~ );
128
+ exception_for_0{
129
+ args = dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam
130
+ unicode ? CreateWindowExW(*args) : CreateWindowExA(*args)
131
+ }
132
+ end
133
+
134
+ attach_function :UpdateWindow, [ :handle ], :int
135
+ def self.update_window(hwnd)
136
+ exception_for_0{
137
+ UpdateWindow(hwnd)
138
+ }
139
+ end
140
+
141
+ attach_function :DestroyWindow, [ :handle ], :int
142
+ def self.destroy_window(hwnd)
143
+ exception_for_0{
144
+ DestroyWindow(hwnd)
145
+ }
146
+ end
147
+
148
+ #~ {GetMessage will return True until it gets a WM_OUIT message.
149
+ #~ So this program will keep running untill you Post a Quit Message}
150
+ attach_function :GetMessageW, [ :pointer, :handle, :long, :long ], :int
151
+ attach_function :GetMessageA, [ :pointer, :handle, :long, :long ], :int
152
+ def self.get_message(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax)
153
+ exception_for_0{
154
+ args = lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax
155
+ unicode ? GetMessageW(*args) : GetMessageA(*args)
156
+ }
157
+ end
158
+
159
+ #~ {Translate any WM_KEYDOWN keyboard Msg to a WM_CHAR message}
160
+ attach_function :TranslateMessage, [ :pointer ], :int
161
+ def self.translate_message(msg)
162
+ TranslateMessage(msg)
163
+ end
164
+
165
+ #~ {this Sends Msg to the address of the
166
+ #~ "Window Procedure" set in the Resistered
167
+ #~ Window's Class for that window}
168
+ attach_function :DispatchMessageW, [ :pointer ], :lresult
169
+ attach_function :DispatchMessageA, [ :pointer ], :lresult
170
+ def self.dispatch_message(msg)
171
+ unicode ? DispatchMessageW(msg) : DispatchMessageA(msg)
172
+ end
173
+
174
+ attach_function :GetDC, [ :handle ], :handle
175
+ def self.get_dc(hWnd)
176
+ exception_for_0{
177
+ GetDC(hWnd)
178
+ }
179
+ end
180
+
181
+ end
182
+ end