dxrubynd 1.4.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1180 @@
1
+ #define WINVER 0x0500 /* �o�[�W������` Windows2000�ȏ� */
2
+ #define _WIN32_WINNT WINVER
3
+
4
+ #include "ruby.h"
5
+ #include "ruby/encoding.h"
6
+ #ifndef RUBY_ST_H
7
+ #include "st.h"
8
+ #endif
9
+
10
+ #define DXRUBY_EXTERN 1
11
+
12
+ #include "dxruby.h"
13
+ #include "messagethread.h"
14
+ #include "font.h"
15
+ #include "imm.h"
16
+
17
+ static HANDLE hMessageThread;
18
+ static DWORD MessageThreadID;
19
+ static HANDLE hEventMainThreadStart;
20
+ int MainThreadError = 0;
21
+
22
+ static int InitWindow( void );
23
+ static int InitDXGraphics( void );
24
+ static void DXRelease();
25
+
26
+ #ifdef DXRUBY15
27
+ int ime_str_length;
28
+ int ime_str_length_old;
29
+ WCHAR *ime_buf = NULL;
30
+ WCHAR *ime_buf_old = NULL;
31
+ CRITICAL_SECTION ime_cs;
32
+ int ime_compositing;
33
+
34
+ int ime_vk_push_str_length;
35
+ char *ime_vk_push_buf = NULL;
36
+ char *ime_vk_push_buf_old = NULL;
37
+
38
+ int ime_vk_release_str_length;
39
+ char *ime_vk_release_buf = NULL;
40
+ char *ime_vk_release_buf_old = NULL;
41
+
42
+ WCHAR *ime_composition_str = NULL;
43
+ WCHAR *ime_composition_str_old = NULL;
44
+ int ime_composition_attr_size;
45
+ char *ime_composition_attr = 0;
46
+ char *ime_composition_attr_old = 0;
47
+ LPCANDIDATELIST ime_canlist = NULL;
48
+ LPCANDIDATELIST ime_canlist_old = NULL;
49
+ int ime_cursor_pos;
50
+
51
+ HIMC default_imc = NULL;
52
+ #endif
53
+
54
+ char *ERR_MESSAGE[ERR_MAX] =
55
+ {
56
+ "ok",
57
+ "out of memory",
58
+ "Internal Error",
59
+ "not changed screen mode",
60
+ "failed create window",
61
+ "DirectX Graphics initialize error",
62
+ "DirectInput initialize error"
63
+ };
64
+
65
+ void DXRuby_raise( int errorcode, char *msg )
66
+ {
67
+ char buf[1024];
68
+ buf[0] = '\0';
69
+
70
+ strcat( buf, ERR_MESSAGE[errorcode] );
71
+ strcat( buf, " - " );
72
+ strcat( buf, msg );
73
+
74
+ /* buf�̒��g�����b�Z�[�W�Ƃ���eDXRubyError��O�𓊂��� */
75
+ rb_funcall( rb_cObject, rb_intern( "raise" ), 2, eDXRubyError, rb_funcall( rb_str_new2( buf ), rb_intern( "force_encoding" ), 1, rb_str_new2( sys_encode ) ) );
76
+ }
77
+
78
+ /*--------------------------------------------------------------------
79
+ �i�����֐��j�X�N���[���T�C�Y�ύX
80
+ ---------------------------------------------------------------------*/
81
+ static int DDChangeSize( void )
82
+ {
83
+ D3DVIEWPORT9 vp;
84
+ HRESULT hr;
85
+ int i;
86
+ D3DDISPLAYMODE d3ddm;
87
+
88
+ g_D3DPP.BackBufferWidth = g_WindowInfo.width;
89
+ g_D3DPP.BackBufferHeight = g_WindowInfo.height;
90
+
91
+ if( !g_WindowInfo.windowed )
92
+ {
93
+ /* �t���X�N���[�����i32bitColor�Œ�/���t���b�V�����[�g�͂���΂���A������Έ�ԍ�������) */
94
+ int count , max, set_refreshrate;
95
+
96
+ max = g_pD3D->lpVtbl->GetAdapterModeCount( g_pD3D, D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8 );
97
+ set_refreshrate = 0;
98
+ g_sync = 0;
99
+ g_D3DPP.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
100
+
101
+ for( count = 0 ; count < max ; count++ )
102
+ {
103
+ g_pD3D->lpVtbl->EnumAdapterModes( g_pD3D, D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8 , count , &d3ddm);
104
+ /* �𑜓x��������疳�� */
105
+ if( g_WindowInfo.width != d3ddm.Width || g_WindowInfo.height != d3ddm.Height )
106
+ {
107
+ continue;
108
+ }
109
+
110
+ /* fps�w�肪����A�������̂��������炻��Ɍ��� */
111
+ if( g_WindowInfo.fps != 0 && d3ddm.RefreshRate == g_WindowInfo.fps )
112
+ {
113
+ set_refreshrate = d3ddm.RefreshRate;
114
+ g_sync = 1; // �����������[�h
115
+ g_D3DPP.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
116
+ break;
117
+ }
118
+
119
+ /* �����ꍇ�ɂ͈�ԑ傫���z�ɂ��� */
120
+ if( d3ddm.RefreshRate > set_refreshrate )
121
+ {
122
+ set_refreshrate = d3ddm.RefreshRate;
123
+ }
124
+ }
125
+
126
+ g_D3DPP.BackBufferFormat = D3DFMT_X8R8G8B8;
127
+ g_D3DPP.Windowed = FALSE;
128
+ g_D3DPP.FullScreen_RefreshRateInHz = set_refreshrate;
129
+ }
130
+ else
131
+ {
132
+ /* �E�B���h�E���[�h�� */
133
+
134
+ /* ���݂̃��[�h���擾 */
135
+ g_pD3D->lpVtbl->GetAdapterDisplayMode( g_pD3D, D3DADAPTER_DEFAULT , &d3ddm );
136
+
137
+ g_sync = 0; // �����񓯊����[�h
138
+ g_D3DPP.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
139
+ g_D3DPP.BackBufferFormat = D3DFMT_UNKNOWN;
140
+ g_D3DPP.Windowed = TRUE;
141
+ g_D3DPP.FullScreen_RefreshRateInHz = 0;
142
+ }
143
+
144
+ /* D3DXSprite�����X�g������ */
145
+ if( g_pD3DXSprite )
146
+ {
147
+ g_pD3DXSprite->lpVtbl->OnLostDevice( g_pD3DXSprite );
148
+ }
149
+
150
+ /* ���C�������_�[�^�[�Q�b�g�̉�� */
151
+ {
152
+ struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, g_WindowInfo.render_target );
153
+ RELEASE( rt->surface );
154
+ }
155
+
156
+ /* ���[�U�[�����_�[�^�[�Q�b�g�̉�� */
157
+ // ppD3DTexture = (LPDIRECT3DTEXTURE9 *)alloca( g_RenderTargetList.count * sizeof(LPDIRECT3DTEXTURE9 *) );
158
+ for( i = 0; i < g_RenderTargetList.count; i++ )
159
+ {
160
+ struct DXRubyRenderTarget *rt = (struct DXRubyRenderTarget *)g_RenderTargetList.pointer[i];
161
+ if( g_RenderTargetList.pointer[i] )
162
+ {
163
+ // ppD3DTexture[i] = to_image( rt );
164
+ RELEASE( rt->surface );
165
+ RELEASE( rt->texture->pD3DTexture );
166
+ }
167
+ }
168
+
169
+ /* �V�F�[�_�̃��X�g */
170
+ for( i = 0; i < g_ShaderCoreList.count; i++ )
171
+ {
172
+ struct DXRubyShaderCore *core = (struct DXRubyShaderCore *)g_ShaderCoreList.pointer[i];
173
+ core->pD3DXEffect->lpVtbl->OnLostDevice( core->pD3DXEffect );
174
+ }
175
+
176
+ /* �ݒ�ύX */
177
+ hr = g_pD3DDevice->lpVtbl->Reset( g_pD3DDevice, &g_D3DPP );
178
+ if( FAILED( hr ) ) return 1;
179
+
180
+ /* ���C�������_�[�^�[�Q�b�g�̕��� */
181
+ {
182
+ struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, g_WindowInfo.render_target );
183
+ g_pD3DDevice->lpVtbl->GetRenderTarget( g_pD3DDevice, 0, &rt->surface );
184
+ }
185
+
186
+ /* ���[�U�[�����_�[�^�[�Q�b�g�̕��� */
187
+ for( i = 0; i < g_RenderTargetList.count; i++ )
188
+ {
189
+ struct DXRubyRenderTarget *rt = (struct DXRubyRenderTarget *)g_RenderTargetList.pointer[i];
190
+ if( g_RenderTargetList.pointer[i] )
191
+ {
192
+ /* �e�N�X�`���I�u�W�F�N�g���쐬���� */
193
+ hr = D3DXCreateTexture( g_pD3DDevice, (UINT)rt->texture->width, (UINT)rt->texture->height,
194
+ 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT,
195
+ &rt->texture->pD3DTexture);
196
+ if( FAILED( hr ) ) return 2;
197
+
198
+ hr = rt->texture->pD3DTexture->lpVtbl->GetSurfaceLevel( rt->texture->pD3DTexture, 0, &rt->surface );
199
+ if( FAILED( hr ) ) return 3;
200
+ }
201
+ }
202
+
203
+ /* �V�F�[�_�̕��A */
204
+ for( i = 0; i < g_ShaderCoreList.count; i++ )
205
+ {
206
+ struct DXRubyShaderCore *core = (struct DXRubyShaderCore *)g_ShaderCoreList.pointer[i];
207
+ core->pD3DXEffect->lpVtbl->OnResetDevice( core->pD3DXEffect );
208
+ }
209
+
210
+ /* D3DXSprite���A */
211
+ if( g_pD3DXSprite )
212
+ {
213
+ g_pD3DXSprite->lpVtbl->OnResetDevice( g_pD3DXSprite );
214
+ }
215
+
216
+ return 0;
217
+ }
218
+
219
+ /*--------------------------------------------------------------------
220
+ �E�B���h�E�̐����Ə�����
221
+ ---------------------------------------------------------------------*/
222
+ static int ChangeSize()
223
+ {
224
+ HRESULT hr;
225
+ RECT rect;
226
+ VALUE vrender_target;
227
+ struct DXRubyRenderTarget *rt;
228
+ int ret;
229
+
230
+ /* �E�B���h�E�̃T�C�Y�ݒ� */
231
+ rect.top = 0;
232
+ rect.left = 0;
233
+ rect.right = (LONG)(g_WindowInfo.width * g_WindowInfo.scale);
234
+ rect.bottom = (LONG)(g_WindowInfo.height * g_WindowInfo.scale);
235
+
236
+ /* �E�B���h�E�̃T�C�Y�C�� */
237
+ if( !g_WindowInfo.windowed )
238
+ { /* �t���X�N���[�� */
239
+ SetWindowLong( g_hWnd, GWL_STYLE, WS_POPUP );
240
+ SetWindowPos( g_hWnd, HWND_TOP, 0, 0, g_WindowInfo.width, g_WindowInfo.height, 0);
241
+ }
242
+ else
243
+ { /* �E�B���h�E���[�h */
244
+ SetWindowLong( g_hWnd, GWL_STYLE, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX);
245
+ AdjustWindowRect( &rect, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, FALSE );
246
+
247
+ /* ���ƍ����v�Z */
248
+ rect.right = rect.right - rect.left;
249
+ rect.bottom = rect.bottom - rect.top;
250
+
251
+ /* �E�B���h�E�ړ�/�T�C�Y�ݒ� */
252
+ if( g_WindowInfo.x == CW_USEDEFAULT )
253
+ { /* �ʒu���f�t�H���g�̏ꍇ */
254
+ SetWindowPos( g_hWnd, HWND_NOTOPMOST , 0, 0, rect.right, rect.bottom, SWP_NOMOVE);
255
+ }
256
+ else
257
+ { /* �ʒu�w��̏ꍇ */
258
+ SetWindowPos( g_hWnd, HWND_NOTOPMOST, g_WindowInfo.x, g_WindowInfo.y, rect.right, rect.bottom, 0 );
259
+ }
260
+ }
261
+
262
+ /* DirectX�̃X�N���[���T�C�Y�ύX */
263
+ ret = DDChangeSize();
264
+ if( ret != 0 )
265
+ {
266
+ return ret;
267
+ }
268
+
269
+ /* �E�B���h�E�\�� */
270
+ ShowWindow( g_hWnd, SW_SHOWNORMAL );
271
+ InvalidateRect( NULL, NULL, TRUE );
272
+ UpdateWindow( g_hWnd );
273
+
274
+ {
275
+ struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, g_WindowInfo.render_target );
276
+
277
+ /* �V�[���̃N���A */
278
+ g_pD3DDevice->lpVtbl->SetRenderTarget( g_pD3DDevice, 0, rt->surface );
279
+ g_pD3DDevice->lpVtbl->Clear( g_pD3DDevice, 0, NULL, D3DCLEAR_TARGET,
280
+ D3DCOLOR_XRGB( rt->r, rt->g, rt->b ), 0, 0 );
281
+ g_pD3DDevice->lpVtbl->Present( g_pD3DDevice, NULL, NULL, NULL, NULL );
282
+
283
+ rt->width = g_WindowInfo.width;
284
+ rt->height = g_WindowInfo.height;
285
+ }
286
+
287
+ g_WindowInfo.created = Qtrue;
288
+
289
+ SetCursor( LoadCursor( NULL, IDC_ARROW ) );
290
+
291
+ return 0;
292
+ }
293
+
294
+
295
+ static int reset( void )
296
+ {
297
+ HRESULT hr;
298
+ hr = g_pD3DDevice->lpVtbl->TestCooperativeLevel( g_pD3DDevice );
299
+ if( hr == D3DERR_DEVICENOTRESET ) /* �f�o�C�X�̓��X�g��Ԃł��邪���Z�b�g�”\�ł��� */
300
+ {
301
+ int i;
302
+ /* �����֗������̓f�o�C�X�����Z�b�g�”\��Ԃł��� */
303
+ /* D3DXSprite�����X�g������ */
304
+ if( g_pD3DXSprite )
305
+ {
306
+ g_pD3DXSprite->lpVtbl->OnLostDevice( g_pD3DXSprite );
307
+ }
308
+
309
+ /* �����_�[�^�[�Q�b�g�̉�� */
310
+ {
311
+ struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, g_WindowInfo.render_target );
312
+ RELEASE( rt->surface );
313
+ }
314
+ for( i = 0; i < g_RenderTargetList.count; i++ )
315
+ {
316
+ struct DXRubyRenderTarget *rt = (struct DXRubyRenderTarget *)g_RenderTargetList.pointer[i];
317
+ if( g_RenderTargetList.pointer[i] )
318
+ {
319
+ RELEASE( rt->surface );
320
+ RELEASE( rt->texture->pD3DTexture );
321
+ }
322
+ }
323
+
324
+ /* �V�F�[�_�̃��X�g */
325
+ for( i = 0; i < g_ShaderCoreList.count; i++ )
326
+ {
327
+ struct DXRubyShaderCore *core = (struct DXRubyShaderCore *)g_ShaderCoreList.pointer[i];
328
+ core->pD3DXEffect->lpVtbl->OnLostDevice( core->pD3DXEffect );
329
+ }
330
+
331
+ hr = g_pD3DDevice->lpVtbl->Reset( g_pD3DDevice, &g_D3DPP ); /* ���������݂� */
332
+ if( FAILED( hr ) )
333
+ {
334
+ if( hr == D3DERR_DEVICELOST )
335
+ {
336
+ return 5; /* �܂����X�g���� */
337
+ }
338
+ if( hr == D3DERR_INVALIDCALL )
339
+ {
340
+ return 10;
341
+ }
342
+ return 1;
343
+ }
344
+
345
+ /* �����_�[�^�[�Q�b�g�̕��� */
346
+ {
347
+ struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, g_WindowInfo.render_target );
348
+ g_pD3DDevice->lpVtbl->GetRenderTarget( g_pD3DDevice, 0, &rt->surface );
349
+ }
350
+ for( i = 0; i < g_RenderTargetList.count; i++ )
351
+ {
352
+ struct DXRubyRenderTarget *rt = (struct DXRubyRenderTarget *)g_RenderTargetList.pointer[i];
353
+ if( g_RenderTargetList.pointer[i] )
354
+ {
355
+ /* �e�N�X�`���I�u�W�F�N�g���쐬���� */
356
+ hr = D3DXCreateTexture( g_pD3DDevice, (UINT)rt->texture->width, (UINT)rt->texture->height,
357
+ 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT,
358
+ &rt->texture->pD3DTexture);
359
+ if( FAILED( hr ) ) return 2;
360
+
361
+ hr = rt->texture->pD3DTexture->lpVtbl->GetSurfaceLevel( rt->texture->pD3DTexture, 0, &rt->surface );
362
+ if( FAILED( hr ) ) return 3;
363
+ }
364
+ }
365
+
366
+ /* �V�F�[�_�̕��A */
367
+ for( i = 0; i < g_ShaderCoreList.count; i++ )
368
+ {
369
+ struct DXRubyShaderCore *core = (struct DXRubyShaderCore *)g_ShaderCoreList.pointer[i];
370
+ core->pD3DXEffect->lpVtbl->OnResetDevice( core->pD3DXEffect );
371
+ }
372
+
373
+ if( g_pD3DXSprite ) /* D3DXSprite���A */
374
+ {
375
+ g_pD3DXSprite->lpVtbl->OnResetDevice( g_pD3DXSprite );
376
+ }
377
+ }
378
+ else if( hr == D3DERR_DEVICELOST ) /* �f�o�C�X�̓��X�g��Ԃł��� */
379
+ {
380
+ return 5; /* ���̋@��� */
381
+ }
382
+ else /* DirectX�̓����G���[ */
383
+ {
384
+ return 4;
385
+ }
386
+
387
+ return 0;
388
+ }
389
+
390
+
391
+ /*--------------------------------------------------------------------
392
+ �X���b�h���C��
393
+ ---------------------------------------------------------------------*/
394
+ static DWORD WINAPI MessageThreadProc( LPVOID lpParameter )
395
+ {
396
+ MSG msg;
397
+ msg.message = WM_NULL;
398
+
399
+ CoInitializeEx( NULL, COINIT_MULTITHREADED );
400
+
401
+ /* �E�B���h�E�쐬(���̎��_�ł͔�\��) */
402
+ InitWindow();
403
+ if( MainThreadError != 0 )
404
+ {
405
+ SetEvent( hEventMainThreadStart );
406
+ ExitThread( 0 );
407
+ }
408
+
409
+ /* DirectX Graphics�̏����� */
410
+ InitDXGraphics();
411
+ if( MainThreadError != 0 )
412
+ {
413
+ SetEvent( hEventMainThreadStart );
414
+ ExitThread( 0 );
415
+ }
416
+
417
+ /* DirectInput������ */
418
+ InitDirectInput();
419
+ if( MainThreadError != 0 )
420
+ {
421
+ SetEvent( hEventMainThreadStart );
422
+ ExitThread( 0 );
423
+ }
424
+
425
+ /* ���������I��������Ƃ̒ʒm */
426
+ SetEvent( hEventMainThreadStart );
427
+
428
+ /* ���b�Z�[�W���[�v */
429
+ /* WM_QUIT���͂��܂Ń��b�Z�[�W�������������� */
430
+ while( msg.message != WM_QUIT )
431
+ {
432
+ if( GetMessage( &msg, 0, 0, 0 ) != 0)
433
+ // if( PeekMessage( &msg, g_hWnd, 0, 0, PM_REMOVE ) != 0)
434
+ {
435
+ /* ���b�Z�[�W�����鎞 */
436
+ TranslateMessage( &msg );
437
+ DispatchMessage( &msg );
438
+ }
439
+ // g_byMouseState_L_buf = GetKeyState( VK_LBUTTON );
440
+ // g_byMouseState_M_buf = GetKeyState( VK_MBUTTON );
441
+ // g_byMouseState_R_buf = GetKeyState( VK_RBUTTON );
442
+ }
443
+
444
+ DXRelease();
445
+
446
+ CoUninitialize();
447
+
448
+ // �X���b�h�I��
449
+ ExitThread( 0 );
450
+ }
451
+
452
+ /*--------------------------------------------------------------------
453
+ �i�����֐��j�E�B���h�E�v���V�[�W��
454
+ ---------------------------------------------------------------------*/
455
+ LRESULT CALLBACK MessageThreadWndProc( HWND hWnd, UINT msg, UINT wParam, LONG lParam )
456
+ {
457
+ RECT rect;
458
+ VALUE temp;
459
+
460
+ switch( msg )
461
+ {
462
+ case WM_CREATE:
463
+ break;
464
+
465
+ case WM_ACTIVATE:
466
+ /* �E�B���h�E�A�N�e�B�u�^��A�N�e�B�u�� */
467
+ g_WindowInfo.active = (LOWORD(wParam) != 0);
468
+ break;
469
+
470
+ case WM_CLOSE:
471
+ g_WindowInfo.requestclose = 1;
472
+ return 0;
473
+
474
+ case WM_DESTROY:
475
+ /* �E�B���h�E�j�� */
476
+ PostQuitMessage( 0 );
477
+ g_hWnd = NULL;
478
+ return 0;
479
+
480
+ case WM_MOUSEWHEEL:
481
+ g_WindowInfo.mousewheelpos += (short)HIWORD(wParam);
482
+ break;
483
+
484
+ case WM_LBUTTONDOWN:
485
+ g_byMouseState_L_buf = 0x80;
486
+ SetCapture(g_hWnd);
487
+ break;
488
+ case WM_LBUTTONUP:
489
+ g_byMouseState_L_buf = 0x00;
490
+ ReleaseCapture();
491
+ break;
492
+ case WM_MBUTTONDOWN:
493
+ g_byMouseState_M_buf = 0x80;
494
+ SetCapture(g_hWnd);
495
+ break;
496
+ case WM_MBUTTONUP:
497
+ g_byMouseState_M_buf = 0x00;
498
+ ReleaseCapture();
499
+ break;
500
+ case WM_RBUTTONDOWN:
501
+ g_byMouseState_R_buf = 0x80;
502
+ SetCapture(g_hWnd);
503
+ break;
504
+ case WM_RBUTTONUP:
505
+ g_byMouseState_R_buf = 0x00;
506
+ ReleaseCapture();
507
+ break;
508
+
509
+ #ifdef DXRUBY15
510
+ case WM_KEYDOWN:
511
+ EnterCriticalSection( &ime_cs );
512
+ if( ime_vk_push_str_length+1 >= IME_VK_BUF_SIZE-1 ) /* �o�b�t�@�I�[�o�[������N���A�����Ⴄ */
513
+ {
514
+ ime_vk_push_str_length = 0;
515
+ }
516
+ ime_vk_push_buf[ime_vk_push_str_length++] = (char)wParam;
517
+ LeaveCriticalSection( &ime_cs );
518
+ return 0;
519
+
520
+ case WM_KEYUP:
521
+ EnterCriticalSection( &ime_cs );
522
+ if( ime_vk_release_str_length+1 >= IME_VK_BUF_SIZE-1 ) /* �o�b�t�@�I�[�o�[������N���A�����Ⴄ */
523
+ {
524
+ ime_vk_release_str_length = 0;
525
+ }
526
+ ime_vk_release_buf[ime_vk_release_str_length++] = (char)wParam;
527
+ LeaveCriticalSection( &ime_cs );
528
+ return 0;
529
+
530
+ case WM_CHAR:
531
+ if( wParam < 32 )
532
+ {
533
+ return 0;
534
+ }
535
+
536
+ EnterCriticalSection( &ime_cs );
537
+ if( ime_str_length+1 >= IME_BUF_SIZE-1 ) /* �o�b�t�@�I�[�o�[������N���A�����Ⴄ */
538
+ {
539
+ ime_str_length = 0;
540
+ }
541
+ MultiByteToWideChar( CP_ACP, 0, (char *)&wParam, 1, (LPWSTR)&ime_buf[ime_str_length], 2 );
542
+ ime_str_length += 1;
543
+ ime_buf[ime_str_length] = 0;
544
+ LeaveCriticalSection( &ime_cs );
545
+ return 0;
546
+
547
+ case WM_IME_CHAR:
548
+ if( ((char)(wParam >> 8) & 0xff) != 0 )
549
+ {
550
+ EnterCriticalSection( &ime_cs );
551
+ if( ime_str_length+1 >= IME_BUF_SIZE-1 ) /* �o�b�t�@�I�[�o�[������N���A�����Ⴄ */
552
+ {
553
+ ime_str_length = 0;
554
+ }
555
+ wParam = ((wParam >> 8) & 0xff) + ((wParam & 0xff) << 8);
556
+ MultiByteToWideChar( CP_ACP, 0, (char *)&wParam, 2, (LPWSTR)&ime_buf[ime_str_length], 2 );
557
+ ime_str_length += 1;
558
+ ime_buf[ime_str_length] = 0;
559
+ LeaveCriticalSection( &ime_cs );
560
+ return 0;
561
+ }
562
+ break;
563
+ #endif
564
+
565
+ case WM_APP + 0:
566
+ /* �f�o�C�X�̃��Z�b�g */
567
+ return reset();
568
+
569
+ case WM_APP + 1:
570
+ /* �E�B���h�E�̐ݒ�ύX */
571
+ return ChangeSize();
572
+
573
+ case WM_APP + 2:
574
+ /* �J�[�\���̕\�� */
575
+ while( ShowCursor( TRUE ) < 0 );
576
+ g_WindowInfo.enablemouse = 1;
577
+ return 0;
578
+
579
+ case WM_APP + 3:
580
+ /* �J�[�\���̔�\�� */
581
+ while( ShowCursor( FALSE ) >= 0 );
582
+ g_WindowInfo.enablemouse = 0;
583
+ return 0;
584
+
585
+ case WM_APP + 4:
586
+ /* �J�[�\���̕ύX */
587
+ SetCursor( LoadCursor( NULL, (LPSTR)lParam ));
588
+ return 0;
589
+
590
+ #ifdef DXRUBY15
591
+ case WM_APP + 6:
592
+ /* IME�̗L����/������ */
593
+ if( (int)lParam )
594
+ {
595
+ if( default_imc )
596
+ {
597
+ ImmAssociateContext( g_hWnd, default_imc );
598
+ default_imc = NULL;
599
+ }
600
+ }
601
+ else
602
+ {
603
+ if( !default_imc )
604
+ {
605
+ default_imc = ImmAssociateContext( g_hWnd, NULL );
606
+ }
607
+ }
608
+
609
+ return 0;
610
+
611
+ case WM_APP + 7:
612
+ /* IME�̏�Ԃ�Ԃ� */
613
+ // return WINNLSGetEnableStatus( g_hWnd );
614
+ return !!default_imc;
615
+
616
+ case WM_IME_STARTCOMPOSITION:
617
+ ime_compositing = 1;
618
+ return 0;
619
+
620
+ case WM_IME_ENDCOMPOSITION:
621
+ ime_compositing = 0;
622
+ EnterCriticalSection( &ime_cs );
623
+ if( ime_composition_str && ime_composition_str != ime_composition_str_old )
624
+ {
625
+ free( ime_composition_str );
626
+ }
627
+ ime_composition_str = NULL;
628
+
629
+ if( ime_composition_attr && ime_composition_attr != ime_composition_attr_old )
630
+ {
631
+ free( ime_composition_attr );
632
+ }
633
+ ime_composition_attr = NULL;
634
+ ime_composition_attr_size = 0;
635
+
636
+ if( ime_canlist && ime_canlist != ime_canlist_old )
637
+ {
638
+ free( ime_canlist );
639
+ }
640
+ ime_canlist = NULL;
641
+
642
+ ime_cursor_pos = 0;
643
+
644
+ LeaveCriticalSection( &ime_cs );
645
+ return 0;
646
+
647
+ case WM_IME_COMPOSITION:
648
+ {
649
+ int len;
650
+ HIMC hIMC = ImmGetContext( g_hWnd );
651
+ int flag = 0;
652
+
653
+ EnterCriticalSection( &ime_cs );
654
+ if( lParam & GCS_COMPSTR )
655
+ {
656
+ if( ime_composition_str && ime_composition_str != ime_composition_str_old )
657
+ {
658
+ free( ime_composition_str );
659
+ }
660
+
661
+ len = ImmGetCompositionStringW( hIMC, GCS_COMPSTR, 0, 0 );
662
+ if( len )
663
+ {
664
+ ime_composition_str = (WCHAR *)malloc( len + 2 );
665
+ len = ImmGetCompositionStringW( hIMC, GCS_COMPSTR, ime_composition_str, len );
666
+ ime_composition_str[len / 2] = 0;
667
+ }
668
+ else
669
+ {
670
+ ime_composition_str = NULL;
671
+ }
672
+ }
673
+ if( lParam & GCS_COMPATTR )
674
+ {
675
+ if( ime_composition_attr && ime_composition_attr != ime_composition_attr_old )
676
+ {
677
+ free( ime_composition_attr );
678
+ }
679
+
680
+ len = ImmGetCompositionStringW( hIMC, GCS_COMPATTR, 0, 0 );
681
+ if( len )
682
+ {
683
+ ime_composition_attr = (char *)malloc( len );
684
+ ime_composition_attr_size = ImmGetCompositionStringW( hIMC, GCS_COMPATTR, ime_composition_attr, len );
685
+ }
686
+ else
687
+ {
688
+ ime_composition_attr = NULL;
689
+ ime_composition_attr_size = 0;
690
+ }
691
+ }
692
+ if( lParam & GCS_CURSORPOS )
693
+ {
694
+ ime_cursor_pos = ImmGetCompositionStringW( hIMC, GCS_CURSORPOS, NULL, 0 );
695
+ }
696
+ if( lParam & GCS_RESULTSTR )
697
+ {
698
+ WCHAR *temp;
699
+
700
+ len = ImmGetCompositionStringW( hIMC, GCS_RESULTSTR, 0, 0 );
701
+
702
+ if( len > IME_BUF_SIZE + 2 )
703
+ {
704
+ return 0;
705
+ }
706
+
707
+ if( ime_str_length + len + 1 >= IME_BUF_SIZE-1 ) /* �o�b�t�@�I�[�o�[������N���A�����Ⴄ */
708
+ {
709
+ ime_str_length = 0;
710
+ }
711
+
712
+ len = ImmGetCompositionStringW( hIMC, GCS_RESULTSTR, (LPWSTR)&ime_buf[ime_str_length], len );
713
+ ime_str_length += len / 2;
714
+ ime_buf[ime_str_length] = 0;
715
+ flag = 1;
716
+ }
717
+ LeaveCriticalSection( &ime_cs );
718
+ ImmReleaseContext( g_hWnd, hIMC );
719
+ if( flag )
720
+ {
721
+ return 0;
722
+ }
723
+ }
724
+ break;
725
+ case WM_IME_SETCONTEXT:
726
+ lParam &= ~ISC_SHOWUIALL;
727
+ break;
728
+ case WM_IME_NOTIFY:
729
+ switch( wParam ) {
730
+ case IMN_OPENSTATUSWINDOW:
731
+ case IMN_CLOSESTATUSWINDOW:
732
+ return 0;
733
+ case IMN_OPENCANDIDATE:
734
+ case IMN_CHANGECANDIDATE:
735
+ {
736
+ int len;
737
+ HIMC hIMC;
738
+
739
+ EnterCriticalSection( &ime_cs );
740
+ hIMC = ImmGetContext( g_hWnd );
741
+
742
+ if( ime_canlist && ime_canlist != ime_canlist_old )
743
+ {
744
+ free( ime_canlist );
745
+ }
746
+
747
+ len = ImmGetCandidateListW( hIMC, 0, NULL, 0 );
748
+ if( len )
749
+ {
750
+ ime_canlist = (LPCANDIDATELIST)malloc( len );
751
+ ImmGetCandidateListW(hIMC, 0, ime_canlist, len);
752
+ }
753
+ else
754
+ {
755
+ ime_canlist = NULL;
756
+ }
757
+
758
+ ImmReleaseContext( g_hWnd, hIMC );
759
+ LeaveCriticalSection( &ime_cs );
760
+ return 0;
761
+ }
762
+ case IMN_CLOSECANDIDATE:
763
+ {
764
+ EnterCriticalSection( &ime_cs );
765
+ if( ime_canlist && ime_canlist != ime_canlist_old )
766
+ {
767
+ free( ime_canlist );
768
+ }
769
+ ime_canlist = NULL;
770
+ LeaveCriticalSection( &ime_cs );
771
+ return 0;
772
+ }
773
+ default:
774
+ break;
775
+ }
776
+ #endif
777
+ }
778
+
779
+ /* �f�t�H���g���� */
780
+ return DefWindowProc( hWnd, msg, wParam, lParam );
781
+ }
782
+
783
+ /*--------------------------------------------------------------------
784
+ �i�����֐��j�E�B���h�E�̐���
785
+ ---------------------------------------------------------------------*/
786
+ static int InitWindow( void )
787
+ {
788
+ WNDCLASSEX wcex;
789
+ RECT rect;
790
+
791
+ /* �E�C���h�E�E�N���X�̓o�^ */
792
+ wcex.cbSize = sizeof( WNDCLASSEX );
793
+ wcex.style = CS_HREDRAW | CS_VREDRAW;
794
+ wcex.lpfnWndProc = (WNDPROC)MessageThreadWndProc;
795
+ wcex.cbClsExtra = 0;
796
+ wcex.cbWndExtra = 0;
797
+ wcex.hInstance = g_hInstance;
798
+ wcex.hIcon = NULL;
799
+ wcex.hIconSm = NULL;
800
+ wcex.hCursor = NULL;//LoadCursor( NULL, IDC_ARROW );
801
+ wcex.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 );
802
+ wcex.lpszMenuName = NULL;
803
+ wcex.lpszClassName = "DXRuby";
804
+
805
+ if( !RegisterClassEx( &wcex ) )
806
+ {
807
+ MainThreadError = 1;
808
+ return MainThreadError;
809
+ }
810
+
811
+ /* ���C���E�E�C���h�E�쐬(�E�C���h�E�E���[�h�p) */
812
+ rect.top = 0;
813
+ rect.left = 0;
814
+ rect.right = g_WindowInfo.width;
815
+ rect.bottom = g_WindowInfo.height;
816
+
817
+ AdjustWindowRect( &rect, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, FALSE );
818
+
819
+ rect.right = rect.right - rect.left;
820
+ rect.bottom = rect.bottom - rect.top;
821
+ rect.left = 0;
822
+ rect.top = 0;
823
+
824
+ g_hWnd = CreateWindow( TEXT("DXRuby"), TEXT("DXRuby Application"),
825
+ WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
826
+ CW_USEDEFAULT, CW_USEDEFAULT,
827
+ rect.right - rect.left, rect.bottom - rect.top,
828
+ NULL, NULL, g_hInstance, NULL );
829
+ if( g_hWnd == NULL )
830
+ {
831
+ MainThreadError = 2;
832
+ return MainThreadError;
833
+ }
834
+
835
+ GetWindowRect( g_hWnd, &rect );
836
+ g_WindowInfo.x = rect.left;
837
+ g_WindowInfo.y = rect.top;
838
+
839
+ return 0;
840
+ }
841
+
842
+
843
+ /*--------------------------------------------------------------------
844
+ �i�����֐��jDirectX Graphics������
845
+ ---------------------------------------------------------------------*/
846
+ static int InitDXGraphics( void )
847
+ {
848
+ D3DVIEWPORT9 vp;
849
+ HRESULT hr;
850
+
851
+ /* Direct3D�I�u�W�F�N�g�̍쐬 */
852
+ g_pD3D = Direct3DCreate9( D3D_SDK_VERSION );
853
+
854
+ if( g_pD3D == NULL )
855
+ {
856
+ MainThreadError = 3;
857
+ return MainThreadError;
858
+ }
859
+
860
+ /* D3DDevice�I�u�W�F�N�g�̍쐬(�E�C���h�E�E���[�h) */
861
+ ZeroMemory( &g_D3DPP, sizeof( g_D3DPP ) );
862
+
863
+ g_D3DPP.BackBufferWidth = 0;
864
+ g_D3DPP.BackBufferHeight = 0;
865
+ g_D3DPP.BackBufferFormat = D3DFMT_UNKNOWN;
866
+ g_D3DPP.BackBufferCount = 2;
867
+ g_D3DPP.MultiSampleType = D3DMULTISAMPLE_NONE;
868
+ g_D3DPP.MultiSampleQuality = 0;
869
+ g_D3DPP.SwapEffect = D3DSWAPEFFECT_DISCARD;
870
+ g_D3DPP.hDeviceWindow = g_hWnd;
871
+ g_D3DPP.Windowed = TRUE;
872
+ g_D3DPP.EnableAutoDepthStencil = TRUE;
873
+ g_D3DPP.AutoDepthStencilFormat = D3DFMT_D24S8;
874
+ g_D3DPP.Flags = 0;
875
+ g_D3DPP.FullScreen_RefreshRateInHz = 0;
876
+ g_D3DPP.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
877
+
878
+ hr = g_pD3D->lpVtbl->CreateDevice( g_pD3D, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd,
879
+ D3DCREATE_MIXED_VERTEXPROCESSING, &g_D3DPP, &g_pD3DDevice );
880
+
881
+ if( FAILED( hr ) )
882
+ {
883
+ hr = g_pD3D->lpVtbl->CreateDevice( g_pD3D, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd,
884
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING, &g_D3DPP, &g_pD3DDevice );
885
+
886
+ if( FAILED( hr ) )
887
+ {
888
+ MainThreadError = 4;
889
+ return MainThreadError;
890
+ }
891
+ }
892
+
893
+ /* �r���[�|�[�g�̐ݒ� */
894
+ vp.X = 0;
895
+ vp.Y = 0;
896
+ vp.Width = g_D3DPP.BackBufferWidth;
897
+ vp.Height = g_D3DPP.BackBufferHeight;
898
+ vp.MinZ = 0.0f;
899
+ vp.MaxZ = 1.0f;
900
+
901
+ hr = g_pD3DDevice->lpVtbl->SetViewport( g_pD3DDevice, &vp );
902
+
903
+ if( FAILED( hr ) )
904
+ {
905
+ MainThreadError = 5;
906
+ return MainThreadError;
907
+ }
908
+
909
+ g_pD3DDevice->lpVtbl->Clear( g_pD3DDevice, 0, NULL, D3DCLEAR_TARGET,
910
+ D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );
911
+
912
+ /* D3DXSprite�I�u�W�F�N�g�쐬 */
913
+ hr = D3DXCreateSprite( g_pD3DDevice, &g_pD3DXSprite );
914
+
915
+ if( FAILED( hr ) )
916
+ {
917
+ MainThreadError = 6;
918
+ return MainThreadError;
919
+ }
920
+
921
+ return 0;
922
+ }
923
+
924
+ /*--------------------------------------------------------------------
925
+ DirectX�I�u�W�F�N�g���������
926
+ ---------------------------------------------------------------------*/
927
+ static void DXRelease()
928
+ {
929
+ int i;
930
+ HRESULT hr;
931
+
932
+ /* �~�`��pShader��� */
933
+ RELEASE( g_WindowInfo.pD3DXEffectCircleShader );
934
+ RELEASE( g_WindowInfo.pD3DXEffectCircleFillShader );
935
+
936
+ /* D3DXSprite�I�u�W�F�N�g�̎g�p�I�� */
937
+ if( g_pD3DXSprite )
938
+ {
939
+ g_pD3DXSprite->lpVtbl->OnLostDevice( g_pD3DXSprite );
940
+ }
941
+
942
+ /* DirectInput��� */
943
+ Input_release();
944
+
945
+ /* D3DXSprite�I�u�W�F�N�g�j�� */
946
+ RELEASE( g_pD3DXSprite );
947
+
948
+ /* Direct3D Device�I�u�W�F�N�g�̔j�� */
949
+ RELEASE( g_pD3DDevice );
950
+
951
+ /* Direct3D�I�u�W�F�N�g�̔j�� */
952
+ RELEASE( g_pD3D );
953
+ }
954
+
955
+
956
+ void InitMessageThread( void )
957
+ {
958
+ hEventMainThreadStart = CreateEvent( NULL, FALSE, FALSE, NULL );
959
+
960
+ #ifdef DXRUBY15
961
+ ime_str_length = 0;
962
+ ime_buf = malloc( IME_BUF_SIZE * sizeof(WCHAR) );
963
+ ime_buf[0] = 0;
964
+ ime_buf_old = malloc( IME_BUF_SIZE * sizeof(WCHAR) );
965
+ ime_buf_old[0] = 0;
966
+ InitializeCriticalSection( &ime_cs );
967
+ ime_compositing = 0;
968
+
969
+ ime_vk_push_str_length = 0;
970
+ ime_vk_push_buf = malloc( IME_VK_BUF_SIZE );
971
+ ime_vk_push_buf[0] = 0;
972
+ ime_vk_push_buf_old = malloc( IME_VK_BUF_SIZE );
973
+ ime_vk_push_buf_old[0] = 0;
974
+
975
+ ime_vk_release_str_length = 0;
976
+ ime_vk_release_buf = malloc( IME_VK_BUF_SIZE );
977
+ ime_vk_release_buf[0] = 0;
978
+ ime_vk_release_buf_old = malloc( IME_VK_BUF_SIZE );
979
+ ime_vk_release_buf_old[0] = 0;
980
+ #endif
981
+
982
+ hMessageThread = CreateThread( NULL, 0, &MessageThreadProc, 0, 0, &MessageThreadID );
983
+ {
984
+ unsigned long result = WaitForSingleObject( hEventMainThreadStart, INFINITE );
985
+ switch( MainThreadError )
986
+ {
987
+ case 0:
988
+ break;
989
+ case 1:
990
+ DXRuby_raise( ERR_WINDOWCREATE, "RegisterClassEx" );
991
+ break;
992
+ case 2:
993
+ DXRuby_raise( ERR_WINDOWCREATE, "CreateWindow" );
994
+ break;
995
+ case 3:
996
+ DXRuby_raise( ERR_D3DERROR, "Direct3DCreate9" );
997
+ break;
998
+ case 4:
999
+ DXRuby_raise( ERR_D3DERROR, "CreateDevice" );
1000
+ break;
1001
+ case 5:
1002
+ DXRuby_raise( ERR_D3DERROR, "SetViewport" );
1003
+ break;
1004
+ case 6:
1005
+ DXRuby_raise( ERR_D3DERROR, "D3DXCreateSprite" );
1006
+ break;
1007
+ case 7:
1008
+ DXRuby_raise( ERR_D3DERROR, "GetSwapChain" );
1009
+ break;
1010
+ case 10:
1011
+ DXRuby_raise( ERR_DINPUTERROR, "DirectInput8Create" );
1012
+ break;
1013
+ case 11:
1014
+ DXRuby_raise( ERR_DINPUTERROR, "CreateDevice" );
1015
+ break;
1016
+ case 12:
1017
+ DXRuby_raise( ERR_DINPUTERROR, "SetDataFormat" );
1018
+ break;
1019
+ case 13:
1020
+ DXRuby_raise( ERR_DINPUTERROR, "SetCooperativeLevel" );
1021
+ break;
1022
+ case 14:
1023
+ DXRuby_raise( ERR_DINPUTERROR, "EnumDevices" );
1024
+ break;
1025
+ case 15:
1026
+ DXRuby_raise( ERR_DINPUTERROR, "SetDataFormat" );
1027
+ break;
1028
+ case 16:
1029
+ DXRuby_raise( ERR_DINPUTERROR, "SetCooperativeLevel" );
1030
+ break;
1031
+ case 17:
1032
+ DXRuby_raise( ERR_DINPUTERROR, "GetProperty" );
1033
+ break;
1034
+ case 18:
1035
+ DXRuby_raise( ERR_DINPUTERROR, "EnumObjects" );
1036
+ break;
1037
+ }
1038
+ }
1039
+ }
1040
+
1041
+ void ExitMessageThread( void )
1042
+ {
1043
+ DWORD exitcode;
1044
+
1045
+ if( g_hWnd != NULL )
1046
+ {
1047
+ SendMessage( g_hWnd, WM_DESTROY, 0, 0 );
1048
+ }
1049
+
1050
+ // do
1051
+ // {
1052
+ // if( !GetExitCodeThread( hMessageThread, &exitcode ) )
1053
+ // {
1054
+ // rb_raise( eDXRubyError, "Therad exit error - ExitMessageThread" );
1055
+ // }
1056
+ // Sleep(1);
1057
+ // }
1058
+ // while( exitcode == STILL_ACTIVE );
1059
+
1060
+ #ifdef DXRUBY15
1061
+ free( ime_buf );
1062
+ free( ime_buf_old );
1063
+ free( ime_vk_push_buf );
1064
+ free( ime_vk_push_buf_old );
1065
+ free( ime_vk_release_buf );
1066
+ free( ime_vk_release_buf_old );
1067
+ if( ime_canlist )
1068
+ {
1069
+ free( ime_canlist );
1070
+ }
1071
+ if( ime_canlist_old && ime_canlist != ime_canlist_old )
1072
+ {
1073
+ free( ime_canlist_old );
1074
+ }
1075
+ if( ime_composition_str )
1076
+ {
1077
+ free( ime_composition_str );
1078
+ }
1079
+ if( ime_composition_str_old && ime_composition_str != ime_composition_str_old )
1080
+ {
1081
+ free( ime_composition_str_old );
1082
+ }
1083
+ if( ime_composition_attr )
1084
+ {
1085
+ free( ime_composition_attr );
1086
+ }
1087
+ if( ime_composition_attr_old && ime_composition_attr != ime_composition_attr_old )
1088
+ {
1089
+ free( ime_composition_attr_old );
1090
+ }
1091
+
1092
+ DeleteCriticalSection( &ime_cs );
1093
+ #endif
1094
+
1095
+ /* �E�C���h�E�E�N���X�̓o�^���� */
1096
+ UnregisterClass( "DXRuby", g_hInstance );
1097
+
1098
+ CloseHandle( hMessageThread );
1099
+ }
1100
+
1101
+
1102
+ void WindowCreateMessage( void )
1103
+ {
1104
+ int ret;
1105
+
1106
+ ret = SendMessage( g_hWnd, WM_APP + 1, 0, 0 );
1107
+
1108
+ switch( ret )
1109
+ {
1110
+ case 0:
1111
+ break;
1112
+ case 1:
1113
+ DXRuby_raise( ERR_NOEXISTSCREENMODE, "Reset" );
1114
+ break;
1115
+ case 2:
1116
+ DXRuby_raise( ERR_INTERNAL, "D3DXCreateTexture" );
1117
+ break;
1118
+ case 3:
1119
+ DXRuby_raise( ERR_INTERNAL, "GetSurfaceLevel" );
1120
+ break;
1121
+ case 4:
1122
+ DXRuby_raise( ERR_INTERNAL, "TestCooperativeLevel" );
1123
+ break;
1124
+ }
1125
+ }
1126
+
1127
+ int ResetMessage( void )
1128
+ {
1129
+ int ret;
1130
+ /* �f�o�C�X���X�g�̏ꍇ�̏��� */
1131
+ ret = SendMessage( g_hWnd, WM_APP + 0, 0, 0 );
1132
+ switch( ret )
1133
+ {
1134
+ case 0:
1135
+ case 5:
1136
+ break;
1137
+ case 1:
1138
+ DXRuby_raise( ERR_INTERNAL, "Reset" );
1139
+ break;
1140
+ case 2:
1141
+ DXRuby_raise( ERR_INTERNAL, "D3DXCreateTexture" );
1142
+ break;
1143
+ case 3:
1144
+ DXRuby_raise( ERR_INTERNAL, "GetSurfaceLevel" );
1145
+ break;
1146
+ case 4:
1147
+ DXRuby_raise( ERR_INTERNAL, "TestCooperativeLevel" );
1148
+ break;
1149
+ case 10:
1150
+ DXRuby_raise( ERR_INTERNAL, "Reset_InvaridCall" );
1151
+ break;
1152
+ }
1153
+ Sleep(100); /* �Ƃ肠����wait */
1154
+ return ret;
1155
+ }
1156
+
1157
+ void ShowCursorMessage( void )
1158
+ {
1159
+ SendMessage( g_hWnd, WM_APP + 2, 0, 0 );
1160
+ }
1161
+
1162
+ void HideCursorMessage( void )
1163
+ {
1164
+ SendMessage( g_hWnd, WM_APP + 3, 0, 0 );
1165
+ }
1166
+
1167
+ void SetCursorMessage( int cursorname )
1168
+ {
1169
+ SendMessage( g_hWnd, WM_APP + 4, 0, cursorname );
1170
+ }
1171
+
1172
+ void SetImeEnable( int flag )
1173
+ {
1174
+ SendMessage( g_hWnd, WM_APP + 6, 0, flag );
1175
+ }
1176
+
1177
+ int GetImeEnable( void )
1178
+ {
1179
+ return SendMessage( g_hWnd, WM_APP + 7, 0, 0 );
1180
+ }