[WINMINE]
[reactos.git] / reactos / base / applications / games / winmine / dialog.c
1 /*
2 * WineMine (dialog.c)
3 *
4 * Copyright 2000 Joshua Thielen
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include "main.h"
22
23 INT_PTR CALLBACK CustomDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
24 {
25 BOOL IsRet;
26 static BOARD *p_board;
27
28 switch( uMsg ) {
29 case WM_INITDIALOG:
30 p_board = (BOARD*) lParam;
31 SetDlgItemInt( hDlg, IDC_EDITROWS, p_board->rows, FALSE );
32 SetDlgItemInt( hDlg, IDC_EDITCOLS, p_board->cols, FALSE );
33 SetDlgItemInt( hDlg, IDC_EDITMINES, p_board->mines, FALSE );
34 return TRUE;
35
36 case WM_COMMAND:
37 switch( LOWORD( wParam ) ) {
38 case IDOK:
39 p_board->rows = GetDlgItemInt( hDlg, IDC_EDITROWS, &IsRet, FALSE );
40 p_board->cols = GetDlgItemInt( hDlg, IDC_EDITCOLS, &IsRet, FALSE );
41 p_board->mines = GetDlgItemInt( hDlg, IDC_EDITMINES, &IsRet, FALSE );
42 CheckLevel( p_board );
43 EndDialog( hDlg, 0 );
44 return TRUE;
45
46 case IDCANCEL:
47 EndDialog( hDlg, 1 );
48 return TRUE;
49 }
50 break;
51 }
52 return FALSE;
53 }
54
55 INT_PTR CALLBACK CongratsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
56 {
57 static BOARD *p_board;
58
59 switch( uMsg ) {
60 case WM_INITDIALOG:
61 p_board = (BOARD*) lParam;
62 SetDlgItemText( hDlg, IDC_EDITNAME,
63 p_board->best_name[p_board->difficulty] );
64 return TRUE;
65
66 case WM_COMMAND:
67 switch( LOWORD( wParam ) ) {
68 case IDOK:
69 GetDlgItemText( hDlg, IDC_EDITNAME,
70 p_board->best_name[p_board->difficulty],
71 sizeof( p_board->best_name[p_board->difficulty] ) );
72 EndDialog( hDlg, 0 );
73 return TRUE;
74
75 case IDCANCEL:
76 EndDialog( hDlg, 0 );
77 return TRUE;
78 }
79 break;
80 }
81 return FALSE;
82 }
83
84 INT_PTR CALLBACK TimesDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
85 {
86 static BOARD *p_board;
87 unsigned i;
88
89 switch( uMsg ) {
90 case WM_INITDIALOG:
91 p_board = (BOARD*) lParam;
92
93 /* set best names */
94 for( i = 0; i < 3; i++ )
95 SetDlgItemText( hDlg, (IDC_NAME1) + i, p_board->best_name[i] );
96
97 /* set best times */
98 for( i = 0; i < 3; i++ )
99 SetDlgItemInt( hDlg, (IDC_TIME1) + i, p_board->best_time[i], FALSE );
100 return TRUE;
101
102 case WM_COMMAND:
103 switch( LOWORD( wParam ) ) {
104 case IDOK:
105 case IDCANCEL:
106 EndDialog( hDlg, 0 );
107 return TRUE;
108 }
109 break;
110 }
111 return FALSE;
112 }