fc4094974f05b745042cc35a840f73c3d8d9c99e
[reactos.git] / rosapps / applications / screensavers / mazescr / maze.c
1 /******************************************************************************
2 * [ maze ] ...
3 *
4 * modified: [ 03-08-15 ] Ge van Geldorp <ge@gse.nl>
5 * ported to ReactOS
6 * modified: [ 94-10-8 ] Ge van Geldorp <Ge.vanGeldorp@lr.tudelft.nl>
7 * ported to MS Windows
8 * modified: [ 3-7-93 ] Jamie Zawinski <jwz@lucid.com>
9 * added the XRoger logo, cleaned up resources, made
10 * grid size a parameter.
11 * modified: [ 3-3-93 ] Jim Randell <jmr@mddjmr.fc.hp.com>
12 * Added the colour stuff and integrated it with jwz's
13 * screenhack stuff. There's still some work that could
14 * be done on this, particularly allowing a resource to
15 * specify how big the squares are.
16 * modified: [ 10-4-88 ] Richard Hess ...!uunet!cimshop!rhess
17 * [ Revised primary execution loop within main()...
18 * [ Extended X event handler, check_events()...
19 * modified: [ 1-29-88 ] Dave Lemke lemke@sun.com
20 * [ Hacked for X11...
21 * [ Note the word "hacked" -- this is extremely ugly, but at
22 * [ least it does the job. NOT a good programming example
23 * [ for X.
24 * original: [ 6/21/85 ] Martin Weiss Sun Microsystems [ SunView ]
25 *
26 ******************************************************************************
27 Copyright 1988 by Sun Microsystems, Inc. Mountain View, CA.
28
29 All Rights Reserved
30
31 Permission to use, copy, modify, and distribute this software and its
32 documentation for any purpose and without fee is hereby granted,
33 provided that the above copyright notice appear in all copies and that
34 both that copyright notice and this permission notice appear in
35 supporting documentation, and that the names of Sun or MIT not be
36 used in advertising or publicity pertaining to distribution of the
37 software without specific prior written permission. Sun and M.I.T.
38 make no representations about the suitability of this software for
39 any purpose. It is provided "as is" without any express or implied warranty.
40
41 SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
42 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 PURPOSE. IN NO EVENT SHALL SUN BE LIABLE FOR ANY SPECIAL, INDIRECT
44 OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
45 OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
46 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
47 OR PERFORMANCE OF THIS SOFTWARE.
48 *****************************************************************************/
49
50 #define STRICT
51
52 #include <stdlib.h>
53 #include <string.h>
54 #include <time.h>
55 #include <windows.h> /* required for all Windows applications */
56 #include <scrnsave.h>
57 #include "resource.h"
58
59 #define APPNAME _T("Maze")
60
61 //static BOOL InitInstance(HWND hParent);
62 LRESULT CALLBACK ScreenSaverProc(HWND hWnd, UINT message, WPARAM uParam, LPARAM lParam);
63 static int choose_door();
64 static long backup();
65 static void draw_wall();
66 static void draw_solid_square(int, int, int, HDC, HBRUSH);
67 static void enter_square(int, HDC, HBRUSH);
68
69 extern HINSTANCE hMainInstance; /* current instance */
70 HBRUSH hBrushDead;
71 HBRUSH hBrushLiving;
72 HPEN hPenWall;
73 HDC hDC;
74 //static BOOL waiting;
75
76 static int solve_delay, pre_solve_delay, post_solve_delay;
77
78 #define MAX_MAZE_SIZE_X ((unsigned long) 1000) // Dynamic detection?
79 #define MAX_MAZE_SIZE_Y ((unsigned long) 1000) // Dynamic detection?
80
81 #define MOVE_LIST_SIZE (MAX_MAZE_SIZE_X * MAX_MAZE_SIZE_Y)
82
83 #define WALL_TOP 0x8000
84 #define WALL_RIGHT 0x4000
85 #define WALL_BOTTOM 0x2000
86 #define WALL_LEFT 0x1000
87
88 #define DOOR_IN_TOP 0x800
89 #define DOOR_IN_RIGHT 0x400
90 #define DOOR_IN_BOTTOM 0x200
91 #define DOOR_IN_LEFT 0x100
92 #define DOOR_IN_ANY 0xF00
93
94 #define DOOR_OUT_TOP 0x80
95 #define DOOR_OUT_RIGHT 0x40
96 #define DOOR_OUT_BOTTOM 0x20
97 #define DOOR_OUT_LEFT 0x10
98
99 #define START_SQUARE 0x2
100 #define END_SQUARE 0x1
101
102 #define border_x (0)
103 #define border_y (0)
104
105 #define get_random(x) (rand() % (x))
106
107 static unsigned short maze[MAX_MAZE_SIZE_X][MAX_MAZE_SIZE_Y];
108
109 static struct {
110 unsigned int x;
111 unsigned int y;
112 unsigned int dir;
113 } move_list[MOVE_LIST_SIZE], save_path[MOVE_LIST_SIZE], path[MOVE_LIST_SIZE];
114
115 static int maze_size_x, maze_size_y;
116 static long sqnum, path_length;
117 static int cur_sq_x, cur_sq_y;
118 static int start_x, start_y, start_dir, end_x, end_y, end_dir;
119 static int grid_width, grid_height;
120 static int bw;
121 static int state = 1, pathi = 0;
122
123 static void set_maze_sizes(width, height)
124 int width, height;
125 {
126 maze_size_x = (width -1)/ grid_width;
127 maze_size_y = (height-1) / grid_height;
128 if (maze_size_x > MAX_MAZE_SIZE_X)
129 maze_size_x = MAX_MAZE_SIZE_X;
130 if (maze_size_y > MAX_MAZE_SIZE_Y)
131 maze_size_y = MAX_MAZE_SIZE_Y;
132 }
133
134 static void initialize_maze() /* draw the surrounding wall and start/end squares */
135 {
136 register int i, j, wall;
137
138 /* initialize all squares */
139 for (i = 0; i < maze_size_x; i++) {
140 for (j = 0; j < maze_size_y; j++) {
141 maze[i][j] = 0;
142 }
143 }
144
145 /* top wall */
146 for (i = 0; i < maze_size_x; i++) {
147 maze[i][0] |= WALL_TOP;
148 }
149
150 /* right wall */
151 for (j = 0; j < maze_size_y; j++) {
152 maze[maze_size_x - 1][j] |= WALL_RIGHT;
153 }
154
155 /* bottom wall */
156 for (i = 0; i < maze_size_x; i++) {
157 maze[i][maze_size_y - 1] |= WALL_BOTTOM;
158 }
159
160 /* left wall */
161 for (j = 0; j < maze_size_y; j++) {
162 maze[0][j] |= WALL_LEFT;
163 }
164
165 /* set start square */
166 wall = get_random(4);
167 switch (wall) {
168 case 0:
169 i = get_random(maze_size_x);
170 j = 0;
171 break;
172 case 1:
173 i = maze_size_x - 1;
174 j = get_random(maze_size_y);
175 break;
176 case 2:
177 i = get_random(maze_size_x);
178 j = maze_size_y - 1;
179 break;
180 case 3:
181 i = 0;
182 j = get_random(maze_size_y);
183 break;
184 }
185 maze[i][j] |= START_SQUARE;
186 maze[i][j] |= (DOOR_IN_TOP >> wall);
187 maze[i][j] &= ~(WALL_TOP >> wall);
188 cur_sq_x = i;
189 cur_sq_y = j;
190 start_x = i;
191 start_y = j;
192 start_dir = wall;
193 sqnum = 0;
194
195 /* set end square */
196 wall = (wall + 2) % 4;
197 switch (wall) {
198 case 0:
199 i = get_random(maze_size_x);
200 j = 0;
201 break;
202 case 1:
203 i = maze_size_x - 1;
204 j = get_random(maze_size_y);
205 break;
206 case 2:
207 i = get_random(maze_size_x);
208 j = maze_size_y - 1;
209 break;
210 case 3:
211 i = 0;
212 j = get_random(maze_size_y);
213 break;
214 }
215 maze[i][j] |= END_SQUARE;
216 maze[i][j] |= (DOOR_OUT_TOP >> wall);
217 maze[i][j] &= ~(WALL_TOP >> wall);
218 end_x = i;
219 end_y = j;
220 end_dir = wall;
221 }
222
223 static void create_maze(HWND hWnd) /* create a maze layout given the initialized maze */
224 {
225 register int i, newdoor = 0;
226
227 do {
228 move_list[sqnum].x = cur_sq_x;
229 move_list[sqnum].y = cur_sq_y;
230 move_list[sqnum].dir = newdoor;
231 while ((newdoor = choose_door(hDC)) == -1) { /* pick a door */
232 if (backup() == -1) { /* no more doors ... backup */
233 return; /* done ... return */
234 }
235 }
236
237 /* mark the out door */
238 maze[cur_sq_x][cur_sq_y] |= (DOOR_OUT_TOP >> newdoor);
239
240 switch (newdoor) {
241 case 0: cur_sq_y--;
242 break;
243 case 1: cur_sq_x++;
244 break;
245 case 2: cur_sq_y++;
246 break;
247 case 3: cur_sq_x--;
248 break;
249 }
250 sqnum++;
251
252 /* mark the in door */
253 maze[cur_sq_x][cur_sq_y] |= (DOOR_IN_TOP >> ((newdoor + 2) % 4));
254
255 /* if end square set path length and save path */
256 if (maze[cur_sq_x][cur_sq_y] & END_SQUARE) {
257 path_length = sqnum;
258 for (i = 0; i < path_length; i++) {
259 save_path[i].x = move_list[i].x;
260 save_path[i].y = move_list[i].y;
261 save_path[i].dir = move_list[i].dir;
262 }
263 }
264 } while (1);
265 }
266
267 static int choose_door(HDC hDC) /* pick a new path */
268 {
269 int candidates[3];
270 register int num_candidates;
271
272 num_candidates = 0;
273
274 /* top wall */
275 if (maze[cur_sq_x][cur_sq_y] & DOOR_IN_TOP)
276 goto rightwall;
277 if (maze[cur_sq_x][cur_sq_y] & DOOR_OUT_TOP)
278 goto rightwall;
279 if (maze[cur_sq_x][cur_sq_y] & WALL_TOP)
280 goto rightwall;
281 if (maze[cur_sq_x][cur_sq_y - 1] & DOOR_IN_ANY) {
282 maze[cur_sq_x][cur_sq_y] |= WALL_TOP;
283 maze[cur_sq_x][cur_sq_y - 1] |= WALL_BOTTOM;
284 draw_wall(cur_sq_x, cur_sq_y, 0, hDC);
285 goto rightwall;
286 }
287 candidates[num_candidates++] = 0;
288
289 rightwall:
290 /* right wall */
291 if (maze[cur_sq_x][cur_sq_y] & DOOR_IN_RIGHT)
292 goto bottomwall;
293 if (maze[cur_sq_x][cur_sq_y] & DOOR_OUT_RIGHT)
294 goto bottomwall;
295 if (maze[cur_sq_x][cur_sq_y] & WALL_RIGHT)
296 goto bottomwall;
297 if (maze[cur_sq_x + 1][cur_sq_y] & DOOR_IN_ANY) {
298 maze[cur_sq_x][cur_sq_y] |= WALL_RIGHT;
299 maze[cur_sq_x + 1][cur_sq_y] |= WALL_LEFT;
300 draw_wall(cur_sq_x, cur_sq_y, 1, hDC);
301 goto bottomwall;
302 }
303 candidates[num_candidates++] = 1;
304
305 bottomwall:
306 /* bottom wall */
307 if (maze[cur_sq_x][cur_sq_y] & DOOR_IN_BOTTOM)
308 goto leftwall;
309 if (maze[cur_sq_x][cur_sq_y] & DOOR_OUT_BOTTOM)
310 goto leftwall;
311 if (maze[cur_sq_x][cur_sq_y] & WALL_BOTTOM)
312 goto leftwall;
313 if (maze[cur_sq_x][cur_sq_y + 1] & DOOR_IN_ANY) {
314 maze[cur_sq_x][cur_sq_y] |= WALL_BOTTOM;
315 maze[cur_sq_x][cur_sq_y + 1] |= WALL_TOP;
316 draw_wall(cur_sq_x, cur_sq_y, 2, hDC);
317 goto leftwall;
318 }
319 candidates[num_candidates++] = 2;
320
321 leftwall:
322 /* left wall */
323 if (maze[cur_sq_x][cur_sq_y] & DOOR_IN_LEFT)
324 goto donewall;
325 if (maze[cur_sq_x][cur_sq_y] & DOOR_OUT_LEFT)
326 goto donewall;
327 if (maze[cur_sq_x][cur_sq_y] & WALL_LEFT)
328 goto donewall;
329 if (maze[cur_sq_x - 1][cur_sq_y] & DOOR_IN_ANY) {
330 maze[cur_sq_x][cur_sq_y] |= WALL_LEFT;
331 maze[cur_sq_x - 1][cur_sq_y] |= WALL_RIGHT;
332 draw_wall(cur_sq_x, cur_sq_y, 3, hDC);
333 goto donewall;
334 }
335 candidates[num_candidates++] = 3;
336
337 donewall:
338 if (num_candidates == 0)
339 return -1;
340 if (num_candidates == 1)
341 return candidates[0];
342 return candidates[get_random(num_candidates)];
343
344 }
345
346 static long backup() /* back up a move */
347 {
348 sqnum--;
349 if (0 <= sqnum) {
350 cur_sq_x = move_list[sqnum].x;
351 cur_sq_y = move_list[sqnum].y;
352 }
353 return sqnum;
354 }
355
356 static void draw_solid_square(i, j, dir, hDC, hBrush) /* draw a solid square in a square */
357 register int i, j, dir;
358 HDC hDC;
359 HBRUSH hBrush;
360 {
361 RECT rc;
362
363 switch (dir) {
364 case 0:
365 rc.left = border_x + bw + grid_width * i;
366 rc.right = rc.left + grid_width - (bw + bw);
367 rc.top = border_y - bw + grid_height * j;
368 rc.bottom = rc.top + grid_height;
369 break;
370 case 1:
371 rc.left = border_x + bw + grid_width * i;
372 rc.right = rc.left + grid_width;
373 rc.top = border_y + bw + grid_height * j;
374 rc.bottom = rc.top + grid_height - (bw + bw);
375 break;
376 case 2:
377 rc.left = border_x + bw + grid_width * i;
378 rc.right = rc.left + grid_width - (bw + bw);
379 rc.top = border_y + bw + grid_height * j;
380 rc.bottom = rc.top + grid_height;
381 break;
382 case 3:
383 rc.left = border_x - bw + grid_width * i;
384 rc.right = rc.left + grid_width;
385 rc.top = border_y + bw + grid_height * j;
386 rc.bottom = rc.top + grid_height - (bw + bw);
387 break;
388 }
389 (void) FillRect(hDC, &rc, hBrush);
390 }
391
392 static void draw_maze_border(HWND hWnd) /* draw the maze outline */
393 {
394 register int i, j;
395 HBRUSH hBrush;
396
397 SelectObject(hDC, hPenWall);
398
399 for (i = 0; i < maze_size_x; i++) {
400 if (maze[i][0] & WALL_TOP) {
401 MoveToEx(hDC, border_x + grid_width * i, border_y, NULL);
402 (void) LineTo(hDC, border_x + grid_width * (i + 1) - 1, border_y);
403 }
404 if ((maze[i][maze_size_y - 1] & WALL_BOTTOM)) {
405 MoveToEx(hDC, border_x + grid_width * i, border_y + grid_height * (maze_size_y) -1, NULL);
406 (void) LineTo(hDC, border_x + grid_width * (i + 1) - 1, border_y + grid_height * (maze_size_y) -1);
407 }
408 }
409 for (j = 0; j < maze_size_y; j++) {
410 if (maze[maze_size_x - 1][j] & WALL_RIGHT) {
411 MoveToEx(hDC, border_x + grid_width * maze_size_x - 1, border_y + grid_height * j, NULL);
412 (void) LineTo(hDC, border_x + grid_width * maze_size_x - 1, border_y + grid_height * (j + 1) - 1);
413 }
414 if (maze[0][j] & WALL_LEFT) {
415 MoveToEx(hDC, border_x, border_y + grid_height * j, NULL);
416 (void) LineTo(hDC, border_x, border_y + grid_height * (j + 1) - 1);
417 }
418 }
419
420 hBrush = GetStockObject(WHITE_BRUSH); // FIXME: do not hardcode
421 draw_solid_square(start_x, start_y, start_dir, hDC, hBrush);
422 draw_solid_square(end_x, end_y, end_dir, hDC, hBrush);
423 }
424
425 static void draw_wall(i, j, dir, hDC) /* draw a single wall */
426 register int i, j, dir;
427 HDC hDC;
428 {
429 SelectObject(hDC, hPenWall);
430
431 switch (dir) {
432 case 0:
433 MoveToEx(hDC, border_x + grid_width * i, border_y + grid_height * j, NULL);
434 (void) LineTo(hDC, border_x + grid_width * (i + 1), border_y + grid_height * j);
435 break;
436 case 1:
437 MoveToEx(hDC, border_x + grid_width * (i + 1), border_y + grid_height * j, NULL);
438 (void) LineTo(hDC, border_x + grid_width * (i + 1), border_y + grid_height * (j + 1));
439 break;
440 case 2:
441 MoveToEx(hDC, border_x + grid_width * i, border_y + grid_height * (j + 1), NULL);
442 (void) LineTo(hDC, border_x + grid_width * (i + 1), border_y + grid_height * (j + 1));
443 break;
444 case 3:
445 MoveToEx(hDC, border_x + grid_width * i, border_y + grid_height * j, NULL);
446 (void) LineTo(hDC, border_x + grid_width * i, border_y + grid_height * (j + 1));
447 break;
448 }
449 }
450
451 static void begin_solve_maze(HWND hWnd) /* solve it with graphical feedback */
452 {
453 /* plug up the surrounding wall */
454 maze[start_x][start_y] |= (WALL_TOP >> start_dir);
455 maze[end_x][end_y] |= (WALL_TOP >> end_dir);
456
457 /* initialize search path */
458 pathi = 0;
459 path[pathi].x = end_x;
460 path[pathi].y = end_y;
461 path[pathi].dir = -1;
462 }
463
464 static int solve_maze(HWND hWnd) /* solve it with graphical feedback */
465 {
466 int ret;
467 int action_done;
468
469 do {
470 action_done = 1;
471 if (++path[pathi].dir >= 4) {
472 pathi--;
473 draw_solid_square((int) (path[pathi].x), (int) (path[pathi].y), (int) (path[pathi].dir), hDC, hBrushDead);
474 ret = 0;
475 }
476 else if (!(maze[path[pathi].x][path[pathi].y] & (WALL_TOP >> path[pathi].dir)) &&
477 ((pathi == 0) || ((path[pathi].dir != (int) (path[pathi - 1].dir + 2) % 4)))) {
478 enter_square(pathi, hDC, hBrushLiving);
479 pathi++;
480 if (maze[path[pathi].x][path[pathi].y] & START_SQUARE) {
481
482 ret = 1;
483 }
484 else {
485 ret = 0;
486 }
487 }
488 else {
489 action_done = 0;
490 }
491 } while (!action_done);
492 return ret;
493 }
494
495 static void enter_square(int n, HDC hDC, HBRUSH hBrush) /* move into a neighboring square */
496 {
497 draw_solid_square((int) path[n].x, (int) path[n].y, (int) path[n].dir, hDC, hBrush);
498
499 path[n + 1].dir = -1;
500 switch (path[n].dir) {
501 case 0: path[n + 1].x = path[n].x;
502 path[n + 1].y = path[n].y - 1;
503 break;
504 case 1: path[n + 1].x = path[n].x + 1;
505 path[n + 1].y = path[n].y;
506 break;
507 case 2: path[n + 1].x = path[n].x;
508 path[n + 1].y = path[n].y + 1;
509 break;
510 case 3: path[n + 1].x = path[n].x - 1;
511 path[n + 1].y = path[n].y;
512 break;
513 }
514 }
515
516 static void start_timer(HWND hWnd, int iTimeout)
517 {
518 SetTimer(hWnd, 1, iTimeout, NULL);
519 }
520
521 static BOOL OnCreate(HWND hWnd, LPCREATESTRUCT lpCreateStruct)
522 {
523 int size;
524
525 srand((unsigned) time(NULL));
526
527 size = GetPrivateProfileIntW(L"maze", L"gridsize", 10, L"maze.ini");
528 pre_solve_delay = GetPrivateProfileIntW(L"maze", L"predelay", 5000, L"maze.ini");
529 post_solve_delay = GetPrivateProfileIntW(L"maze", L"postdelay", 5000, L"maze.ini");
530 solve_delay = GetPrivateProfileIntW(L"maze", L"solvedelay", 1, L"maze.ini");
531
532 if (size < 2) {
533 size = 7 + (rand() % 30);
534 }
535 grid_width = grid_height = size;
536 bw = (size > 6 ? 3 : (size - 1) / 2);
537
538 #if 0
539 /* FIXME Pattern brushes not yet implemented in ReactOS */
540 {
541 static long grayPattern [] = {
542 0x55555555,
543 0xaaaaaaaa,
544 0x55555555,
545 0xaaaaaaaa,
546 0x55555555,
547 0xaaaaaaaa,
548 0x55555555,
549 0xaaaaaaaa
550 };
551 static RGBQUAD argbq [] = {
552 { 0, 0, 255, 0 },
553 { 255, 255, 255, 0 }
554 };
555 BITMAPINFO *pbmi;
556
557 pbmi = malloc(sizeof(BITMAPINFOHEADER) + sizeof(argbq) + sizeof(grayPattern));
558 pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
559 pbmi->bmiHeader.biWidth = 8;
560 pbmi->bmiHeader.biHeight = 8;
561 pbmi->bmiHeader.biPlanes = 1;
562 pbmi->bmiHeader.biBitCount = 1;
563 pbmi->bmiHeader.biCompression = BI_RGB;
564 (void) memcpy(pbmi->bmiColors, argbq, sizeof(argbq));
565 (void) memcpy(pbmi->bmiColors + 2, grayPattern, sizeof(grayPattern));
566 hBrushDead = CreateDIBPatternBrushPt(pbmi, DIB_RGB_COLORS);
567 // hBrushDead = CreateHatchBrush(HS_DIAGCROSS, RGB(255, 0, 0));
568 free(pbmi);
569 }
570 #else
571 hBrushDead = CreateSolidBrush(RGB(255, 0, 0));
572 #endif
573 hBrushLiving = CreateSolidBrush(RGB(0, 255, 0));
574 hPenWall = CreatePen(PS_SOLID, 3, RGB(150, 150, 150));
575
576 hDC = GetDC(hWnd);
577
578 start_timer(hWnd, 1);
579
580 return TRUE;
581 }
582
583 LRESULT CALLBACK ScreenSaverProc(
584 HWND hWnd, // window handle
585 UINT message, // type of message
586 WPARAM wParam, // additional information
587 LPARAM lParam) // additional information
588 {
589 switch (message)
590 {
591 case WM_CREATE:
592 OnCreate(hWnd, (LPCREATESTRUCT) lParam);
593 break;
594 case WM_SIZE:
595 set_maze_sizes(LOWORD(lParam), HIWORD(lParam));
596 break;
597 case WM_TIMER:
598 switch (state)
599 {
600 case 2:
601 begin_solve_maze(hWnd);
602
603 state = 3;
604
605 start_timer(hWnd, solve_delay);
606 break;
607
608 case 3:
609 if (!solve_maze(hWnd))
610 {
611 start_timer(hWnd, solve_delay);
612 }
613 else
614 {
615 state = 1;
616 start_timer(hWnd, post_solve_delay);
617 }
618 break;
619
620 default:
621 initialize_maze();
622
623 SendMessage(hWnd, WM_ERASEBKGND, (WPARAM) hDC, (LPARAM) 0);
624 draw_maze_border(hWnd);
625
626 create_maze(hWnd);
627
628 state = 2;
629
630 start_timer(hWnd, pre_solve_delay);
631 break;
632 }
633 break;
634
635 case WM_DESTROY: // message: window being destroyed
636 DeleteObject(hBrushLiving);
637 DeleteObject(hBrushDead);
638 ReleaseDC(hWnd, hDC);
639 break;
640
641 default: // Passes it on if unproccessed
642 return DefScreenSaverProc(hWnd, message, wParam, lParam);
643 }
644 return 0;
645 }
646
647 BOOL WINAPI ScreenSaverConfigureDialog(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam)
648 {
649 return TRUE;
650 }
651
652 BOOL WINAPI RegisterDialogClasses(HANDLE hmodule)
653 {
654 TCHAR szTitle[256];
655 TCHAR szText[256];
656
657 LoadString(hmodule, IDS_TITLE, szTitle, 256);
658
659 LoadString(hmodule, IDS_TEXT, szText, 256);
660
661 MessageBox(0, szText, szTitle, MB_OK | MB_ICONWARNING);
662 return TRUE;
663 }