1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
/*
 *  ReactOS Winhello - Not So Simple Win32 Windowing test
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/* What do we test with this app?
 * - Windows and Class creation
 * - A Simple Button
 * - Some font rendering in the Window
 * - Scrollbar support
 * - Hotkeys
 * - Messageboxes
 * ????????
 */

#ifndef VK_C
#define VK_C 'C'
#endif

#include <windows.h>
#include <stdio.h>
#include <tchar.h>

HFONT tf;
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
BOOLEAN bolWM_CHAR;
BOOLEAN bolWM_KEYDOWN;

int WINAPI
WinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR lpszCmdLine,
	int nCmdShow)
{
  WNDCLASS wc;
  MSG msg;
  HWND hWnd;
  bolWM_CHAR = 0;
  bolWM_KEYDOWN = 0;

  wc.lpszClassName = "HelloClass";
  wc.lpfnWndProc = MainWndProc;
  wc.style = CS_VREDRAW | CS_HREDRAW;
  wc.hInstance = hInstance;
  wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
  wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
  wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
  wc.lpszMenuName = NULL;
  wc.cbClsExtra = 0;
  wc.cbWndExtra = 0;
  if (RegisterClass(&wc) == 0)
    {
      fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
	      GetLastError());
      return(1);
    }

  hWnd = CreateWindow("HelloClass",
	          "Hello World",
	          WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
	          0, //Position; you can use CW_USEDEFAULT, too
	          0,
	          600, //height
	          400,
	          NULL,
	          NULL,
	          hInstance,
	          NULL);
  if (hWnd == NULL)
    {
      fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
	      GetLastError());
      return(1);
    }

	tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
	    ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
	    DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");

  ShowWindow(hWnd, nCmdShow);

  while(GetMessage(&msg, NULL, 0, 0))
  {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
  }

  DeleteObject(tf);

  return msg.wParam;
}

#define CTRLC 1 /* Define our HotKeys */
#define ALTF1 2 /* Define our HotKeys */

LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
        PAINTSTRUCT   ps;    /* Also used during window drawing */
        HDC hDC;             /* A device context used for drawing */
        RECT rc = {0,0,0,0}, clr, wir;   /* A rectangle used during drawing */
        char spr[100], sir[100];
	static HBRUSH hbrWhite=NULL, hbrGray=NULL, hbrBlack=NULL, hbrRed=NULL, hbrBlue=NULL, hbrYellow=NULL;

        /* The window handle for the "Click Me" button. */
        static HWND   hwndButton = 0;
        static int    cx, cy;          /* Height and width of our button. */

	switch(msg)
	{

	  case WM_CHAR:
	  {
	   TCHAR text[2];
	   hDC = GetDC(hWnd);
 	   text[0] = (TCHAR)wParam;
	   text[1] = _T('\0');

	   //Write in window
	   if( bolWM_KEYDOWN )
	   {
       	        TextOut(hDC, 400, 10, "WM CHAR:", strlen("WM CHAR:"));
       	        bolWM_KEYDOWN = 0;
	   }
	   else
	   {
	        TextOut(hDC, 400, 10, "WM_CHAR:", strlen("WM_CHAR:"));
	        bolWM_KEYDOWN = 1;
	   }
	   TextOut(hDC, 530, 10, text, strlen(text));

#if 0
	   // Make a line depending on the typed key
	   Rect.left = 10;
	   Rect.top = 75;
	   Rect.right = 610;
	   Rect.bottom = 85;
	   FillRect(hDC, &Rect, hbrWhite);

	   Rect.left=308;
	   Rect.right=312;
	   FillRect(hDC, &Rect, hbrRed);

	   Rect.left = 310;
	   Rect.top = 75;
	   Rect.right = 310 +text[0]*2;
	   Rect.bottom = 85;
	   HBRUSH hbrCustom = CreateSolidBrush ( RGB(text[0], text[0], text[0]));
	   FillRect(hDC, &Rect, hbrCustom);
	   DeleteObject ( hbrCustom );

#endif

	   ReleaseDC(hWnd, hDC);
	   return 0;
	 }

	  case WM_KEYDOWN:
	  {
	   RECT Rect;
	   TCHAR text[2];
	   hDC = GetDC(hWnd);
 	   text[0] = (TCHAR)wParam;
	   text[1] = _T('\0');


	   /* Write in window */
	   Rect.left = 400;
	   Rect.top = 50;
	   Rect.right = 550;
	   Rect.bottom = 70;
	   FillRect(hDC, &Rect, hbrWhite);
	   if( bolWM_CHAR )
	   {
	        TextOut(hDC, 400, 30, "WM KEYDOWN:", strlen("WM KEYDOWN:"));
	        bolWM_CHAR = 0;
	   }
	   else
	   {
	        TextOut(hDC, 400, 30, "WM_KEYDOWN:", strlen("WM_KEYDOWN:"));
	        bolWM_CHAR = 1;
	   }
	   TextOut(hDC, 530, 30, text, strlen(text));
	   ReleaseDC(hWnd, hDC);
	   return 0;
	 }

	  case WM_KEYUP:
	  {
	   RECT Rect;
	   TCHAR text[2];
	   hDC = GetDC(hWnd);
 	   text[0] = (TCHAR)wParam;
	   text[1] = _T('\0');


	   /* Write in window */
	   Rect.left = 400;
	   Rect.top = 10;
	   Rect.right = 550;
	   Rect.bottom = 70;
	   FillRect(hDC, &Rect, hbrWhite);
	   TextOut(hDC, 400, 50, "WM_KEYUP:", strlen("WM_KEYUP:"));
	   TextOut(hDC, 530, 50, text, strlen(text));
	   ReleaseDC(hWnd, hDC);
	   return 0;
	 }


        case WM_LBUTTONDOWN:
	 {
	   ULONG x, y;
	   RECT Rect;
	   hDC = GetDC(hWnd);
	   x = LOWORD(lParam);
	   y = HIWORD(lParam);

	   Rect.left = x - 5;
	   Rect.top = y - 5;
	   Rect.right = x + 5;
	   Rect.bottom = y + 5;
	   FillRect(hDC, &Rect, hbrRed);

	   Rect.left = x - 3;
	   Rect.top = y - 3;
	   Rect.right = x + 3;
	   Rect.bottom = y + 3;
	   FillRect(hDC, &Rect, hbrBlack);

           ReleaseDC(hWnd, hDC);
	   break;
	 }
        case WM_LBUTTONUP:
	 {
	   ULONG x, y;
	   RECT Rect;
	   hDC = GetDC(hWnd);
	   x = LOWORD(lParam);
	   y = HIWORD(lParam);

	   Rect.left = x - 5;
	   Rect.top = y - 5;
	   Rect.right = x + 5;
	   Rect.bottom = y + 5;
	   FillRect(hDC, &Rect, hbrRed);

	   Rect.left = x - 3;
	   Rect.top = y - 3;
	   Rect.right = x + 3;
	   Rect.bottom = y + 3;
	   FillRect(hDC, &Rect, hbrGray);

	   ReleaseDC(hWnd, hDC);
	   break;
	 }
        case WM_MBUTTONDOWN:
	 {
	   ULONG x, y;
	   RECT Rect;
	   hDC = GetDC(hWnd);
	   x = LOWORD(lParam);
	   y = HIWORD(lParam);

	   Rect.left = x - 5;
	   Rect.top = y - 5;
	   Rect.right = x + 5;
	   Rect.bottom = y + 5;
	   FillRect(hDC, &Rect, hbrBlue);

	   Rect.left = x - 3;
	   Rect.top = y - 3;
	   Rect.right = x + 3;
	   Rect.bottom = y + 3;
	   FillRect(hDC, &Rect, hbrBlack);

	   ReleaseDC(hWnd, hDC);
	   break;
	 }
        case WM_MBUTTONUP:
	 {
	   ULONG x, y;
	   RECT Rect;
	   hDC = GetDC(hWnd);
	   x = LOWORD(lParam);
	   y = HIWORD(lParam);

	   Rect.left = x - 5;
	   Rect.top = y - 5;
	   Rect.right = x + 5;
	   Rect.bottom = y + 5;
	   FillRect(hDC, &Rect, hbrBlue);

	   Rect.left = x - 3;
	   Rect.top = y - 3;
	   Rect.right = x + 3;
	   Rect.bottom = y + 3;
	   FillRect(hDC, &Rect, hbrGray);

	   ReleaseDC(hWnd, hDC);
	   break;
         }
        case WM_RBUTTONDOWN:
	 {
	   ULONG x, y;
	   RECT Rect;
	   hDC = GetDC(hWnd);
	   x = LOWORD(lParam);
	   y = HIWORD(lParam);

	   Rect.left = x - 5;
	   Rect.top = y - 5;
	   Rect.right = x + 5;
	   Rect.bottom = y + 5;
	   FillRect(hDC, &Rect, hbrYellow);

	   Rect.left = x - 3;
	   Rect.top = y - 3;
	   Rect.right = x + 3;
	   Rect.bottom = y + 3;
	   FillRect(hDC, &Rect, hbrBlack);

	   ReleaseDC(hWnd, hDC);
	   break;
	 }
        case WM_RBUTTONUP:
	 {
	   ULONG x, y;
	   RECT Rect;
	   hDC = GetDC(hWnd);
	   x = LOWORD(lParam);
	   y = HIWORD(lParam);

	   Rect.left = x - 5;
	   Rect.top = y - 5;
	   Rect.right = x + 5;
	   Rect.bottom = y + 5;
	   FillRect(hDC, &Rect, hbrYellow);

	   Rect.left = x - 3;
	   Rect.top = y - 3;
	   Rect.right = x + 3;
	   Rect.bottom = y + 3;
	   FillRect(hDC, &Rect, hbrGray);

	   ReleaseDC(hWnd, hDC);
	   break;
	 }

	case WM_MOUSEMOVE:
         {
          int fwKeys;
          int x;
          int y;
          RECT Rect;
          int temp;
	  TCHAR text[256];

          hDC = GetDC(hWnd);
          fwKeys = wParam;        // key flags
          x = LOWORD(lParam);  // horizontal position of cursor
          y = HIWORD(lParam);  // vertical position of cursor

          Rect.left = 10;
	  Rect.top = 100;
	  Rect.right = 160;
	  Rect.bottom = 300;
	  FillRect(hDC, &Rect, hbrWhite);

          temp = _sntprintf ( text, sizeof(text)/sizeof(*text), _T("x: %d"), x );<--- temp is assigned
	  TextOut(hDC,10,100,text,strlen(text));
          temp = _sntprintf ( text, sizeof(text)/sizeof(*text), _T("y: %d"), y );<--- temp is overwritten
	  TextOut(hDC,10,120,text,strlen(text));

          Rect.left = x - 2;
          Rect.top = y - 2;
          Rect.right = x + 2;
          Rect.bottom = y + 2;

          switch ( fwKeys )
          {
                case MK_CONTROL:
                       TextOut(hDC,10,140,"Control",strlen("Control"));
                       break;
                case MK_SHIFT:
                       TextOut(hDC,10,160,"Shift",strlen("Shift"));
                       break;
                case MK_LBUTTON:
                       TextOut(hDC,10,180,"Left",strlen("Left"));
                       FillRect(hDC, &Rect, hbrRed);
                       break;
                case MK_MBUTTON:
                       TextOut(hDC,10,200,"Middle",strlen("Middle"));
	               FillRect(hDC, &Rect, hbrBlue);
                       break;
                case MK_RBUTTON:
                       TextOut(hDC,10,220,"Right",strlen("Right"));
	               FillRect(hDC, &Rect, hbrYellow);
                       break;
           }
                       ReleaseDC(hWnd, hDC);
          break;
         }

	case WM_HSCROLL:
	 {
      int nPos;
	  int temp;
	  RECT Rect;
	  int nScrollCode;
	  HWND hwndScrollBar;
	  TCHAR text[256];
	  SCROLLINFO Scrollparameter;
 	  nScrollCode = (int) LOWORD(wParam);  // scroll bar value
	  nPos = (short int) HIWORD(wParam);   // scroll box position
	  hwndScrollBar = (HWND) lParam;       // handle to scroll bar
 	  hDC = GetDC(hWnd);

          Scrollparameter.cbSize = sizeof(Scrollparameter);
          Scrollparameter.fMask = SIF_ALL;
          GetScrollInfo ( hWnd, SB_HORZ, &Scrollparameter );

          Rect.left = 200;
	  Rect.top = 100;
	  Rect.right = 350;
	  Rect.bottom = 300;
	  FillRect(hDC, &Rect, hbrWhite);

          switch ( nScrollCode )
          {
                case SB_ENDSCROLL: //Ends scroll.
                        TextOut(hDC,200,120,"SB_ENDSCROLL    ",16);
	    	        Scrollparameter.nPos = Scrollparameter.nPos;<--- Redundant assignment of 'Scrollparameter.nPos' to itself.
                        break;
                case SB_LEFT: //Scrolls to the upper left.
                        TextOut(hDC,200,140,"SB_LEFT         ",16);
	    	        Scrollparameter.nPos = Scrollparameter.nMin;
                        break;
                case SB_RIGHT: //Scrolls to the lower right.
                        TextOut(hDC,200,160,"SB_RIGHT        ",16);
	    	        Scrollparameter.nPos = Scrollparameter.nMax;
                        break;
                case SB_LINELEFT: //Scrolls left by one unit.
                        TextOut(hDC,200,180,"SB_LINELEFT     ",16);
	    	        Scrollparameter.nPos--;
                        break;
                case SB_LINERIGHT: //Scrolls right by one unit.
                        TextOut(hDC,200,200,"SB_LINERIGHT    ",16);
	    	        Scrollparameter.nPos++;
                        break;
                case SB_PAGELEFT: //Scrolls left by the width of the window.
                        TextOut(hDC,200,220,"SB_PAGELEFT     ",16);
                        Scrollparameter.nPos -= Scrollparameter.nPage;
                        break;
                case SB_PAGERIGHT: //Scrolls right by the width of the window.
                        TextOut(hDC,200,240,"PAGERIGHT       ",16);
                        Scrollparameter.nPos += Scrollparameter.nPage;
                        break;
                case SB_THUMBPOSITION: //The user has dragged the scroll box (thumb) and released the mouse button. The nPos parameter indicates the position of the scroll box at the end of the drag operation.
                        TextOut(hDC,200,260,"SB_THUMBPOSITION",16);
	    	        Scrollparameter.nPos = Scrollparameter.nTrackPos;
                        break;
                case SB_THUMBTRACK: //
                        TextOut(hDC,200,280,"SB_THUMBTRACK   ",16);
	    	        Scrollparameter.nPos = Scrollparameter.nTrackPos;
                        break;
          }

 	   SetScrollInfo(
                 hWnd,    // handle to window with scroll bar
                 SB_HORZ,    // scroll bar flag
                 &Scrollparameter, // pointer to structure with scroll parameters
                 1 // redraw flag
           );
          temp = _sntprintf ( text, sizeof(text)/sizeof(*text), _T("Horizontal: %d"), Scrollparameter.nPos );
	  TextOut(hDC,200,100,text,strlen(text));
          ReleaseDC(hWnd, hDC);
 	  return 0;
         }

 	case WM_VSCROLL:
	 {
	  int nPos;
	  int temp;
	  RECT Rect;
	  int nScrollCode;
	  HWND hwndScrollBar;
	  TCHAR text[256];
	  SCROLLINFO Scrollparameter;
 	  nScrollCode = (int) LOWORD(wParam);  // scroll bar value
	  nPos = (short int) HIWORD(wParam);   // scroll box position
	  hwndScrollBar = (HWND) lParam;       // handle to scroll bar
 	  hDC = GetDC(hWnd);

          Scrollparameter.cbSize = sizeof(Scrollparameter);
          Scrollparameter.fMask = SIF_ALL;
          GetScrollInfo ( hWnd, SB_VERT, &Scrollparameter );

          Rect.left = 400;
	  Rect.top = 100;
	  Rect.right = 550;
	  Rect.bottom = 300;
	  FillRect(hDC, &Rect, hbrWhite);

          switch ( nScrollCode )
          {
                case SB_ENDSCROLL: //Ends scroll.
                        TextOut(hDC,400,120,"SB_ENDSCROLL    ",16);
	    	        Scrollparameter.nPos = Scrollparameter.nPos;<--- Redundant assignment of 'Scrollparameter.nPos' to itself.
	    	        break;
                case SB_LEFT: //Scrolls to the upper left.
                        TextOut(hDC,400,140,"SB_LEFT         ",16);
	    	        Scrollparameter.nPos = Scrollparameter.nMin;
                        break;
                case SB_RIGHT: //Scrolls to the lower right.
                        TextOut(hDC,400,160,"SB_RIGHT        ",16);
	    	        Scrollparameter.nPos = Scrollparameter.nMax;
                        break;
                case SB_LINELEFT: //Scrolls left by one unit.
                        TextOut(hDC,400,180,"SB_LINELEFT     ",16);
	    	        Scrollparameter.nPos--;
                        break;
                case SB_LINERIGHT: //Scrolls right by one unit.
                        TextOut(hDC,400,200,"SB_LINERIGHT    ",16);
	    	        Scrollparameter.nPos++;
                        break;
                case SB_PAGELEFT: //Scrolls left by the width of the window.
                        TextOut(hDC,400,220,"SB_PAGELEFT     ",16);
                        Scrollparameter.nPos -= Scrollparameter.nPage;
                        break;
                case SB_PAGERIGHT: //Scrolls right by the width of the window.
                        TextOut(hDC,400,240,"PAGERIGHT       ",16);
                        Scrollparameter.nPos += Scrollparameter.nPage;
                        break;
                case SB_THUMBPOSITION: //The user has dragged the scroll box (thumb) and released the mouse button. The nPos parameter indicates the position of the scroll box at the end of the drag operation.
                        TextOut(hDC,400,260,"SB_THUMBPOSITION",16);
	    	        Scrollparameter.nPos = Scrollparameter.nTrackPos;
                        break;
                case SB_THUMBTRACK: //
                        TextOut(hDC,400,280,"SB_THUMBTRACK   ",16);
	    	        Scrollparameter.nPos = Scrollparameter.nTrackPos;
                        break;
          }

 	  SetScrollInfo(
                 hWnd,    // handle to window with scroll bar
                 SB_VERT,    // scroll bar flag
                 &Scrollparameter, // pointer to structure with scroll parameters
                 1 // redraw flag
          );
          temp = _sntprintf ( text, sizeof(text)/sizeof(*text), _T("Vertical: %d"), Scrollparameter.nPos );
	  TextOut(hDC,400,100,text,strlen(text));
          ReleaseDC(hWnd, hDC);
 	  return 0;
 	  }

	case WM_HOTKEY:
	 switch(wParam)
	 {
          case CTRLC:
            MessageBox(hWnd, "You just pressed Ctrl+C", "Hotkey", MB_OK | MB_ICONINFORMATION);
            break;
          case ALTF1:
            MessageBox(hWnd, "You just pressed Ctrl+Alt+F1", "Hotkey", MB_OK | MB_ICONINFORMATION);
            break;
	 }
	 break;

	case WM_DESTROY:
	  UnregisterHotKey(hWnd, CTRLC);
	  UnregisterHotKey(hWnd, ALTF1);
	  PostQuitMessage(0);
	  DeleteObject ( hbrWhite );
	  DeleteObject ( hbrGray );
	  DeleteObject ( hbrBlack );
	  DeleteObject ( hbrRed );
	  DeleteObject ( hbrBlue );
	  DeleteObject ( hbrYellow );
	  break;

	case WM_CREATE:
	 {
	  SCROLLINFO si;
	  TEXTMETRIC tm;
	  /* Register a Ctrl+Alt+C hotkey*/
	  RegisterHotKey(hWnd, CTRLC, MOD_CONTROL, VK_C);
	  RegisterHotKey(hWnd, ALTF1, MOD_CONTROL | MOD_ALT, VK_F1);

	  hbrWhite = CreateSolidBrush ( RGB(0xFF, 0xFF, 0xFF));
	  hbrGray = CreateSolidBrush ( RGB(0xAF, 0xAF, 0xAF));
	  hbrBlack = CreateSolidBrush ( RGB(0x00, 0x00, 0x00));
	  hbrRed = CreateSolidBrush ( RGB(0xFF, 0x00, 0x00));
	  hbrBlue = CreateSolidBrush ( RGB(0x00, 0x00, 0xFF));
	  hbrYellow = CreateSolidBrush ( RGB(0xFF, 0xFF, 0x00));

	  si.cbSize = sizeof(si);
	  si.fMask = SIF_ALL;
          si.nMin = 0;
          si.nMax = 100;
          si.nPage = 5;
	  si.nPos = 0;

	  SetScrollInfo ( hWnd, SB_HORZ, &si, FALSE );
	  SetScrollInfo ( hWnd, SB_VERT, &si, FALSE );


	  /* The window is being created. Create our button
	   * window now. */

	  /* First we use the system fixed font size to choose
	   * a nice button size. */
	  hDC = GetDC (hWnd);
	  SelectObject (hDC, GetStockObject (SYSTEM_FIXED_FONT));
	  GetTextMetrics (hDC, &tm);
	  cx = tm.tmAveCharWidth * 30;
	  cy = (tm.tmHeight + tm.tmExternalLeading) * 2;
	  ReleaseDC (hWnd, hDC);

	  /* Now create the button */
	  hwndButton = CreateWindow (
	          "button",         /* Builtin button class */
	          "Click Here",
	          WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
	          0, 0, cx, cy,
	          hWnd,             /* Parent is this window. */
	          (HMENU) 1,        /* Control ID: 1 */
	          ((LPCREATESTRUCT) lParam)->hInstance,
	          NULL
	          );

	  return 0;
          break;
	 }

	 case WM_PAINT:
	  hDC = BeginPaint(hWnd, &ps);
	  TextOut(hDC, 10, 10, "Hello World from ReactOS!",
			strlen("Hello World from ReactOS!"));
	  TextOut(hDC, 10, 80, "Press Ctrl+C or Ctrl+Alt+F1 to test Hotkey support.",
			strlen("Press Ctrl+C or Ctrl+Alt+F1 to test Hotkey support."));
          GetClientRect(hWnd, &clr);
          GetWindowRect(hWnd, &wir);
          sprintf(spr, "%lu,%lu,%lu,%lu              ", clr.left, clr.top, clr.right, clr.bottom);
          sprintf(sir, "%lu,%lu,%lu,%lu              ", wir.left, wir.top, wir.right, wir.bottom);
          TextOut(hDC, 10, 30, spr, 20);
          TextOut(hDC, 10, 50, sir, 20);

	  /* Draw "Hello, World" in the middle of the upper
	   * half of the window. */
	  rc.bottom = rc.bottom / 2;
	  DrawText (hDC, "Hello, World", -1, &rc,
	          DT_SINGLELINE | DT_CENTER | DT_VCENTER);

	  EndPaint (hWnd, &ps);
	  return 0;
	  break;

         case WM_SIZE:
	  /* The window size is changing. If the button exists
	   * then place it in the center of the bottom half of
	   * the window. */
	  if (hwndButton &&
	          (wParam == SIZEFULLSCREEN ||
	           wParam == SIZENORMAL)
	     )
	  {
	          rc.left = (LOWORD(lParam) - cx) / 2;
	          rc.top = HIWORD(lParam) * 3 / 4 - cy / 2;
	          MoveWindow (
	                  hwndButton,
	                  rc.left, rc.top, cx, cy, TRUE);
	  }
	  break;

         case WM_COMMAND:
	  /* Check the control ID, notification code and
	   * control handle to see if this is a button click
	   * message from our child button. */
	  if (LOWORD(wParam) == 1 &&
	      HIWORD(wParam) == BN_CLICKED &&
	      (HWND) lParam == hwndButton)
	  {
	          /* Our button was clicked. Close the window. */
	          DestroyWindow (hWnd);
	  }
	  return 0;
	  break;

	default:
	  return DefWindowProc(hWnd, msg, wParam, lParam);
	}
	return 0;
}